Got an error while parsing grammar wrong argument type Class (expected Module)

12 views
Skip to first unread message

Ivan Lo

unread,
Mar 18, 2017, 7:21:02 PM3/18/17
to Treetop Development
Hi I've got an error while parsing my grammar
 TypeError:
       wrong argument type Class (expected Module)
     # (eval):311:in `extend'
     # (eval):311:in `_nt_line'
     # (eval):21:in `block in _nt_document'
     # (eval):20:in `loop'
     # (eval):20:in `_nt_document'
     # /Users/gingray/.rvm/gems/ruby-2.2.2/gems/treetop-1.6.8/lib/treetop/runtime/compiled_parser.rb:18:in `parse'
     # ./app/services/parser/chord_parser.rb:8:in `parse'
     # ./spec/services/parser/chord_parser_spec.rb:3:in `block (2 levels) in <top (required)>'
     # ./spec/services/parser/chord_parser_spec.rb:5:in `block (2 levels) in <top (required)>'
     # ./spec/spec_helper.rb:36:in `block (2 levels) in <top (required)>'

here my grammar

grammar TreetopChord
  rule document
    (line)*
  end

  rule text
    [a-zA-Z0-9,.\s]+ <TextLiteral>
  end

  rule chord
    '{' [0-9#b/]+ '}' <ChordExpression>
  end

  rule title
    '[' [a-z]+ ']' <TitleLiteral>
  end

  rule line
    (((text / chord / title ) [\r\n]+) / (text / chord / title )) <LineLiteral>
  end
end


I've got error on <LineLiteral> if i remove this everything goes fine, but I don't know why this happens also I try to use other way for grammar like

  rule line
    (text / chord / title ) [\r\n]+ <LineLiteral> / (text / chord / title ) <LineLiteral>
  end


but got the same result.

Really grateful for any kind of help. Thanks in advance.

Reply all
Reply to author
Forward
0 new messages