PageRenderTime 496ms CodeModel.GetById 312ms app.highlight 3ms RepoModel.GetById 118ms app.codeStats 0ms

/scanner.l

http://github.com/fizx/parsley
LEX | 221 lines | 211 code | 10 blank | 0 comment | 0 complexity | dd62b783f80e95c4294381fb2772d105 MD5 | raw file
  1%{
  2#include <stdio.h>
  3#include "parser.h"
  4
  5YY_BUFFER_STATE mybuffer;
  6
  7void prepare_parse(char* msg) {
  8  mybuffer = yy_scan_string(msg);  
  9}
 10
 11void cleanup_parse() {
 12  yy_delete_buffer(mybuffer);  
 13}
 14 
 15%}
 16
 17%option stack
 18%x DSTR
 19%x SSTR
 20
 21NUMBER      [0-9]+
 22S		        [\t\r \n]+
 23AT          "@"
 24LPAREN      "("
 25RPAREN      ")"
 26PIPE        "|"
 27LT          "<"
 28SLASH       "/"
 29DBLSLASH     "//"
 30BANG        "!"
 31COLON       ":"
 32DBLCOLON		"::"
 33QUERY       "?"
 34HASH        "#"
 35COMMA       {S}?","
 36DOT         "."
 37DBLDOT       ".."
 38GT          {S}?">"
 39LBRA        "["
 40RBRA        "]"
 41TILDE       {S}?"~"
 42SPLAT       "*"
 43PLUS        {S}?"+"
 44DASH				"-"
 45EQ          "="
 46LTE         "<="
 47GTE         ">="
 48DOLLAR      "$"
 49STRING			(['][^']*['])|(["][^"]*["])
 50
 51BSLASHLIT   \\(.|\n)
 52OTHER       (.|\n)
 53
 54XANCESTOR 		"ancestor"
 55XANCESTORSELF	"ancestor-or-self"
 56XATTR					"attribute"
 57XCHILD				"child"
 58XDESC					"descendant"
 59XDESCSELF			"descendant-or-self"
 60XFOLLOW				"following"
 61XFOLLOWSIB		"following-sibling"
 62XNS						"namespace"
 63XPARENT				"parent"
 64XPRE					"preceding"
 65XPRESIB				"preceding-sibling"
 66XSELF					"self"
 67XOR						"or"
 68XAND					"and"
 69XDIV					"div"
 70XMOD					"mod"
 71XCOMMENT			"comment"
 72XTEXT 				"text" 
 73XPI					 	"processing-instruction"
 74XNODE					"node"
 75CXEQUATION    [0-9]+n
 76CXOPHE        "|="
 77CXOPNE        "!="
 78CXOPSTARTEQ   "^="
 79CXOPENDEQ     "$="
 80CXOPCONTAINS  "*="
 81CXOPCONTAINS2 "~="
 82CXFIRST       ":first"
 83CXLAST        ":last"
 84CXNOT         ":not"
 85CXEVEN        ":even"
 86CXODD         ":odd"
 87CXEQ          ":eq"
 88CXGT          ":gt"
 89CXLT          ":lt"
 90CXCONTENT     ":content"
 91CXHEADER      ":header"
 92CXCONTAINS    ":contains"
 93CXEMPTY       ":empty"
 94CXHAS         ":has"
 95CXPARENT      ":parent"
 96CXNTHCH       ":nth-child"
 97CXNTHLASTCH   ":nth-last-child"
 98CXNTHTYPE 	  ":nth-of-type"
 99CXNTHLASTTYPE ":nth-last-of-type"
100CXFIRSTCH     ":first-child"
101CXLASTCH      ":last-child"
102CXFIRSTTYPE   ":first-of-type"
103CXLASTTYPE    ":last-of-type"
104CXONLYCH      ":only-child"
105CXONLYTYPE    ":only-of-type"
106CXINPUT       ":input"
107CXTEXT        ":text"
108CXPASSWORD    ":password"
109CXRADIO       ":radio"
110CXCHECKBOX    ":checkbox"
111CXSUBMIT      ":submit"
112CXIMAGE       ":image"
113CXRESET       ":reset"
114CXBUTTON      ":button"
115CXFILE        ":file"
116CXENABLED     ":enabled"
117CXDISABLED    ":disabled"
118CXCHECKED     ":checked"
119CXSELECTED    ":selected"
120
121NAME        [a-zA-Z_][a-zA-Z0-9\-_]*
122
123%%
124{NUMBER} yylval.string = strdup(yytext); return NUMBER;
125{S} yylval.string = strdup(yytext); return S;
126{AT} yylval.string = strdup(yytext); return AT;
127{LPAREN} yylval.string = strdup(yytext); return LPAREN;
128{RPAREN} yylval.string = strdup(yytext); return RPAREN;
129{PIPE} yylval.string = strdup(yytext); return PIPE;
130{LT} yylval.string = strdup(yytext); return LT;
131{SLASH} yylval.string = strdup(yytext); return SLASH;
132{DBLSLASH} yylval.string = strdup(yytext); return DBLSLASH;
133{BANG} yylval.string = strdup(yytext); return BANG;
134{COLON} yylval.string = strdup(yytext); return COLON;
135{DBLCOLON} yylval.string = strdup(yytext); return DBLCOLON;
136{QUERY} yylval.string = strdup(yytext); return QUERY;
137{HASH} yylval.string = strdup(yytext); return HASH;
138{COMMA} yylval.string = strdup(yytext); return COMMA;
139{DOT} yylval.string = strdup(yytext); return DOT;
140{DBLDOT} yylval.string = strdup(yytext); return DBLDOT;
141{GT} yylval.string = strdup(yytext); return GT;
142{LBRA} yylval.string = strdup(yytext); return LBRA;
143{RBRA} yylval.string = strdup(yytext); return RBRA;
144{TILDE} yylval.string = strdup(yytext); return TILDE;
145{SPLAT} yylval.string = strdup(yytext); return SPLAT;
146{PLUS} yylval.string = strdup(yytext); return PLUS;
147{DASH} yylval.string = strdup(yytext); return DASH;
148{EQ} yylval.string = strdup(yytext); return EQ;
149{LTE} yylval.string = strdup(yytext); return LTE;
150{GTE} yylval.string = strdup(yytext); return GTE;
151{DOLLAR} yylval.string = strdup(yytext); return DOLLAR;
152{BSLASHLIT} yylval.string = strdup(yytext); return BSLASHLIT;
153{XANCESTOR} yylval.string = strdup(yytext); return XANCESTOR;
154{XANCESTORSELF} yylval.string = strdup(yytext); return XANCESTORSELF;
155{XATTR} yylval.string = strdup(yytext); return XATTR;
156{XCHILD} yylval.string = strdup(yytext); return XCHILD;
157{XDESC} yylval.string = strdup(yytext); return XDESC;
158{XDESCSELF} yylval.string = strdup(yytext); return XDESCSELF;
159{XFOLLOW} yylval.string = strdup(yytext); return XFOLLOW;
160{XFOLLOWSIB} yylval.string = strdup(yytext); return XFOLLOWSIB;
161{XNS} yylval.string = strdup(yytext); return XNS;
162{XPARENT} yylval.string = strdup(yytext); return XPARENT;
163{XPRE} yylval.string = strdup(yytext); return XPRE;
164{XPRESIB} yylval.string = strdup(yytext); return XPRESIB;
165{XSELF} yylval.string = strdup(yytext); return XSELF;
166{XOR} yylval.string = strdup(yytext); return XOR;
167{XAND} yylval.string = strdup(yytext); return XAND;
168{XDIV} yylval.string = strdup(yytext); return XDIV;
169{XMOD} yylval.string = strdup(yytext); return XMOD;
170{XCOMMENT} yylval.string = strdup(yytext); return XCOMMENT;
171{XTEXT} yylval.string = strdup(yytext); return XTEXT;
172{XPI} yylval.string = strdup(yytext); return XPI;
173{XNODE} yylval.string = strdup(yytext); return XNODE;
174{CXEQUATION} yylval.string = strdup(yytext); return CXEQUATION;
175{CXOPHE} yylval.string = strdup(yytext); return CXOPHE;
176{CXOPNE} yylval.string = strdup(yytext); return CXOPNE;
177{CXOPSTARTEQ} yylval.string = strdup(yytext); return CXOPSTARTEQ;
178{CXOPENDEQ} yylval.string = strdup(yytext); return CXOPENDEQ;
179{CXOPCONTAINS} yylval.string = strdup(yytext); return CXOPCONTAINS;
180{CXOPCONTAINS2} yylval.string = strdup(yytext); return CXOPCONTAINS2;
181{CXFIRST} yylval.string = strdup(yytext); return CXFIRST;
182{CXLAST} yylval.string = strdup(yytext); return CXLAST;
183{CXNOT} yylval.string = strdup(yytext); return CXNOT;
184{CXEVEN} yylval.string = strdup(yytext); return CXEVEN;
185{CXODD} yylval.string = strdup(yytext); return CXODD;
186{CXEQ} yylval.string = strdup(yytext); return CXEQ;
187{CXGT} yylval.string = strdup(yytext); return CXGT;
188{CXLT} yylval.string = strdup(yytext); return CXLT;
189{CXCONTENT} yylval.string = strdup(yytext); return CXCONTENT;
190{CXHEADER} yylval.string = strdup(yytext); return CXHEADER;
191{CXCONTAINS} yylval.string = strdup(yytext); return CXCONTAINS;
192{CXEMPTY} yylval.string = strdup(yytext); return CXEMPTY;
193{CXHAS} yylval.string = strdup(yytext); return CXHAS;
194{CXPARENT} yylval.string = strdup(yytext); return CXPARENT;
195{CXNTHCH} yylval.string = strdup(yytext); return CXNTHCH;
196{CXNTHLASTCH} yylval.string = strdup(yytext); return CXNTHLASTCH;
197{CXNTHTYPE} yylval.string = strdup(yytext); return CXNTHTYPE;
198{CXNTHLASTTYPE} yylval.string = strdup(yytext); return CXNTHLASTTYPE;
199{CXFIRSTCH} yylval.string = strdup(yytext); return CXFIRSTCH;
200{CXLASTCH} yylval.string = strdup(yytext); return CXLASTCH;
201{CXFIRSTTYPE} yylval.string = strdup(yytext); return CXFIRSTTYPE;
202{CXLASTTYPE} yylval.string = strdup(yytext); return CXLASTTYPE;
203{CXONLYCH} yylval.string = strdup(yytext); return CXONLYCH;
204{CXONLYTYPE} yylval.string = strdup(yytext); return CXONLYTYPE;
205{CXINPUT} yylval.string = strdup(yytext); return CXINPUT;
206{CXTEXT} yylval.string = strdup(yytext); return CXTEXT;
207{CXPASSWORD} yylval.string = strdup(yytext); return CXPASSWORD;
208{CXRADIO} yylval.string = strdup(yytext); return CXRADIO;
209{CXCHECKBOX} yylval.string = strdup(yytext); return CXCHECKBOX;
210{CXSUBMIT} yylval.string = strdup(yytext); return CXSUBMIT;
211{CXIMAGE} yylval.string = strdup(yytext); return CXIMAGE;
212{CXRESET} yylval.string = strdup(yytext); return CXRESET;
213{CXBUTTON} yylval.string = strdup(yytext); return CXBUTTON;
214{CXFILE} yylval.string = strdup(yytext); return CXFILE;
215{CXENABLED} yylval.string = strdup(yytext); return CXENABLED;
216{CXDISABLED} yylval.string = strdup(yytext); return CXDISABLED;
217{CXCHECKED} yylval.string = strdup(yytext); return CXCHECKED;
218{CXSELECTED} yylval.string = strdup(yytext); return CXSELECTED;
219{NAME} yylval.string = strdup(yytext); return NAME;
220{STRING} yylval.string = strdup(yytext); return STRING;
221{OTHER} yylval.string = strdup(yytext); return OTHER;