Last active
August 29, 2015 14:10
-
-
Save Aupajo/21d3de5ae11af5bb6796 to your computer and use it in GitHub Desktop.
JSP tag parser in Ruby using Parslet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class JSPTagParser < Parslet::Parser | |
rule(:java) { (str('%>').absent? >> any).repeat.as(:java) } | |
rule(:jsp) { java.as(:code) } | |
rule(:jsp_with_tags) { str('<%') >> jsp >> str('%>') } | |
rule(:text) { (str('<%').absent? >> any).repeat(1) } | |
rule(:text_with_java) { (text.as(:text) | jsp_with_tags).repeat.as(:text) } | |
root(:text_with_java) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment