Question

I want to make a simple JSP parser by using Treetop. Now, I have the following problem:

My basic grammar for starting is:

grammar Jspgrammar
    rule jspToken
        '<%'
    end

    rule jspPageToken
        jspToken '@page' 
    end
end

jspToken should match '<%' while jspPageToken should match '<%@page'

When I try this in irb:

   load 'jspgrammar.rb'
   parser=JspgrammarParser.new
   tree=parser.parse("<%")
   => SyntaxNode offset=0, "<%"

But when I try

   tree=parser.parse("<%@page")
   => nil

What am I missing?

Was it helpful?
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top