Skip to content

Commit

Permalink
Replace NewParser with Parser #3
Browse files Browse the repository at this point in the history
- Enable to parse colon-less rules
  • Loading branch information
junk0612 committed Oct 15, 2023
1 parent 0f0a16b commit cfc9ecf
Show file tree
Hide file tree
Showing 4 changed files with 204 additions and 195 deletions.
9 changes: 8 additions & 1 deletion lib/lrama/new_lexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,14 @@ def lex_token
when @scanner.scan(/\d+/)
return [:INTEGER, Integer(@scanner.matched)]
when @scanner.scan(/([a-zA-Z_.][-a-zA-Z0-9_.]*)/)
return [:IDENTIFIER, build_token(type: Token::Ident, s_value: @scanner.matched)]
token = build_token(type: Token::Ident, s_value: @scanner.matched)
type =
if @scanner.check(/\s*(\[\s*[a-zA-Z_.][-a-zA-Z0-9_.]*\s*\])?\s*:/)
:IDENT_COLON
else
:IDENTIFIER
end
return [type, token]
else
raise
end
Expand Down
Loading

0 comments on commit cfc9ecf

Please sign in to comment.