Project

General

Profile

1
/*@bgen(jjtree) Generated By:JJTree: Do not edit this line. ft.jj */
2
/*@egen*//**
3
* JJTree file
4
*  NODE_PACKAGE = "eu.dnetlib.data.collective.transformation.rulelanguage.node";
5
*/
6

    
7
options {
8
  STATIC=false;
9
               
10
                 
11
  JDK_VERSION = "1.6";
12
}
13

    
14
PARSER_BEGIN(FtScript) 
15

    
16
package eu.dnetlib.data.collective.transformation.rulelanguage.parser;
17
import eu.dnetlib.data.collective.transformation.rulelanguage.Rules;
18
public class FtScript/*@bgen(jjtree)*/implements FtScriptTreeConstants/*@egen*/ {/*@bgen(jjtree)*/
19
  protected JJTFtScriptState jjtree = new JJTFtScriptState();
20

    
21
/*@egen*/
22
}
23

    
24
PARSER_END(FtScript)
25

    
26
SKIP :
27
{
28
  " "
29
| "\t"
30
| "\n"
31
| "\r"
32
| <"//" (~["\n","\r"])* ("\n"|"\r"|"\r\n")>
33
| <"/*" (~["*"])* "*" (~["/"] (~["*"])* "*")* "/">
34
}
35

    
36
MORE :
37
{
38
  "//" : IN_SINGLE_LINE_COMMENT
39
}
40

    
41
< IN_SINGLE_LINE_COMMENT >
42
SPECIAL_TOKEN :
43
{
44
  <SINGLE_LINE_COMMENT: "\n" | "\r" | "\r\n" > : DEFAULT
45
}
46

    
47
/* RESERVED WORDS AND LITERALS */
48
// KEYWORDS
49
TOKEN : {	< IMPORT:            "import" > }
50
TOKEN : {	< TRANS:             "trans" > }
51
TOKEN : {	< IF:                "if" > }
52
TOKEN : {	< ELSE:              "else" > }
53
TOKEN : {	< END:               "end" > }
54
TOKEN : {   < EXTRACT:           "Extract" > }
55
TOKEN : {   < IDENTIFIEREXTRACT: "identifierExtract" > }
56
TOKEN : {	< CONVERT:           "Convert" > }
57
TOKEN : {	< REGEXPR:           "RegExpr" > }
58
TOKEN : {	< GETVALUE:	         "getValue" > }
59
TOKEN : {   < COPY:              "copy" > }
60
TOKEN : {   < DECLARE_NAMESPACE: "declare_ns" > }
61
TOKEN : {   < DECLARE_SCRIPT:    "declare_script" > }
62
TOKEN : {   < DECLARE_SUBSCRIPT: "declare_subscript" > }
63
TOKEN : {   < PREPROCESS:        "preprocess" > }
64
TOKEN : {   < SET:               "set" > }
65
TOKEN : {   < SKIPRECORD:        "skipRecord" > }
66
TOKEN : {   < SPLIT:             "split" > }
67
TOKEN : {   < STATIC:            "static" > }
68
TOKEN : {   < XPATH_SCHEME:      "xpath:" > }
69
TOKEN : {   < APPLY:             "apply" > }
70
TOKEN : {   < EMPTY:             "empty" > }
71
TOKEN : {   < DBLOOKUP:          "dblookup" > }
72
TOKEN : {   < LOOKUP:            "lookup" > }
73
TOKEN : {   < CONCAT:            "concat" > }
74

    
75
// SPEC. CHARS
76
TOKEN : { < SEMICOLON: ";" > }
77
TOKEN : { < RBRACKET: "]" > }
78
TOKEN : { < LBRACE: "{" > }
79
TOKEN : { < RBRACE: "}" > }
80
TOKEN : { < COMMA: "," > }
81
TOKEN : { < RPAREN: ")" > }
82
TOKEN : { < QUOTE: "'" > }
83

    
84
TOKEN :
85
{
86

    
87
  < EQUAL:   "="      > |
88
  < NOTEQUAL:   "!="      > |
89
  < GT:    " &gt; "  | ">"    > |
90
  < LT:    " &lt; "  | "<"    > |
91
  < GTE:   " &gt;= " | ">="    > |
92
  < LTE:   " &lt;= " | "<="    > |
93
  < PLUS:   "+"      > |
94
  < VBAR:   "|"      > |
95
//  < SLASH_SLASH:  "//"      > |
96
  < SLASH:   "/"      > |
97

    
98
  < DOT_DOT:      ".."      > |
99
  //< DOT:     "."      > |
100

    
101
  < AT:     "@"      > |
102

    
103
  < LPAREN: "(" > |
104
  < LBRACKET: "[" > |
105
  < DOLLAR_QNAME: "$" <IDENTIFIER>     >  |
106
  < PERCENT_QNAME: "%" < IDENTIFIER > >
107

    
108
}
109

    
110
TOKEN :
111
{
112
  < XPATH:
113
     < XPATH_SCHEME > <QUOTED_STRING >
114
  > 
115
}
116

    
117
TOKEN :
118
{
119
  < JOBCONST:
120
     < JOBCONST_PREFIX > <LETTER_OR_DIGIT> (<LETTER_OR_DIGIT>)* >
121
|  < #JOBCONST_PREFIX: "$job." >
122
}
123

    
124
TOKEN:
125
{
126
  < QUOTED_STRING: "\""
127
  (~["\""]
128
  )+ "\"" >
129
}
130

    
131
TOKEN:
132
{
133
  < SINGLE_QUOTE: "'"
134
  (~["'"]
135
  )+ "'" >
136
}
137

    
138
TOKEN : /* STRING LITERALS*/
139
{
140
  < CHARACTER_LITERAL:
141
      "'"
142
      (   (~["'","\\","\n","\r"])
143
        | ("\\"
144
            ( ["n","t","b","r","f","\\","'","\""]
145
            | ["0"-"7"] ( ["0"-"7"] )?
146
            | ["0"-"3"] ["0"-"7"] ["0"-"7"]
147
            )
148
          )
149
      )
150
      "'"
151
  >
152
| 
153
  < STRING_LITERAL:
154
    "\""
155
    ( (~["\"", "\\", "\n", "\r"])
156
      | ("\\"
157
           ( ["n", "t", "b", "r", "f", "\\", "'", "\""]
158
           | ["0"-"7"] ( ["0"-"7"] )?
159
           | ["0"-"3"] ["0"-"7"] ["0"-"7"]
160
           )
161
        )
162
    )*
163
    "\""
164
  >
165
}
166

    
167

    
168
TOKEN :
169
{
170
  < URI:
171
    < IDENTIFIER > "://" <IDENTIFIER >
172
    ( "/" < IDENTIFIER > )*  ( "/" )?
173
  >
174
}
175

    
176

    
177

    
178
TOKEN : /* IDENTIFIERS */
179
{
180
  < IDENTIFIER:
181
   ( < AT >|<LETTER_OR_DIGIT>) (<LETTER_OR_DIGIT>|<MINUS>|< DOT >|< COLON >|< AT >)* >
182
|  < #LETTER_OR_DIGIT: ["_","a"-"z","A"-"Z","0"-"9"] >
183
|  < #MINUS: "-" >
184
|  < #DOT: "." >
185
|  < #COLON: ":" >
186
//|  < #AT: "@" >
187
}
188

    
189

    
190

    
191
ASTStart Start() :{/*@bgen(jjtree) Start */
192
  ASTStart jjtn000 = new ASTStart(JJTSTART);
193
  boolean jjtc000 = true;
194
  jjtree.openNodeScope(jjtn000);
195
/*@egen*/}
196
{/*@bgen(jjtree) Start */
197
  try {
198
/*@egen*/	
199
  (script())/*@bgen(jjtree)*/
200
  {
201
    jjtree.closeNodeScope(jjtn000, true);
202
    jjtc000 = false;
203
  }
204
/*@egen*/
205
  { return jjtn000; }/*@bgen(jjtree)*/
206
  } catch (Throwable jjte000) {
207
    if (jjtc000) {
208
      jjtree.clearNodeScope(jjtn000);
209
      jjtc000 = false;
210
    } else {
211
      jjtree.popNode();
212
    }
213
    if (jjte000 instanceof RuntimeException) {
214
      throw (RuntimeException)jjte000;
215
    }
216
    if (jjte000 instanceof ParseException) {
217
      throw (ParseException)jjte000;
218
    }
219
    throw (Error)jjte000;
220
  } finally {
221
    if (jjtc000) {
222
      jjtree.closeNodeScope(jjtn000, true);
223
    }
224
  }
225
/*@egen*/
226
}
227

    
228
/**
229
 * id = value
230
 */
