comparison src/urweb.lex @ 2221:278e10629ba1

Basic field-resolution invalidation.
author Ziv Scully <ziv@mit.edu>
date Sat, 29 Nov 2014 03:37:59 -0500
parents 6d126af2e1cb
children 4d967a4ddb82
comparison
equal deleted inserted replaced
2220:794017f378de 2221:278e10629ba1
16 * 16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
48 (if !commentLevel = 0 then 48 (if !commentLevel = 0 then
49 commentPos := pos 49 commentPos := pos
50 else 50 else
51 (); 51 ();
52 commentLevel := !commentLevel + 1) 52 commentLevel := !commentLevel + 1)
53 53
54 fun exitComment () = 54 fun exitComment () =
55 (ignore (commentLevel := !commentLevel - 1); 55 (ignore (commentLevel := !commentLevel - 1);
56 if !commentLevel = 0 then 56 if !commentLevel = 0 then
57 !commentOut () 57 !commentOut ()
58 else 58 else
59 ()) 59 ())
60 60
61 fun eof () = 61 fun eof () =
62 let 62 let
63 val pos = ErrorMsg.lastLineStart () 63 val pos = ErrorMsg.lastLineStart ()
64 in 64 in
65 if !commentLevel > 0 then 65 if !commentLevel > 0 then
66 ErrorMsg.errorAt' (!commentPos, !commentPos) "Unterminated comment" 66 ErrorMsg.errorAt' (!commentPos, !commentPos) "Unterminated comment"
67 else 67 else
68 (); 68 ();
69 Tokens.EOF (pos, pos) 69 Tokens.EOF (pos, pos)
70 end 70 end
71 end 71 end
72 72
73 val strEnder = ref #"\"" 73 val strEnder = ref #"\""
74 val str = ref ([] : char list) 74 val str = ref ([] : char list)
175 %header (functor UrwebLexFn(structure Tokens : Urweb_TOKENS)); 175 %header (functor UrwebLexFn(structure Tokens : Urweb_TOKENS));
176 %full 176 %full
177 %s COMMENT STRING CHAR XML XMLTAG; 177 %s COMMENT STRING CHAR XML XMLTAG;
178 178
179 id = [a-z_][A-Za-z0-9_']*; 179 id = [a-z_][A-Za-z0-9_']*;
180 xmlid = [A-Za-z][A-Za-z0-9-_]*; 180 xmlid = [A-Za-z][A-Za-z0-9_-]*;
181 cid = [A-Z][A-Za-z0-9_]*; 181 cid = [A-Z][A-Za-z0-9_]*;
182 ws = [\ \t\012\r]; 182 ws = [\ \t\012\r];
183 intconst = [0-9]+; 183 intconst = [0-9]+;
184 realconst = [0-9]+\.[0-9]*; 184 realconst = [0-9]+\.[0-9]*;
185 notags = ([^<{\n(]|(\([^\*<{\n]))+; 185 notags = ([^<{\n(]|(\([^\*<{\n]))+;
298 (YYBEGIN INITIAL; 298 (YYBEGIN INITIAL;
299 xmlTag := rest; 299 xmlTag := rest;
300 Tokens.XML_END (yypos, yypos + size yytext)) 300 Tokens.XML_END (yypos, yypos + size yytext))
301 else 301 else
302 Tokens.END_TAG (id, yypos, yypos + size yytext) 302 Tokens.END_TAG (id, yypos, yypos + size yytext)
303 | _ => 303 | _ =>
304 Tokens.END_TAG (id, yypos, yypos + size yytext) 304 Tokens.END_TAG (id, yypos, yypos + size yytext)
305 end); 305 end);
306 306
307 <XML> "<" {xmlid} => (YYBEGIN XMLTAG; 307 <XML> "<" {xmlid} => (YYBEGIN XMLTAG;
308 Tokens.BEGIN_TAG (String.extract (yytext, 1, NONE), 308 Tokens.BEGIN_TAG (String.extract (yytext, 1, NONE),