On Mon, Aug 25, 2014 at 12:50 PM, Thierry Goubier <thierry.goubier(a)gmail.com
wrote:
2014-08-25 11:12 GMT+02:00 Usman Bhatti <usman.bhatti(a)gmail.com>om>:
I understand that context is important when
parsing a program for certain
parsing related information.
In my case, I am using PetitParser more as a syntax highlighter on the
lines of PPTextHighlighter and in that case you dont need much of
contextual information. All you need is token positions. Can we envisage,
for such usage, a simplistic but more robust parser?
If you're more into that, then a lexer may be enough and a very efficient
one can be built with SmaCC.
What you're doing doesn't seems to require a parser: it is just matching
It was just a illustrative example to show the slowness of PParser due to
the recent modifications. What I want to achieve is to be able to express
keyword or lines matching (may be some day complete code blocks as well).
We found that doing it with the parser is quite easy.
It would be worth trying SmaCC to compare its performance with PP-based
solution but I am not knowledgable about SmaCC. Any pointers to where
should I start from?
regards,
Usman
Keyword [^\n] *
isn't it?
Thierry
[|string allStyles text|
string := (PharoFilesOpener default changesFileOrNil contents copyFrom: 1
to: 60000).
text := string asText.
allStyles := {
'Announcement' -> TextColor green.
'Collections' -> TextColor blue.
'File' -> TextColor blue.
'Metacello' -> TextColor red.
'Monticello' -> TextColor magenta.
'Morphic' -> TextColor orange.
'Mooose' -> TextColor green.
'FAMIX' -> TextColor green.
'Roassal' -> TextColor green.
}.
allStyles do: [ :assoc | ((assoc key asParser, #newline asParser negate
star) matchingRangesIn: string) do: [:aRange | text addAttribute: (assoc
value) from: aRange first to: aRange last] ].
text] timeToRun ==> 15 sec
_______________________________________________
Moose-dev mailing list
Moose-dev(a)iam.unibe.ch
https://www.iam.unibe.ch/mailman/listinfo/moose-dev