001 /*@bgen(jjtree) Generated By:JJTree: Do not edit this line. JSSPParser.jj */
002 /*@egen*/
003 /*
004  *  Descripter 1.0 - Java Script Engines
005  *  Copyright (C) 2010-2015  Jianjun Liu (J.J.Liu)
006  *  
007  *  This program is free software: you can redistribute it and/or modify
008  *  it under the terms of the GNU Affero General Public License as published by
009  *  the Free Software Foundation, either version 3 of the License, or
010  *  (at your option) any later version.
011  *  
012  *  This program is distributed in the hope that it will be useful,
013  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
015  *  GNU Affero General Public License for more details.
016  *  
017  *  You should have received a copy of the GNU Affero General Public License
018  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
019  */
020 
021 options {
022                             
023     FORCE_LA_CHECK = false;
024     JDK_VERSION = "1.6";
025     JAVA_UNICODE_ESCAPE = true;
026     UNICODE_INPUT = true;
027                  
028                                 
029                              
030                                                 
031                          
032                            
033                             
034     STATIC = false;
035                    
036                                  
037                                    
038                            
039 }
040 
041 PARSER_BEGIN(JSSPParser)
042 
043 package org.descripter.js.ss.parse;
044 
045 public class JSSPParser/*@bgen(jjtree)*/implements JSSPParserTreeConstants/*@egen*/
046 {/*@bgen(jjtree)*/
047   protected JJTJSSPParserState jjtree = new JJTJSSPParserState();
048 
049 /*@egen*/
050     void jjtreeOpenNodeScope(Node n) {
051         ((AbstractNode)n).firstToken = getToken(1);
052     }
053 
054     void jjtreeCloseNodeScope(Node n) {
055         ((AbstractNode)n).lastToken = getToken(0);
056     }
057 }
058 PARSER_END(JSSPParser)
059 
060 SPECIAL_TOKEN :
061 {
062     < LF: "\n" >     /* Line Feed */
063 |   < CR: "\r" >     /* Carriage Return */
064 |   < LS: "\u2028" > /* Line separator */
065 |   < PS: "\u2029" > /* Paragraph separator */
066 }
067 
068 MORE [IGNORE_CASE] :
069 {
070     "<%" : IN_SCRIPT
071 |   "\"" : IN_DOUBLE_STRING
072 |   "\'" : IN_SINGLE_STRING
073 }
074 
075 <IN_SCRIPT> TOKEN :
076 {
077     <SCRIPT: "%>" > : DEFAULT
078 }
079 
080 <IN_DOUBLE_STRING> TOKEN :
081 {
082     <DOUBLE_STRING: "\"" > : DEFAULT
083 }
084 
085 <IN_SINGLE_STRING> TOKEN :
086 {
087     <SINGLE_STRING: "\'" > : DEFAULT
088 }
089 
090 <DEFAULT> TOKEN :
091 {
092     <HTML:
093         (
094                  ~["<","\"","\'","\n","\r","\u2028","\u2029"]
095         |   ("<" ~["%","\"","\'","\n","\r","\u2028","\u2029"])
096         )*
097     > : DEFAULT
098 }
099 
100 <IN_DOUBLE_STRING,IN_SINGLE_STRING,IN_SCRIPT,DEFAULT> MORE :
101 {
102     < ~[] >
103 }
104 
105 JSSPPage Page()       :
106 {/*@bgen(jjtree) Page */
107   JSSPPage jjtn000 = new JSSPPage(this, JJTPAGE);
108   boolean jjtc000 = true;
109   jjtree.openNodeScope(jjtn000);
110   jjtreeOpenNodeScope(jjtn000);
111 /*@egen*/}
112 {/*@bgen(jjtree) Page */
113   try {
114 /*@egen*/
115   (
116     Script() | Html()
117   )*
118   < EOF >/*@bgen(jjtree)*/
119   {
120     jjtree.closeNodeScope(jjtn000, true);
121     jjtc000 = false;
122     jjtreeCloseNodeScope(jjtn000);
123   }
124 /*@egen*/
125   {
126     return jjtn000;
127   }/*@bgen(jjtree)*/
128   } catch (Throwable jjte000) {
129     if (jjtc000) {
130       jjtree.clearNodeScope(jjtn000);
131       jjtc000 = false;
132     } else {
133       jjtree.popNode();
134     }
135     if (jjte000 instanceof RuntimeException) {
136       throw (RuntimeException)jjte000;
137     }
138     if (jjte000 instanceof ParseException) {
139       throw (ParseException)jjte000;
140     }
141     throw (Error)jjte000;
142   } finally {
143     if (jjtc000) {
144       jjtree.closeNodeScope(jjtn000, true);
145       jjtreeCloseNodeScope(jjtn000);
146     }
147   }
148 /*@egen*/
149 }
150 
151 void Script()         :
152 {/*@bgen(jjtree) Script */
153         JSSPScript jjtn000 = new JSSPScript(this, JJTSCRIPT);
154         boolean jjtc000 = true;
155         jjtree.openNodeScope(jjtn000);
156         jjtreeOpenNodeScope(jjtn000);
157 /*@egen*/
158     Token t;
159 }
160 {/*@bgen(jjtree) Script */
161 try {
162 /*@egen*/
163 (
164     t = < SCRIPT >
165 )/*@bgen(jjtree)*/
166         {
167           jjtree.closeNodeScope(jjtn000, true);
168           jjtc000 = false;
169           jjtreeCloseNodeScope(jjtn000);
170         }
171 /*@egen*/   {
172         jjtn000.jjtSetValue(t.image.substring(2, t.image.length() - 2));
173     }/*@bgen(jjtree)*/
174 } finally {
175   if (jjtc000) {
176     jjtree.closeNodeScope(jjtn000, true);
177     jjtreeCloseNodeScope(jjtn000);
178   }
179 }
180 /*@egen*/
181 }
182 
183 void Html()       :
184 {/*@bgen(jjtree) Html */
185         JSSPHtml jjtn000 = new JSSPHtml(this, JJTHTML);
186         boolean jjtc000 = true;
187         jjtree.openNodeScope(jjtn000);
188         jjtreeOpenNodeScope(jjtn000);
189 /*@egen*/
190     Token t;
191 }
192 {/*@bgen(jjtree) Html */
193 try {
194 /*@egen*/
195 (
196         t = < DOUBLE_STRING >
197     |   t = < SINGLE_STRING >
198     |   t = < HTML >
199 )/*@bgen(jjtree)*/
200         {
201           jjtree.closeNodeScope(jjtn000, true);
202           jjtc000 = false;
203           jjtreeCloseNodeScope(jjtn000);
204         }
205 /*@egen*/   {
206         jjtn000.jjtSetValue(t.image);
207     }/*@bgen(jjtree)*/
208 } finally {
209   if (jjtc000) {
210     jjtree.closeNodeScope(jjtn000, true);
211     jjtreeCloseNodeScope(jjtn000);
212   }
213 }
214 /*@egen*/
215 }
216