Skip to content

Commit

Permalink
Merge pull request #174 from yui-knk/remove_unused_token_types
Browse files Browse the repository at this point in the history
Remove unused token types
  • Loading branch information
yui-knk authored Nov 3, 2023
2 parents 6d3449b + 6cf9431 commit 6334bdf
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 44 deletions.
21 changes: 0 additions & 21 deletions lib/lrama/lexer/token.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,30 +54,9 @@ def self.define_type(name)
end

# Token types
define_type(:P_expect) # %expect
define_type(:P_define) # %define
define_type(:P_printer) # %printer
define_type(:P_error_token) # %error-token
define_type(:P_lex_param) # %lex-param
define_type(:P_parse_param) # %parse-param
define_type(:P_initial_action) # %initial-action
define_type(:P_union) # %union
define_type(:P_token) # %token
define_type(:P_type) # %type
define_type(:P_nonassoc) # %nonassoc
define_type(:P_left) # %left
define_type(:P_right) # %right
define_type(:P_precedence) # %precedence
define_type(:P_prec) # %prec
define_type(:User_code) # { ... }
define_type(:Tag) # <int>
define_type(:Number) # 0
define_type(:Ident_Colon) # k_if:, k_if : (spaces can be there)
define_type(:Ident) # api.pure, tNUMBER
define_type(:Named_Ref) # [foo]
define_type(:Semicolon) # ;
define_type(:Bar) # |
define_type(:String) # "str"
define_type(:Char) # '+'
end
end
Expand Down
21 changes: 0 additions & 21 deletions sig/lrama/lexer/token.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,9 @@ module Lrama
def self.define_type: (Symbol name) -> void

# Token types
P_expect: Type
P_define: Type
P_printer: Type
P_error_token: Type
P_lex_param: Type
P_parse_param: Type
P_initial_action: Type
P_union: Type
P_token: Type
P_type: Type
P_nonassoc: Type
P_left: Type
P_right: Type
P_precedence: Type
P_prec: Type
User_code: Type
Tag: Type
Number: Type
Ident_Colon: Type
Ident: Type
Named_Ref: Type
Semicolon: Type
Bar: Type
String: Type
Char: Type
end
end
Expand Down
3 changes: 1 addition & 2 deletions spec/lrama/parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1333,9 +1333,8 @@ class : keyword_class tSTRING keyword_end { code 1 }
program: /* empty */
;
INPUT

expect { Lrama::Parser.new(y, "error_messages/parse.y").parse }.to raise_error(<<~ERROR)
error_messages/parse.y:5:14: parse error on value #<struct Lrama::Lexer::Token type=#<struct Lrama::Lexer::Token::Type id=19, name="Ident">, s_value="invalid", alias=nil> (IDENTIFIER)
error_messages/parse.y:5:14: parse error on value #<struct Lrama::Lexer::Token type=#<struct Lrama::Lexer::Token::Type id=2, name="Ident">, s_value="invalid", alias=nil> (IDENTIFIER)
%expect invalid
^
ERROR
Expand Down

0 comments on commit 6334bdf

Please sign in to comment.