blob: fbab62fbba5fbf243892005b1e020b67b63d9299 [file] [log] [blame]
vinayakb38b7ca42012-03-05 05:44:15 +00001options {
2
3
4 STATIC = false;
5
6}
7
8PARSER_BEGIN(AdmLexer)
9
10package edu.uci.ics.asterix.adm.parser;
11
12import java.io.*;
13
14public class AdmLexer {
15
16 public static void main(String args[]) throws ParseException, TokenMgrError, IOException, FileNotFoundException {
17 File file = new File(args[0]);
18 Reader freader = new BufferedReader(new InputStreamReader
19 (new FileInputStream(file), "UTF-8"));
20 AdmLexer flexer = new AdmLexer(freader);
21 Token t = null;
22 do {
23 t = flexer.next();
24 System.out.println(AdmLexerConstants.tokenImage[t.kind]);
25 } while (t.kind != EOF);
26 freader.close();
27 }
28
29 public Token next() throws ParseException {
30 return getNextToken();
31 }
32
33 public String tokenKindToString(int tokenKind) {
34 return AdmLexerConstants.tokenImage[tokenKind];
35 }
36}
37
38PARSER_END(AdmLexer)
39
40<DEFAULT>
41TOKEN :
42{
43 <NULL_LITERAL : "null">
44}
45
46<DEFAULT>
47TOKEN :
48{
49 <TRUE_LITERAL : "true">
50}
51
52<DEFAULT>
53TOKEN :
54{
55 <FALSE_LITERAL : "false">
56}
57
58
59<DEFAULT>
60TOKEN :
61{
62 <INTEGER_LITERAL : ("-")? (<DIGIT>)+ >
63}
64
65
66<DEFAULT>
67TOKEN :
68{
69 <#DIGIT : ["0" - "9"]>
70}
71
72
73TOKEN:
74{
75 < DOUBLE_LITERAL:
76 ("-")? <INTEGER> ( "." <INTEGER> )? (<EXPONENT>)?
77 | ("-")? "." <INTEGER>
78 >
79 | < #EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ >
80 | <INTEGER : (<DIGIT>)+ >
81 | <FLOAT_LITERAL: <DOUBLE_LITERAL>("f"|"F")>
82 }
83
84<DEFAULT>
85TOKEN :
86{
87 <STRING_LITERAL : ("\"" (<EscapeQuot> | ~["\""])* "\"") >
88 |
89 < #EscapeQuot: "\\\"" >
90}
91
92<DEFAULT>
93TOKEN :
94{
95 <START_RECORD : "{">
96}
97
98<DEFAULT>
99TOKEN :
100{
101 <END_RECORD : "}">
102}
103
104<DEFAULT>
105TOKEN :
106{
107 <COMMA : ",">
108}
109
110<DEFAULT>
111TOKEN :
112{
113 <COLON : ":">
114}
115
116
117<DEFAULT>
118TOKEN :
119{
120 <START_ORDERED_LIST : "[">
121}
122
123<DEFAULT>
124TOKEN :
125{
126 <END_ORDERED_LIST : "]">
127}
128
129<DEFAULT>
130TOKEN :
131{
132 <START_UNORDERED_LIST : "{{">
133}
134
135<DEFAULT>
136TOKEN :
137{
138 <END_UNORDERED_LIST : "}}">
139}
140
141
142
143
144SKIP:
145{
146 " "
147| "\t"
148| "\r"
149| "\n"
150}