Skip to content

Commit

Permalink
Add %error-token
Browse files Browse the repository at this point in the history
  • Loading branch information
junk0612 committed Oct 2, 2023
1 parent 1ee5f00 commit 08bc098
Show file tree
Hide file tree
Showing 4 changed files with 392 additions and 356 deletions.
3 changes: 2 additions & 1 deletion lib/lrama/grammar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def nterms
def extract_references
@_rules.each do |lhs, rhs, _|
rhs.each_with_index do |token, index|
next if token.class == Lrama::Grammar::Symbol || token.type != Lrama::Lexer::Token::User_code
next if token.class == Lrama::Grammar::Symbol || token.type != Lrama::Lexer::Token::User_code

scanner = StringScanner.new(token.s_value)
references = []
Expand Down Expand Up @@ -348,6 +348,7 @@ def extract_references
end

token.references = references
token.numberize_references(lhs, rhs)
build_references(token)
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/lrama/new_lexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def lex_token
return [@scanner.matched, @scanner.matched]
when @scanner.scan(/;/)
return [@scanner.matched, @scanner.matched]
when @scanner.scan(/%union|%token|%type|%left|%right|%nonassoc|%expect|%define|%require|%printer|%lex-param|%parse-param|%initial-action|%prec/)
when @scanner.scan(/%union|%token|%type|%left|%right|%nonassoc|%expect|%define|%require|%printer|%lex-param|%parse-param|%initial-action|%prec|%error-token/)
return [@scanner.matched, @scanner.matched]
when @scanner.scan(/<\w+>/)
return [:TAG, @scanner.matched]
Expand Down
Loading

0 comments on commit 08bc098

Please sign in to comment.