Treetop: How to make combined rule?

179 views Asked by At

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?

1

There are 1 answers

0
poseid On BEST ANSWER