231
void assign(Rules r)           : {/*@bgen(jjtree) MyAssign */
232
                                  ASTMyAssign jjtn000 = new ASTMyAssign(JJTMYASSIGN);
233
                                  boolean jjtc000 = true;
234
                                  jjtree.openNodeScope(jjtn000);
235
/*@egen*/String value = ""; Token t;}
236
{/*@bgen(jjtree) MyAssign */
237
                                                          try {
238
/*@egen*/
239
	                                                  {jjtn000.setRule(r);}
240
         (t = inputField()/*@bgen(jjtree)*/
241
                                                      {
242
                                                        jjtree.closeNodeScope(jjtn000, true);
243
                                                        jjtc000 = false;
244
                                                      }
245
/*@egen*/                            {jjtn000.setFieldExpression(t.image);}        
246
         |value = quotedString()/*@bgen(jjtree)*/
247
                                                      {
248
                                                        jjtree.closeNodeScope(jjtn000, true);
249
                                                        jjtc000 = false;
250
                                                      }
251
/*@egen*/                      {jjtn000.setAttribute(value);}
252
         )/*@bgen(jjtree)*/
253
                                                          } catch (Throwable jjte000) {
254
                                                            if (jjtc000) {
255
                                                              jjtree.clearNodeScope(jjtn000);
256
                                                              jjtc000 = false;
257
                                                            } else {
258
                                                              jjtree.popNode();
259
                                                            }
260
                                                            if (jjte000 instanceof RuntimeException) {
261
                                                              throw (RuntimeException)jjte000;
262
                                                            }
263
                                                            if (jjte000 instanceof ParseException) {
264
                                                              throw (ParseException)jjte000;
265
                                                            }
266
                                                            throw (Error)jjte000;
267
                                                          } finally {
268
                                                            if (jjtc000) {
269
                                                              jjtree.closeNodeScope(jjtn000, true);
270
                                                            }
271
                                                          }
272
/*@egen*/
273
}
274

    
275
void attrib_list()       : {}
276
{
277
	<LBRACKET>
278
	  (attribute())*
279
	<RBRACKET>
280
}
281

    
282

    
283
void attribute()              : {/*@bgen(jjtree) MyAttribute */
284
                                 ASTMyAttribute jjtn000 = new ASTMyAttribute(JJTMYATTRIBUTE);
285
                                 boolean jjtc000 = true;
286
                                 jjtree.openNodeScope(jjtn000);
287
/*@egen*/String value; Token t=null;}
288
{/*@bgen(jjtree) MyAttribute */
289
        try {
290
/*@egen*/
291
	(value = identifier() { jjtn000.setAttributeValue(value);}
292
	|t = inputField()
293
	{ value = t.image;
294
	  jjtn000.setAttributeInputField(value);
295
	}
296
	)
297
	[<COMMA>]/*@bgen(jjtree)*/
298
        } catch (Throwable jjte000) {
299
          if (jjtc000) {
300
            jjtree.clearNodeScope(jjtn000);
301
            jjtc000 = false;
302
          } else {
303
            jjtree.popNode();
304
          }
305
          if (jjte000 instanceof RuntimeException) {
306
            throw (RuntimeException)jjte000;
307
          }
308
          if (jjte000 instanceof ParseException) {
309
            throw (ParseException)jjte000;
310
          }
311
          throw (Error)jjte000;
312
        } finally {
313
          if (jjtc000) {
314
            jjtree.closeNodeScope(jjtn000, true);
315
          }
316
        }
317
/*@egen*/
318
	
319
}
320

    
321
/**
322
 *  a conditional Rule, which contains the condition, the Rule on which the condition holds and the alternative rule
323
 */
