Compiler/lexical analyzer: Difference between revisions

m
(→‎{{header|Perl 6}}: avoid unnecessary reparsing)
m (→‎{{header|Perl 6}}: minor cleanup)
Line 1,497:
This is more complicated than strictly necessary for this task. It is set up to be easily adapted to do syntax analysis.
 
(Note: there are several bogus comments added strictlysolely to help with syntax highlighting.)
 
{{works with|Rakudo|2016.08}}
Line 1,577:
my $l;
my @pos = gather for $c_code.lines».chars.kv -> $line, $v {
take [ $line + 1, $_ ] for 1 .. ($v+1); # v+1 for newline
$l = $line+2;
}
Line 1,583:
 
for flat $c_code<tokens>.list, $c_code<eoi> -> $m {
say join "\t", @pos[$m.from].fmt('%3d'), $m.ast; ;
}
}
10,351

edits