Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hashrocket: parser behaves differently with parser-gem #4

Open
namiwang opened this issue Nov 29, 2018 · 0 comments
Open

hashrocket: parser behaves differently with parser-gem #4

namiwang opened this issue Nov 29, 2018 · 0 comments

Comments

@namiwang
Copy link
Contributor

WTF lexer.advance
WTF emitted token tLBRACE
{ 1 => 2, :foo => "bar" }
^ tLBRACE "{"                                   expr_beg     [0 <= cond] [0 <= cmdarg]
read    :tLBRACE(tLBRACE) ["{", #<Parser::Source::Range tmp/a.rb 0...1>]

shift   tLBRACE
        [ (tLBRACE ["{", #<Parser::Source::Range tmp/a.rb 0...1>]) ]

goto    61
        [ 0 61 ]

WTF lexer.advance
WTF emitted token tINTEGER
{ 1 => 2, :foo => "bar" }
  ^ tINTEGER 1                                  expr_end     [0 <= cond] [0 <= cmdarg]
read    :tINTEGER(tINTEGER) [1, #<Parser::Source::Range tmp/a.rb 2...3>]

shift   tINTEGER
        [ (tLBRACE ["{", #<Parser::Source::Range tmp/a.rb 0...1>]) (tINTEGER [1, #<Parser::Source::Range tmp/a.rb 2...3>]) ]

goto    93
        [ 0 61 93 ]

  >>> STATE SET <<<                             expr_end     [0 <= cond] [0 <= cmdarg]
reduce  tINTEGER --> simple_numeric
        [ (tLBRACE ["{", #<Parser::Source::Range tmp/a.rb 0...1>]) (simple_numeric s(:int, 1)) ]

goto    92
        [ 0 61 92 ]

reduce  simple_numeric --> numeric
        [ (tLBRACE ["{", #<Parser::Source::Range tmp/a.rb 0...1>]) (numeric s(:int, 1)) ]

goto    76
        [ 0 61 76 ]

reduce  numeric --> literal
        [ (tLBRACE ["{", #<Parser::Source::Range tmp/a.rb 0...1>]) (literal s(:int, 1)) ]

goto    48
        [ 0 61 48 ]

reduce  literal --> primary
        [ (tLBRACE ["{", #<Parser::Source::Range tmp/a.rb 0...1>]) (primary s(:int, 1)) ]

goto    47
        [ 0 61 47 ]

WTF lexer.advance
WTF emitted token tASSOC
WTF emitted token tINTEGER
{ 1 => 2, :foo => "bar" }
    ^~ tASSOC "=>"                              expr_end     [0 <= cond] [0 <= cmdarg]
read    :tASSOC(tASSOC) ["=>", #<Parser::Source::Range tmp/a.rb 4...6>]

// WHAT THE HELL why it doesnot reduce primary->arg directly

reduce  primary --> arg
        [ (tLBRACE ["{", #<Parser::Source::Range tmp/a.rb 0...1>]) (arg s(:int, 1)) ]

goto    280
        [ 0 61 280 ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant