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

1.1     ! root        1: open C.LexValue
        !             2: type lexresult=V
        !             3: val eof = fn () => EOF
        !             4: val lineno = C.G.lineno
        !             5: 
        !             6: structure KeyWord : sig
        !             7:                        val find : string -> V option
        !             8:                    end =
        !             9:   struct
        !            10: 
        !            11:        val TableSize = 211
        !            12:        val HashFactor = 5
        !            13: 
        !            14:        val hash = fn s =>
        !            15:           fold (fn (c,v)=>(v*HashFactor+(ord c)) mod TableSize) (explode s) 0
        !            16: 
        !            17: 
        !            18:        val HashTable = array(TableSize,nil) : (string * V) list array
        !            19: 
        !            20: 
        !            21:        val add = fn (s,v) =>
        !            22:         let val i = hash s
        !            23:         in update(HashTable,i,(s,v) :: (HashTable sub i))
        !            24:         end
        !            25: 
        !            26:         val find = fn s =>
        !            27:          let val i = hash s
        !            28:              fun f ((key,v)::r) = if s=key then SOME v else f r
        !            29:                | f nil = NONE
        !            30:          in  f (HashTable sub i)
        !            31:          end
        !            32:  
        !            33:        val _ = 
        !            34:            (List.app add
        !            35:        [("and",YAND),
        !            36:         ("array",YARRAY),
        !            37:         ("begin",YBEGIN),
        !            38:         ("case",YCASE),
        !            39:         ("const",YCONST),
        !            40:         ("div",YDIV),
        !            41:         ("do",YDO),
        !            42:         ("downto",YDOWNTO),
        !            43:         ("else",YELSE),
        !            44:         ("end",YEND),
        !            45:         ("extern",YEXTERN),
        !            46:         ("file",YFILE),
        !            47:         ("for",YFOR),
        !            48:         ("forward",YFORWARD),
        !            49:         ("function",YFUNCTION),
        !            50:         ("goto",YGOTO),
        !            51:         ("hex",YHEX),
        !            52:         ("if",YIF),
        !            53:         ("in",YIN),
        !            54:         ("label",YLABEL),
        !            55:         ("mod",YMOD),
        !            56:         ("nil",YNIL),
        !            57:         ("not",YNOT),
        !            58:         ("oct",YOCT),
        !            59:         ("of",YOF),
        !            60:         ("or",YOR),
        !            61:         ("packed",YPACKED),
        !            62:         ("procedure",YPROCEDURE),
        !            63:         ("program",YPROG),
        !            64:         ("record",YRECORD),
        !            65:         ("repeat",YREPEAT),
        !            66:         ("set",YSET),
        !            67:         ("then",YTHEN),
        !            68:         ("to",YTO),
        !            69:         ("type",YTYPE),
        !            70:         ("until",YUNTIL),
        !            71:         ("var",YVAR),
        !            72:         ("while",YWHILE),
        !            73:         ("with",YWITH)
        !            74:        ])
        !            75:    end
        !            76:    open KeyWord
        !            77: 
        !            78: %%
        !            79: 
        !            80: %s C B;
        !            81: alpha=[A-Za-z];
        !            82: digit=[0-9];
        !            83: optsign=("+"|"-")?;
        !            84: integer={digit}+;
        !            85: frac="."{digit}+;
        !            86: exp=(e|E){optsign}{digit}+;
        !            87: octdigit=[0-7];
        !            88: ws = [\ \t];
        !            89: %%
        !            90: <INITIAL>{ws}+ => (lex());
        !            91: <INITIAL>\n    => (inc lineno; lex());
        !            92: <INITIAL>{alpha}+ => (case find yytext of SOME v => v | _ => YID);
        !            93: <INITIAL>{alpha}({alpha}|{digit})*  => (YID);
        !            94: <INITIAL>{optsign}{integer}({frac}{exp}?|{frac}?{exp}) => (YNUMB);
        !            95: <INITIAL>{optsign}{integer} => (YINT);
        !            96: <INITIAL>{octdigit}+(b|B) => (YBINT);
        !            97: <INITIAL>"'"([^']|"''")*"'" => (YSTRING);
        !            98: <INITIAL>"(*" =>   (YYBEGIN C; lex());
        !            99: <INITIAL>".."  => (YDOTDOT);
        !           100: <INITIAL>"."   => (YDOT);
        !           101: <INITIAL>"("   => (YLPAR);
        !           102: <INITIAL>")"   => (YRPAR);
        !           103: <INITIAL>";"   => (YSEMI);
        !           104: <INITIAL>","   => (YCOMMA);
        !           105: <INITIAL>":"   => (YCOLON);
        !           106: <INITIAL>"^"   => (YCARET);
        !           107: <INITIAL>"["   => (YLBRA);
        !           108: <INITIAL>"]"   => (YRBRA);
        !           109: <INITIAL>"~"   => (YTILDE);
        !           110: <INITIAL>"<"   => (YLESS);
        !           111: <INITIAL>"="   => (YEQUAL);
        !           112: <INITIAL>">"   => (YGREATER);
        !           113: <INITIAL>"+"   => (YPLUS);
        !           114: <INITIAL>"-"   => (YMINUS);
        !           115: <INITIAL>"|"   => (YBAR);
        !           116: <INITIAL>"*"   => (YSTAR);
        !           117: <INITIAL>"/"   => (YSLASH);
        !           118: <INITIAL>"{"   => (YYBEGIN B; lex());
        !           119: <INITIAL>.     => (YILLCH);
        !           120: <C>\n          => (inc lineno; lex());
        !           121: <C>[^()*\n]+   => (lex());
        !           122: <C>"(*"                => (lex());
        !           123: <C>"*)"                => (YYBEGIN INITIAL; lex());
        !           124: <C>[*()]       => (lex());
        !           125: <B>\n          => (inc lineno; lex());
        !           126: <B>[^{}\n]+    => (lex());
        !           127: <B>"{"         => (lex());
        !           128: <B>"}"         => (YYBEGIN INITIAL; lex());

unix.superglobalmegacorp.com

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