324
void conditionalStmt()              : {/*@bgen(jjtree) MyCondition */
325
                                       ASTMyCondition jjtn000 = new ASTMyCondition(JJTMYCONDITION);
326
                                       boolean jjtc000 = true;
327
                                       jjtree.openNodeScope(jjtn000);
328
/*@egen*/Rules r1 = new Rules(); Rules r2 = new Rules(); Token cond; Token apply;}
329
{/*@bgen(jjtree) MyCondition */
330
  try {
331
/*@egen*/
332
  [< APPLY > apply = inputField()
333
  {
334
    jjtn000.setApplyExpression(apply.image);
335
  } ]
336
   < IF > cond = inputField() { jjtn000.setConditionalExpression(cond.image); jjtn000.setPrimaryRule(r1); jjtn000.setSecondaryRule(r2); }
337
    rule(r1)
338
  < ELSE >
339
    rule(r2)/*@bgen(jjtree)*/
340
  } catch (Throwable jjte000) {
341
    if (jjtc000) {
342
      jjtree.clearNodeScope(jjtn000);
343
      jjtc000 = false;
344
    } else {
345
      jjtree.popNode();
346
    }
347
    if (jjte000 instanceof RuntimeException) {
348
      throw (RuntimeException)jjte000;
349
    }
350
    if (jjte000 instanceof ParseException) {
351
      throw (ParseException)jjte000;
352
    }
353
    throw (Error)jjte000;
354
  } finally {
355
    if (jjtc000) {
356
      jjtree.closeNodeScope(jjtn000, true);
357
    }
358
  }
359
/*@egen*/
360
}
361

    
362
void empty(Rules r)          : {/*@bgen(jjtree) MyEmpty */
363
  ASTMyEmpty jjtn000 = new ASTMyEmpty(JJTMYEMPTY);
364
  boolean jjtc000 = true;
365
  jjtree.openNodeScope(jjtn000);
366
/*@egen*/}
367
{/*@bgen(jjtree) MyEmpty */
368
                                             try {
369
/*@egen*/
370
                                             {jjtn000.setRule(r);}
371
        < EMPTY >/*@bgen(jjtree)*/
372
                                             {
373
                                               jjtree.closeNodeScope(jjtn000, true);
374
                                               jjtc000 = false;
375
                                             }
376
/*@egen*/                            {jjtn000.setEmpty(true);}/*@bgen(jjtree)*/
377
                                             } finally {
378
                                               if (jjtc000) {
379
                                                 jjtree.closeNodeScope(jjtn000, true);
380
                                               }
381
                                             }
382
/*@egen*/        
383
}
384

    
385
String identifier()       : {Token t;}
386
{
387
  t = <IDENTIFIER> {return t.image;}
388
}
389

    
390
void importDeclaration()           :
391
{/*@bgen(jjtree) MyImport */
392
 ASTMyImport jjtn000 = new ASTMyImport(JJTMYIMPORT);
393
 boolean jjtc000 = true;
394
 jjtree.openNodeScope(jjtn000);
395
/*@egen*/String scriptName;}
396
{/*@bgen(jjtree) MyImport */
397
  try {
398
/*@egen*/
399
  <IMPORT> <LPAREN> scriptName = identifier() <RPAREN> ";"/*@bgen(jjtree)*/
400
                                                           {
401
                                                             jjtree.closeNodeScope(jjtn000, true);
402
                                                             jjtc000 = false;
403
                                                           }
404
/*@egen*/ { jjtn000.setScriptName(scriptName); }/*@bgen(jjtree)*/
405
  } catch (Throwable jjte000) {
406
    if (jjtc000) {
407
      jjtree.clearNodeScope(jjtn000);
408
      jjtc000 = false;
409
    } else {
410
      jjtree.popNode();
411
    }
412
    if (jjte000 instanceof RuntimeException) {
413
      throw (RuntimeException)jjte000;
414
    }
415
    if (jjte000 instanceof ParseException) {
416
      throw (ParseException)jjte000;
417
    }
418
    throw (Error)jjte000;
419
  } finally {
420
    if (jjtc000) {
421
      jjtree.closeNodeScope(jjtn000, true);
422
    }
423
  }
424
/*@egen*/
425
}
426

    
427
Token anyExpression()       : { Token t; }
428
{
429
  t = < IDENTIFIER >
430
  {
431
    return t;
432
  }
433
}
434

    
435
Token inputField()       :{ Token t; }
436
{
437
  t =  < XPATH >
438
  {
439
    return t;
440
  }
441
  | t = < JOBCONST >
442
  {
443
    return t;
444
  }
445
  | t = < DOLLAR_QNAME >
446
  {
447
    return t;
448
  }
449
}
450

    
451

    
452
/*
453
 * becomes obsolete
454
 */
