Annotation of researchv10no/cmd/sml/lib/mlyacc/mlyacc.lex, revision 1.1

1.1     ! root        1: open C.LexValue
        !             2: type lexresult = V
        !             3: 
        !             4: val pcount = ref 0;
        !             5: val commentLevel = ref 0
        !             6: val lineno = C.HDR.lineno
        !             7: val actionstart = ref 0
        !             8: val eof = fn () => (if (!pcount)>0 then
        !             9:                         error " eof encountered in action beginning here !"
        !            10:                                (!actionstart)
        !            11:                      else (); EOF)
        !            12: 
        !            13: val text = ref (nil : string list)
        !            14: val Add = fn s => (text := s::(!text))
        !            15: val error = C.HDR.error
        !            16: val inc = fn (i:int ref) => i := (!i) +1
        !            17: 
        !            18: fun lookup s =
        !            19: let val dict = [("%prec",PREC_TAG),("%term",Term),
        !            20:                  ("%nonterm",Nonterm),("%nonassoc",PREC NONASSOC),
        !            21:                  ("%left",PREC LEFT),("%right",PREC RIGHT),
        !            22:                  ("%eof",PERCENT_EOF),("%start",START),
        !            23:                  ("%prefer",PREFER),("%insert_prefer",IPREFER),
        !            24:                  ("%keyword",KEYWORD),("%structure",STRUCT),
        !            25:                  ("%verbose",VERBOSE)]
        !            26: 
        !            27:      fun find ((a,d)::b) = if a=s then d else find(b)
        !            28:        | find nil = (UNKNOWN s)
        !            29: in find dict
        !            30: end
        !            31: 
        !            32: %%
        !            33: %s A B C D F COMMENT STRING;
        !            34: ws = [\t\ ]*;
        !            35: idchars = [A-Za-z_'0-9];
        !            36: id=[A-Za-z]{idchars}*;
        !            37: tyvar="'"{idchars}*;
        !            38: qualid ={id}".";
        !            39: %%
        !            40: <INITIAL>.     => (YYBEGIN C; lineno := 1; text := [yytext]; lex());
        !            41: <INITIAL>\n    => (YYBEGIN C; lineno := 2; text := [yytext]; lex());
        !            42: <INITIAL>"%%"  => (YYBEGIN D; HEADER "");
        !            43: 
        !            44: <C>[^%\n]+     => (Add yytext; lex());
        !            45: <C>"%%"                => (YYBEGIN D; HEADER (implode (rev (!text))));
        !            46: <C>\n          => (Add yytext; inc lineno; lex());
        !            47: <C>.           => (Add yytext; lex());
        !            48: 
        !            49: <D>"("         => (LPAREN);
        !            50: <D>")"         => (RPAREN);
        !            51: 
        !            52: <D,A>of                => (OF);
        !            53: <D,A>for       => (FOR);
        !            54: <D,A>val       => (VAL);
        !            55: <D,A>"="       => (EQUAL);
        !            56: <D,A>"%%"      => (YYBEGIN A; DELIMITER);
        !            57: <D,A>{ws}+     => (lex());
        !            58: <D,A>\n+       => (lineno := !lineno + (size yytext); lex());
        !            59: <D,A>":"       => (COLON);
        !            60: <D,A>"|"       => (BAR);
        !            61: <D,A>"{"       => (LBRACE);
        !            62: <D,A>"}"       => (RBRACE);
        !            63: <D,A>","       => (COMMA);
        !            64: <D,A>"*"       => (ASTERISK);
        !            65: <D,A>"->"      => (ARROW);
        !            66: <D,A>"%"[a-z_]+        => (lookup yytext);
        !            67: <D,A>{id}      => (ID yytext);
        !            68: <D,A>[0-9]+    => (INT yytext);
        !            69: <D,A>{tyvar}   => (TYVAR yytext);
        !            70: <D,A>{qualid}  => (IDDOT yytext);
        !            71: <A>"("         => (pcount := 1; actionstart := (!C.HDR.lineno);
        !            72:                    text := nil; YYBEGIN B; lex());
        !            73: <D,A>.         => (UNKNOWN yytext);
        !            74: 
        !            75: <B>"("         => (pcount := (!pcount) + 1; Add yytext; lex());
        !            76: <B>")"         => (pcount := (!pcount) - 1; 
        !            77:                    if (!pcount = 0) then
        !            78:                         (YYBEGIN A; PROG (implode (rev (!text))))
        !            79:                    else (Add yytext; lex()));
        !            80: <B>"\""                => (Add yytext; YYBEGIN STRING; lex());
        !            81: <B>[^()"\n]+   => (Add yytext; lex());
        !            82: <B>\n          => (Add yytext; inc lineno; lex());
        !            83: <B>"(*"                => (Add yytext; YYBEGIN COMMENT; inc commentLevel; lex());
        !            84: 
        !            85: <COMMENT>[(*)] => (Add yytext; lex());
        !            86: <COMMENT>"(*"  => (Add yytext; inc commentLevel; lex());
        !            87: <COMMENT>[^*()\n]+ => (Add yytext; lex());
        !            88: <COMMENT>\n    => (Add yytext; inc lineno; lex());
        !            89: <COMMENT>"*)"  => (Add yytext; dec commentLevel;
        !            90:                    if !commentLevel=0 then YYBEGIN B else (); lex());
        !            91: <STRING>"\""   => (Add yytext; YYBEGIN B; lex());
        !            92: <STRING>[^"\\\n]+ => (Add yytext; lex());
        !            93: <STRING>\\     => (Add yytext; lex());
        !            94: <STRING>\\\"   => (Add yytext; lex());
        !            95: <STRING>\n     => (Add yytext; error "unclosed string" (!lineno); 
        !            96:                    inc lineno; YYBEGIN B; lex());
        !            97: <STRING>\\[\ \t\n]   => (Add yytext;
        !            98:                        if substring(yytext,1,1)="\n" then inc lineno else ();
        !            99:                        YYBEGIN F; lex());
        !           100: 
        !           101: <F>\n          => (Add yytext; inc lineno; lex());
        !           102: <F>[\ \t]+     => (Add yytext; lex());
        !           103: <F>\\          => (Add yytext; YYBEGIN STRING; lex());
        !           104: <F>.           => (Add yytext; error "unclosed string" (!lineno);
        !           105:                    YYBEGIN B; lex());
        !           106: %%

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.