Skip to content

Commit

Permalink
Merge pull request #126 from junk0612/replace-new-parser-3
Browse files Browse the repository at this point in the history
Replace NewParser with Parser #3
  • Loading branch information
yui-knk authored Oct 16, 2023
2 parents e9a224a + c2c994e commit dfeb6b7
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 dfeb6b7

Please sign in to comment.