Skip to content

Commit

Permalink
Merge pull request #494 from ydah/optimize-lex_comment
Browse files Browse the repository at this point in the history
Optimize Lexer comment reading
  • Loading branch information
ydah authored Dec 31, 2024
2 parents 613d53f + c45d056 commit 214c511
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/lrama/lexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,11 @@ def lex_c_code
def lex_comment
until @scanner.eos? do
case
when @scanner.scan(/\n/)
newline
when @scanner.scan(/\*\//)
when @scanner.scan_until(/[\s\S]*?\*\//)
@scanner.matched.count("\n").times { newline }
return
else
@scanner.getch
when @scanner.scan_until(/\n/)
newline
end
end
end
Expand Down

0 comments on commit 214c511

Please sign in to comment.