Compiler/lexical analyzer: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) (→{{header|Perl 6}}: avoid unnecessary reparsing) |
Thundergnat (talk | contribs) 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
{{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
}
}
|