SHParserST80 and the types: #- and #'$'

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

SHParserST80 and the types: #- and #'$'

Edouard Poor
I was trying to write the most compact source code to HTML/CSS I could come up with:

parser := SHParserST80 new.

code := OrderedCollection sourceCodeAt: #sort:.
ranges := parser rangesIn: code classOrMetaClass: OrderedCollection workspace: nil environment: nil.

dict := Dictionary with: 1->#whitespace.
ranges do: [ :range | dict add: range start -> range type; add: range end + 1 -> #whitespace ].
spans := dict associations sorted overlappingPairsCollect: [ :a :b |
'<span class="', a value, '">', (code copyFrom: a key to: b key - 1), '</span>' ].

but SHParserST80's use of #- and #'$' might mess things up a little. What do you think about replacing those two symbols with textual versions (like #minus #characterPrefix)?

I'm kind of serious - Shout's two non-textual type names seem ugly.

Cheers,
Edouard.
Reply | Threaded
Open this post in threaded view
|

Re: SHParserST80 and the types: #- and #'$'

Benjamin Van Ryseghem (Pharo)
JB and I were discuting about changing the SHParser by PetitParser, maybe your problem is a good excuse to do it :°


Ben


2011/2/26 Edouard Poor <[hidden email]>
I was trying to write the most compact source code to HTML/CSS I could come up with:

parser := SHParserST80 new.

code := OrderedCollection sourceCodeAt: #sort:.
ranges := parser rangesIn: code classOrMetaClass: OrderedCollection workspace: nil environment: nil.

dict := Dictionary with: 1->#whitespace.
ranges do: [ :range | dict add: range start -> range type; add: range end + 1 -> #whitespace ].
spans := dict associations sorted overlappingPairsCollect: [ :a :b |
'<span class="', a value, '">', (code copyFrom: a key to: b key - 1), '</span>' ].

but SHParserST80's use of #- and #'$' might mess things up a little. What do you think about replacing those two symbols with textual versions (like #minus #characterPrefix)?

I'm kind of serious - Shout's two non-textual type names seem ugly.

Cheers,
Edouard.