2 // import org.xml.sax.helpers.*;
4 class BookkeepingLexer extends Lexer;
8 charVocabulary='\u0000'..'\u007F';
9 exportVocab=BookkeepingLexer;
14 LEFT_PAREN :'(' { System.out.println("LEFT PARENTHESESE '('"); };
16 RIGHT_PAREN :')' { System.out.println("RIGHT PARENTHESESE ')'"); };
18 DELIMITER :',' { System.out.println("DELIMITER ','"); };
20 OPT_ENTRY :"-entry" WHITESPACE( 'A'..'Z' | 'a'..'z' | '0'..'9' )* { System.out.println("-entry"); };
22 OPT_ACCOUNT :"-account" WHITESPACE( 'A'..'Z' | 'a'..'z' | '0'..'9' )*;
24 OPT_JOURNAL :"-journal" WHITESPACE( 'A'..'Z' | 'a'..'z' | '0'..'9' )*;
26 OPT_NAME :"-name" WHITESPACE( 'A'..'Z' | 'a'..'z' | '0'..'9' )*;
28 OPT_TYPE :"-type" WHITESPACE( 'A'..'Z' | 'a'..'z' | '0'..'9' )*;
30 OPT_CWEIGHT :"-counterWeight" WHITESPACE("debit"|"credit");
32 OPT_AMOUNT :"-amount" WHITESPACE(('0'..'9')+'.'('0'..'9')('0'..'9'))*;
34 OPT_ID :"-id" WHITESPACE( 'A'..'Z' | 'a'..'z' | '0'..'9' )*;
36 OPT_ENTRYNUM :"-entrynum" WHITESPACE('0'..'9')*;
38 OPT_DATE :"-date" WHITESPACE(('0'..'9')('0'..'9')'/'('0'..'9')('0'..'9')'/'('0'..'9')('0'..'9')('0'..'9')('0'..'9'))*;
40 OPT_FILE :"-F" WHITESPACE( 'A'..'Z' | 'a'..'z' | '0'..'9' )*;
42 COMMAND_CREATE :("create")+ { System.out.println("COMMAND_CREATE"); };
44 COMMAND_ADD! :("add")+ { System.out.println("COMMAND_ADD"); };
46 COMMAND_REMOVE :("remove")+ { System.out.println("COMMAND_REMOVE"); };
48 COMMAND_REVERSE :("reverse")+ { System.out.println("COMMAND_REVERSE"); };
50 COMMAND_FIND :("find")+ { System.out.println("COMMAND_FIND"); };
52 COMMAND_LOAD :("load")+ { System.out.println("COMMAND_LOAD"); };
54 COMMAND_LIST :("list")+ { System.out.println("COMMAND_LIST"); };
56 COMMAND_LOGIN :("login")+ { System.out.println("COMMAND_LOGIN"); };
58 COMMAND_LOGOUT :("logout")+ { System.out.println("COMMAND_LOGOUT"); };
60 COMMAND_EXIT :("exit")+ { System.out.println("COMMAND_EXIT"); };
62 END_COMMAND :';' { System.out.println("END COMMAND ';'"); };
64 WHITESPACE :( ' ' | '\r' | '\n' | '\t' ) {
65 System.out.println("");
66 System.out.println("WHITE SPACE ' '");
70 // inherited from grammar XMLLexer
73 // inherited from grammar XMLLexer
74 DOCTYPE! :"<!DOCTYPE" WS rootElementName:NAME
75 { System.out.println("ROOTELEMENT: "+rootElementName.getText()); }
78 ( "SYSTEM" WS sys1:STRING
79 { System.out.println("SYSTEM: "+sys1.getText()); }
81 | "PUBLIC" WS pub:STRING WS sys2:STRING
82 { System.out.println("PUBLIC: "+pub.getText()); }
83 { System.out.println("SYSTEM: "+sys2.getText()); }
87 ( dtd:INTERNAL_DTD ( WS )?
88 { System.out.println("DTD: "+dtd.getText()); }
94 // inherited from grammar XMLLexer
95 protected INTERNAL_DTD :'['!
96 // reports warning, but is absolutely ok (checked generated code)
97 // besides this warning was not generated with k=1 which is
98 // enough for this rule...
99 ( options {greedy=false;} : NL
100 | STRING // handle string specially to avoid to mistake ']' in string for end dtd
106 // inherited from grammar XMLLexer
107 PI! :// { AttributesImpl attributes = new AttributesImpl(); }
111 ( ATTR /*[attributes]*/ ( WS )? )*
113 if (target.getText().equalsIgnoreCase("xml")) {
114 // this is the xml declaration, handle it
115 System.out.println("XMLDECL: "+target.getText());
117 System.out.println("PI: "+target.getText());
123 // inherited from grammar XMLLexer
124 COMMENT! :"<!--" c:COMMENT_DATA "-->"
125 { System.out.println("COMMENT: "+c.getText()); }
128 // inherited from grammar XMLLexer
129 protected COMMENT_DATA :( options {greedy=false;} : NL
134 // inherited from grammar XMLLexer
135 ENDTAG! :"</" g:NAME ( WS )? '>'
136 { System.out.println("ENDTAG: "+g.getText()); }
139 // inherited from grammar XMLLexer
140 STARTTAG! :// XXX should org.xml.sax.AttributesImpl be replaced by something else?
141 // { AttributesImpl attributes = new AttributesImpl(); }
145 ( ATTR /*[attributes]*/ ( WS )? )*
147 { System.out.println("EMTYTAG: "+g.getText()); }
149 { System.out.println("STARTTAG: "+g.getText()); }
153 // inherited from grammar XMLLexer
154 PCDATA! :p:PCDATA_DATA
155 { System.out.println("PCDATA: "+p.getText()); }
158 // inherited from grammar XMLLexer
159 protected PCDATA_DATA :( options {greedy=true;} : NL
160 | ~( '<' | '\n' | '\r' )
164 // inherited from grammar XMLLexer
165 CDATABLOCK! :"<![CDATA[" p:CDATA_DATA "]]>"
166 { System.out.println("CDATABLOCK: "+p.getText()); }
169 // inherited from grammar XMLLexer
170 protected CDATA_DATA :( options {greedy=false;} : NL
175 // inherited from grammar XMLLexer
176 protected ATTR :name:NAME ( WS )? '=' ( WS )? value:STRING_NO_QUOTE
178 { attributes.addAttribute("", "", name.getText(), "CDATA",
182 { System.out.println("ATTRIBUTE: "+name.getText()+"="+value.getText()); }
185 // inherited from grammar XMLLexer
186 protected STRING_NO_QUOTE :'"'! (~'"')* '"'!
187 | '\''! (~'\'')* '\''!
190 // inherited from grammar XMLLexer
191 protected STRING :'"' (~'"')* '"'
195 // inherited from grammar XMLLexer
196 protected NAME :( LETTER | '_' | ':') ( options {greedy=true;} : NAMECHAR )*
199 // inherited from grammar XMLLexer
200 protected NAMECHAR :LETTER | DIGIT | '.' | '-' | '_' | ':'
203 // inherited from grammar XMLLexer
204 protected DIGIT :'0'..'9'
207 // inherited from grammar XMLLexer
208 protected LETTER :'a'..'z'
212 // inherited from grammar XMLLexer
213 protected WS :( options {
221 // inherited from grammar XMLLexer
222 protected ESC :( '\t'
227 // inherited from grammar XMLLexer
228 protected NL :( options {
229 generateAmbigWarnings=false;
239 class XMLLexer extends Lexer;
243 charVocabulary='\u0000'..'\u007F';
245 exportVocab=XMLLexer;
250 DOCTYPE! :"<!DOCTYPE" WS rootElementName:NAME
251 { System.out.println("ROOTELEMENT: "+rootElementName.getText()); }
254 ( "SYSTEM" WS sys1:STRING
255 { System.out.println("SYSTEM: "+sys1.getText()); }
257 | "PUBLIC" WS pub:STRING WS sys2:STRING
258 { System.out.println("PUBLIC: "+pub.getText()); }
259 { System.out.println("SYSTEM: "+sys2.getText()); }
263 ( dtd:INTERNAL_DTD ( WS )?
264 { System.out.println("DTD: "+dtd.getText()); }
270 protected INTERNAL_DTD :'['!
271 // reports warning, but is absolutely ok (checked generated code)
272 // besides this warning was not generated with k=1 which is
273 // enough for this rule...
274 ( options {greedy=false;} : NL
275 | STRING // handle string specially to avoid to mistake ']' in string for end dtd
281 PI! :// { AttributesImpl attributes = new AttributesImpl(); }
285 ( ATTR /*[attributes]*/ ( WS )? )*
287 if (target.getText().equalsIgnoreCase("xml")) {
288 // this is the xml declaration, handle it
289 System.out.println("XMLDECL: "+target.getText());
291 System.out.println("PI: "+target.getText());
297 COMMENT! :"<!--" c:COMMENT_DATA "-->"
298 { System.out.println("COMMENT: "+c.getText()); }
301 protected COMMENT_DATA :( options {greedy=false;} : NL
306 ENDTAG! :"</" g:NAME ( WS )? '>'
307 { System.out.println("ENDTAG: "+g.getText()); }
312 STARTTAG! :// XXX should org.xml.sax.AttributesImpl be replaced by something else?
313 // { AttributesImpl attributes = new AttributesImpl(); }
317 ( ATTR /*[attributes]*/ ( WS )? )*
319 { System.out.println("EMTYTAG: "+g.getText()); }
321 { System.out.println("STARTTAG: "+g.getText()); }
325 PCDATA! :p:PCDATA_DATA
326 { System.out.println("PCDATA: "+p.getText()); }
329 protected PCDATA_DATA :( options {greedy=true;} : NL
330 | ~( '<' | '\n' | '\r' )
334 CDATABLOCK! :"<![CDATA[" p:CDATA_DATA "]]>"
335 { System.out.println("CDATABLOCK: "+p.getText()); }
338 protected CDATA_DATA :( options {greedy=false;} : NL
343 protected ATTR :name:NAME ( WS )? '=' ( WS )? value:STRING_NO_QUOTE
345 { attributes.addAttribute("", "", name.getText(), "CDATA",
349 { System.out.println("ATTRIBUTE: "+name.getText()+"="+value.getText()); }
352 protected STRING_NO_QUOTE :'"'! (~'"')* '"'!
353 | '\''! (~'\'')* '\''!
356 protected STRING :'"' (~'"')* '"'
360 protected NAME :( LETTER | '_' | ':') ( options {greedy=true;} : NAMECHAR )*
363 protected NAMECHAR :LETTER | DIGIT | '.' | '-' | '_' | ':'
366 protected DIGIT :'0'..'9'
369 protected LETTER :'a'..'z'
373 protected WS :( options {
381 protected ESC :( '\t'
386 protected NL :( options {
387 generateAmbigWarnings=false;