in reply to Positions of certain tokens in syntax tree
Here a "naive" approach by embedding Perl code.
When parsing a recursive syntax you are able to put a Perl code after each match pattern using (?{...}) and $^N will give you the content of this last match.
Compare this example from perlre
$_ = "The brown fox jumps over the lazy dog"; /the (\S+)(?{ $color = $^N }) (\S+)(?{ $animal = $^N })/i; print "color = $color, animal = $animal\n";
instead of storing the match you might concatenate it to a "result" string or print it to a channel
> and I want to change all identifiers to upper case in the text
depending on match pattern execute a uc before returning the result.
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
FootballPerl is like chess, only without the dice
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Positions of certain tokens in syntax tree
by rubystallion (Novice) on Dec 14, 2019 at 08:43 UTC |