455
String key()       : {String key;}
456
{
457
   key = identifier()                     
458
   <EQUAL>
459
   {return key;}
460
}
461

    
462
void literal()       :
463
{}
464
{
465
  < CHARACTER_LITERAL > | < STRING_LITERAL >
466
}
467

    
468
void nsDeclaration()       :
469
{/*@bgen(jjtree) MyNs */
470
 ASTMyNs jjtn000 = new ASTMyNs(JJTMYNS);
471
 boolean jjtc000 = true;
472
 jjtree.openNodeScope(jjtn000);
473
/*@egen*/String nsPrefix; String nsUri;}
474
{/*@bgen(jjtree) MyNs */
475
        try {
476
/*@egen*/
477
	< DECLARE_NAMESPACE > nsPrefix = identifier() < EQUAL > nsUri = quotedString() < SEMICOLON >/*@bgen(jjtree)*/
478
        {
479
          jjtree.closeNodeScope(jjtn000, true);
480
          jjtc000 = false;
481
        }
482
/*@egen*/
483
	{
484
	  jjtn000.setNsDeclaration(nsPrefix, nsUri);
485
	}/*@bgen(jjtree)*/
486
        } catch (Throwable jjte000) {
487
          if (jjtc000) {
488
            jjtree.clearNodeScope(jjtn000);
489
            jjtc000 = false;
490
          } else {
491
            jjtree.popNode();
492
          }
493
          if (jjte000 instanceof RuntimeException) {
494
            throw (RuntimeException)jjte000;
495
          }
496
          if (jjte000 instanceof ParseException) {
497
            throw (ParseException)jjte000;
498
          }
499
          throw (Error)jjte000;
500
        } finally {
501
          if (jjtc000) {
502
            jjtree.closeNodeScope(jjtn000, true);
503
          }
504
        }
505
/*@egen*/
506
}
507

    
508
void preprocess()               :{/*@bgen(jjtree) MyPreprocess */
509
                                  ASTMyPreprocess jjtn000 = new ASTMyPreprocess(JJTMYPREPROCESS);
510
                                  boolean jjtc000 = true;
511
                                  jjtree.openNodeScope(jjtn000);
512
/*@egen*/String preprocessId;}
513
{/*@bgen(jjtree) MyPreprocess */
514
  try {
515
/*@egen*/
516
  < PREPROCESS >
517
   preprocessId = identifier() < EQUAL >
518
   < DBLOOKUP >
519
    < LPAREN >                     { String sqlExpr; }
520
      sqlExpr = quotedString()
521
    < RPAREN >                     { jjtn000.preprocess(preprocessId, "dblookup", sqlExpr); }
522
  < SEMICOLON >/*@bgen(jjtree)*/
523
  } catch (Throwable jjte000) {
524
    if (jjtc000) {
525
      jjtree.clearNodeScope(jjtn000);
526
      jjtc000 = false;
527
    } else {
528
      jjtree.popNode();
529
    }
530
    if (jjte000 instanceof RuntimeException) {
531
      throw (RuntimeException)jjte000;
532
    }
533
    if (jjte000 instanceof ParseException) {
534
      throw (ParseException)jjte000;
535
    }
536
    throw (Error)jjte000;
537
  } finally {
538
    if (jjtc000) {
539
      jjtree.closeNodeScope(jjtn000, true);
540
    }
541
  }
542
/*@egen*/
543
}
544

    
545
void set(Rules r)        : {/*@bgen(jjtree) MySet */
546
                            ASTMySet jjtn000 = new ASTMySet(JJTMYSET);
547
                            boolean jjtc000 = true;
548
                            jjtree.openNodeScope(jjtn000);
549
/*@egen*/Token expr; String value = "";}
550
{/*@bgen(jjtree) MySet */
551
  try {
552
/*@egen*/
553
  {    jjtn000.setRule(r);  }
554

    
555
  < SET >
556
        < LPAREN >
557
        (
558
          
559
        expr = inputField()        { jjtn000.setValueExpression(expr.image); }
560
      | value = quotedString()     { jjtn000.setAttribute(value); }
561
        )
562
        (
563
          < COMMA >
564
		     {
565
		       r = new Rules();
566
		     }
567
		     rule(r)
568
		     {
569
			   jjtn000.addAttributeRule(r);  
570
			 }
571
          
572
        )*
573
        < RPAREN >/*@bgen(jjtree)*/
574
  } catch (Throwable jjte000) {
575
    if (jjtc000) {
576
      jjtree.clearNodeScope(jjtn000);
577
      jjtc000 = false;
578
    } else {
579
      jjtree.popNode();
580
    }
581
    if (jjte000 instanceof RuntimeException) {
582
      throw (RuntimeException)jjte000;
583
    }
584
    if (jjte000 instanceof ParseException) {
585
      throw (ParseException)jjte000;
586
    }
587
    throw (Error)jjte000;
588
  } finally {
589
    if (jjtc000) {
590
      jjtree.closeNodeScope(jjtn000, true);
591
    }
592
  }
593
/*@egen*/
594
}
595

    
596
void copy(Rules r)         : {/*@bgen(jjtree) MyCopy */
597
  ASTMyCopy jjtn000 = new ASTMyCopy(JJTMYCOPY);
598
  boolean jjtc000 = true;
599
  jjtree.openNodeScope(jjtn000);
600
/*@egen*/}
601
{/*@bgen(jjtree) MyCopy */
602
  try {
603
/*@egen*/
604
  {    jjtn000.setRule(r);  }
605
  	   < COPY >
606
	      < LPAREN >         	        { String templateMatchExpression; String applyTemplateSelectExpression; String copySelectExpression; }
607
	       templateMatchExpression = quotedString()
608
	       < COMMA >
609
	       applyTemplateSelectExpression = quotedString()
610
	       <  COMMA >
611
	       copySelectExpression = quotedString()
612
	      < RPAREN >/*@bgen(jjtree)*/
613
                                                {
614
                                                  jjtree.closeNodeScope(jjtn000, true);
615
                                                  jjtc000 = false;
616
                                                }
617
/*@egen*/	                { jjtn000.copy(templateMatchExpression, applyTemplateSelectExpression, copySelectExpression); }/*@bgen(jjtree)*/
618
  } catch (Throwable jjte000) {
619
    if (jjtc000) {
620
      jjtree.clearNodeScope(jjtn000);
621
      jjtc000 = false;
622
    } else {
623
      jjtree.popNode();
624
    }
625
    if (jjte000 instanceof RuntimeException) {
626
      throw (RuntimeException)jjte000;
627
    }
628
    if (jjte000 instanceof ParseException) {
629
      throw (ParseException)jjte000;
630
    }
631
    throw (Error)jjte000;
632
  } finally {
633
    if (jjtc000) {
634
      jjtree.closeNodeScope(jjtn000, true);
635
    }
636
  }
637
/*@egen*/
638

    
639
}
640

    
641
void op(Rules r)       : {/*@bgen(jjtree) MyOp */
642
                          ASTMyOp jjtn000 = new ASTMyOp(JJTMYOP);
643
                          boolean jjtc000 = true;
644
                          jjtree.openNodeScope(jjtn000);
645
/*@egen*/String functionName = ""; Token expr; Token expr2; Token vocab; String defaultPattern = ""; String function = ""; String elementName = ""; String regExpr; Token feature;}
646
{/*@bgen(jjtree) MyOp */
647
                                            try {
648
/*@egen*/
649
	                                    {jjtn000.setRule(r);}
650
	( (<GETVALUE> 
651
	 <LPAREN>
652
	   functionName = identifier() <COMMA> attrib_list()
653
	 <RPAREN>/*@bgen(jjtree)*/
654
                                            {
655
                                              jjtree.closeNodeScope(jjtn000, true);
656
                                              jjtc000 = false;
657
                                            }
658
/*@egen*/                           {jjtn000.getValue(functionName);}
659
	 )	 
660
	| (<CONVERT> 
661
	  <LPAREN>
662
	    expr = inputField()
663
	    <COMMA>
664
	    vocab = <IDENTIFIER>
665
	    (
666
	      <COMMA>
667
	      defaultPattern = quotedString()
668
	      <COMMA>
669
	      function = quotedString()
670
	    )*
671
	  <RPAREN>/*@bgen(jjtree)*/
672
                                            {
673
                                              jjtree.closeNodeScope(jjtn000, true);
674
                                              jjtc000 = false;
675
                                            }
676
/*@egen*/                          {jjtn000.convert(expr.image, vocab.image, defaultPattern, function);} 
677
	  )
678
	| (< EXTRACT >
679
	   < LPAREN >
680
	    feature = < IDENTIFIER >
681
	   < RPAREN >/*@bgen(jjtree)*/
682
                                            {
683
                                              jjtree.closeNodeScope(jjtn000, true);
684
                                              jjtc000 = false;
685
                                            }
686
/*@egen*/                       {jjtn000.extract(feature.image); }
687
	  )
688
	| (<REGEXPR>
689
		<LPAREN>
690
		expr = inputField()
691
		<COMMA>
692
		expr2 = inputField()
693
		<COMMA>
694
		regExpr = quotedString()
695
		<RPAREN>/*@bgen(jjtree)*/
696
                                                {
697
                                                  jjtree.closeNodeScope(jjtn000, true);
698
                                                  jjtc000 = false;
699
                                                }
700
/*@egen*/                        {jjtn000.regExpr(expr.image, expr2.image, regExpr);}
701
	  )
702
	| (<SPLIT>
703
	    < LPAREN >
704
	     expr = inputField()
705
	     < COMMA >
706
	     elementName = quotedString()
707
	     < COMMA >
708
	     regExpr = quotedString()
709
        < RPAREN >/*@bgen(jjtree)*/
710
                                        {
711
                                          jjtree.closeNodeScope(jjtn000, true);
712
                                          jjtc000 = false;
713
                                        }
714
/*@egen*/                      {jjtn000.split(expr.image, elementName, regExpr);}
715
	  )
716
	| ( < LOOKUP >                    	{ String propertyKey; }
717
         < LPAREN >                     
718
           expr = inputField()
719
           < COMMA >
720
           propertyKey = quotedString()
721
         < RPAREN >/*@bgen(jjtree)*/
722
                                        {
723
                                          jjtree.closeNodeScope(jjtn000, true);
724
                                          jjtc000 = false;
725
                                        }
726
/*@egen*/                     { jjtn000.lookup(expr.image, propertyKey); }
727
	  )
728
	| ( < IDENTIFIEREXTRACT >       	{ String xpathExprJsonString; Token xpathExprInputSource; }
729
	      < LPAREN > 
730
            // "{//abc, //def }" ?json list of xpath-expr
731
            // xpath-expr of input source
732
            // regExpr          
733
	        xpathExprJsonString = singleQuotedString()
734
	        < COMMA >
735
	        xpathExprInputSource = inputField()
736
	        < COMMA >
737
	        regExpr = singleQuotedString()            
738
	      < RPAREN >/*@bgen(jjtree)*/
739
                                                {
740
                                                  jjtree.closeNodeScope(jjtn000, true);
741
                                                  jjtc000 = false;
742
                                                }
743
/*@egen*/	                { jjtn000.identifierExtract(xpathExprJsonString, xpathExprInputSource.image, regExpr); }
744
	  )
745
	| ( < CONCAT >                    	{ jjtn000.concat();	}
746
	      < LPAREN >	                { String v; Token t; }
747
			( v = quotedString() { jjtn000.addConcat(v); }  | t = < DOLLAR_QNAME >			{ jjtn000.addConcat(t.image); }
748
			)
749
			(
750
			  < COMMA >
751
              (
752
                v = quotedString() { jjtn000.addConcat(v); } | t = < DOLLAR_QNAME >			{ jjtn000.addConcat(t.image); }
753
              )
754
			)*
755
	      < RPAREN >
756
	  )
757
	| (< SKIPRECORD >	                {jjtn000.skipRecord();}
758
	   < LPAREN >
759
	   < RPAREN >
760
	  )
761
	)/*@bgen(jjtree)*/
762
                                            } catch (Throwable jjte000) {
763
                                              if (jjtc000) {
764
                                                jjtree.clearNodeScope(jjtn000);
765
                                                jjtc000 = false;
766
                                              } else {
767
                                                jjtree.popNode();
768
                                              }
769
                                              if (jjte000 instanceof RuntimeException) {
770
                                                throw (RuntimeException)jjte000;
771
                                              }
772
                                              if (jjte000 instanceof ParseException) {
773
                                                throw (ParseException)jjte000;
774
                                              }
775
                                              throw (Error)jjte000;
776
                                            } finally {
777
                                              if (jjtc000) {
778
                                                jjtree.closeNodeScope(jjtn000, true);
779
                                              }
780
                                            }
781
/*@egen*/
782
}
783

    
784
String leftExprOutputField()       :{ String leftExpr; }
785
{
786
  leftExpr = identifier() < EQUAL > { return leftExpr; }
787
}
788

    
789
String leftExprVar()       :{ String leftExpr; }
790
{
791
  leftExpr = variable() <  EQUAL >  { return leftExpr; }
792
}
793

    
794
String leftExprTemplate()       :{ String leftExpr; }
795
{
796
  leftExpr = template() < EQUAL >  { return leftExpr;  }
797
}
798

    
799
String singleQuotedString()       : { Token t;}
800
{
801
  t =
802
    < SINGLE_QUOTE >
803
    { return t.image; }
804
}
805

    
806
String quotedString()       : {Token t;}
807
{
808
  t =
809
    < QUOTED_STRING >
810
     {return t.image;}
811
}
812

    
813
void rule(Rules r)       : { String ruleDecl; String leftExpr;}
814
{
815
	[  ruleDecl = ruleDecl() { r.setRuleDeclaration(ruleDecl);	} ]
816
	 (
817
	   leftExpr = leftExprOutputField()
818
	   {
819
	     String[] fieldArray = leftExpr.split("@");
820
	     r.setTargetField(fieldArray[0]);
821
	     if (fieldArray.length > 1)
822
	     {
823
	       r.setAttribute(fieldArray[1]);
824
	     }
825
	   }
826
	 | leftExpr = leftExprVar()	 {	r.setVariable(leftExpr); }
827
	 | leftExpr = leftExprTemplate()	 { r.setTemplate(leftExpr);	 }
828
	 )
829
     (
830
 	   LOOKAHEAD(2)
831
       
832
       assign(r)
833
     | op(r)
834
     | set(r)
835
     | copy(r)
836
     | empty(r)
837
     ) < SEMICOLON >  
838
}
839

    
840
String ruleDecl()       : {Token t;}
841
{
842
  (
843
    t = < STATIC >  
844
  )
845
  { return t.image;
846
  }
847
}
848

    
849
void script()       :{}
850
{
851
	   scriptDeclaration()
852
	  [ importDeclaration() ]
853
	  (
854
	     nsDeclaration()
855
	   )*
856
	   (
857
	     preprocess()
858
	   )*
859
	  ( stmt() | conditionalStmt() )*
860
	  ( <END> <EOF> )
861
}
862

    
863
void scriptDeclaration()           :
864
{/*@bgen(jjtree) MyScript */
865
 ASTMyScript jjtn000 = new ASTMyScript(JJTMYSCRIPT);
866
 boolean jjtc000 = true;
867
 jjtree.openNodeScope(jjtn000);
868
/*@egen*/String scriptName; ASTMyScript.SCRIPTTYPE scriptType;}
869
{/*@bgen(jjtree) MyScript */
870
        try {
871
/*@egen*/
872

    
873
  	(
874
  	  < DECLARE_SCRIPT >
875
  	  {
876
  	    jjtn000.setScriptType(ASTMyScript.SCRIPTTYPE.MAINSCRIPT);
877
  	  }
878
  	  | < DECLARE_SUBSCRIPT >
879
  	  {
880
  	    jjtn000.setScriptType(ASTMyScript.SCRIPTTYPE.SUBSCRIPT);  	    
881
  	  }
882
  	) scriptName = quotedString() < SEMICOLON >/*@bgen(jjtree)*/
883
        {
884
          jjtree.closeNodeScope(jjtn000, true);
885
          jjtc000 = false;
886
        }
887
/*@egen*/
888
  	{
889
  	  jjtn000.setScript(scriptName);
890
  	}/*@bgen(jjtree)*/
891
        } catch (Throwable jjte000) {
892
          if (jjtc000) {
893
            jjtree.clearNodeScope(jjtn000);
894
            jjtc000 = false;
895
          } else {
896
            jjtree.popNode();
897
          }
898
          if (jjte000 instanceof RuntimeException) {
899
            throw (RuntimeException)jjte000;
900
          }
901
          if (jjte000 instanceof ParseException) {
902
            throw (ParseException)jjte000;
903
          }
904
          throw (Error)jjte000;
905
        } finally {
906
          if (jjtc000) {
907
            jjtree.closeNodeScope(jjtn000, true);
908
          }
909
        }
910
/*@egen*/
911
}
912

    
913
void stmt()       :{Rules r = new Rules();}
914
{
915
  rule(r)
916
}
917

    
918
String string()       : {Token t;}
919
{
920
	t = <STRING_LITERAL> {return t.image.substring(1, t.image.length()-1);}
921
}
922

    
923
String variable()       : { Token t; }
924
{
925
  t = < DOLLAR_QNAME >  { return t.image;  }
926
}
927

    
928
String template()       : { Token t; }
929
{
930
  t = < PERCENT_QNAME >  { return t.image;  }
931
}
(26-26/27)