home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-08-18 | 15.8 KB | 520 lines | [TEXT/Moml] |
- local open Obj Lexing in
-
-
- open Fnlib Syntax Grammar Scan_aux;
-
- fun action_50 lexbuf = (
- raise Lexical_error
- ("illegal character #" ^ makestring(getLexeme lexbuf)) )
- and action_49 lexbuf = (
- raise Lexical_error "unterminated lexer definition" )
- and action_48 lexbuf = (
- Tdash )
- and action_47 lexbuf = (
- Tcaret )
- and action_46 lexbuf = (
- Trparen )
- and action_45 lexbuf = (
- Tlparen )
- and action_44 lexbuf = (
- Tplus )
- and action_43 lexbuf = (
- Tmaybe )
- and action_42 lexbuf = (
- Tstar )
- and action_41 lexbuf = (
- Trbracket )
- and action_40 lexbuf = (
- Tlbracket )
- and action_39 lexbuf = (
- Teof )
- and action_38 lexbuf = (
- Tunderscore )
- and action_37 lexbuf = (
- Tor )
- and action_36 lexbuf = (
- Tend )
- and action_35 lexbuf = (
- Tequal )
- and action_34 lexbuf = (
- let val n1 = getLexemeEnd lexbuf
- val () = brace_depth := 1
- val n2 = action lexbuf
- in Taction(Location(n1, n2)) end )
- and action_33 lexbuf = (
- Tchar(char lexbuf) )
- and action_32 lexbuf = (
- (reset_string_buffer();
- string lexbuf;
- Tstring(get_stored_string())) )
- and action_31 lexbuf = (
- case getLexeme lexbuf of
- "rule" => Trule
- | "parse" => Tparse
- | "and" => Tand
- | "eof" => Teof
- | s => Tident s )
- and action_30 lexbuf = (
- raise Lexical_error "unmatched comment bracket" )
- and action_29 lexbuf = (
- (comment_depth := 1; comment lexbuf; main lexbuf) )
- and action_28 lexbuf = (
- main lexbuf )
- and action_27 lexbuf = (
- action lexbuf )
- and action_26 lexbuf = (
- raise Lexical_error "unterminated action" )
- and action_25 lexbuf = (
- raise Lexical_error "unmatched comment bracket" )
- and action_24 lexbuf = (
- (comment_depth := 1; comment lexbuf; action lexbuf) )
- and action_23 lexbuf = (
- (reset_string_buffer();
- string lexbuf;
- reset_string_buffer();
- action lexbuf) )
- and action_22 lexbuf = (
- (decr brace_depth;
- if !brace_depth = 0 then
- getLexemeStart lexbuf
- else
- action lexbuf) )
- and action_21 lexbuf = (
- (incr brace_depth; action lexbuf) )
- and action_20 lexbuf = (
- (store_string_char(getLexemeChar lexbuf 0);
- string lexbuf) )
- and action_19 lexbuf = (
- raise Lexical_error "invalid character in string" )
- and action_18 lexbuf = (
- raise Lexical_error "unterminated string" )
- and action_17 lexbuf = (
- raise Lexical_error "ill-formed escape sequence in string" )
- and action_16 lexbuf = (
- let val code = char_for_decimal_code lexbuf 1 in
- if Char.ord code >= 256 then
- raise Lexical_error "character code in string > 255"
- else ();
- store_string_char code;
- string lexbuf
- end )
- and action_15 lexbuf = (
- (store_string_char(
- Char.chr(Char.ord(getLexemeChar lexbuf 2) - 64));
- string lexbuf) )
- and action_14 lexbuf = (
- (store_string_char(char_for_backslash(getLexemeChar lexbuf 1));
- string lexbuf) )
- and action_13 lexbuf = (
- string lexbuf )
- and action_12 lexbuf = (
- () )
- and action_11 lexbuf = (
- raise Lexical_error "ill-formed character constant" )
- and action_10 lexbuf = (
- getLexemeChar lexbuf 0 )
- and action_9 lexbuf = (
- raise Lexical_error "invalid character in character constant" )
- and action_8 lexbuf = (
- raise Lexical_error "unterminated character constant" )
- and action_7 lexbuf = (
- raise Lexical_error "ill-formed escape sequence in character constant" )
- and action_6 lexbuf = (
- let val code = char_for_decimal_code lexbuf 1 in
- if Char.ord code >= 256 then
- raise Lexical_error "character code in string > 255"
- else ();
- code
- end )
- and action_5 lexbuf = (
- Char.chr(Char.ord(getLexemeChar lexbuf 2) - 64) )
- and action_4 lexbuf = (
- char_for_backslash (getLexemeChar lexbuf 1) )
- and action_3 lexbuf = (
- comment lexbuf )
- and action_2 lexbuf = (
- raise Lexical_error "unterminated comment" )
- and action_1 lexbuf = (
- (decr comment_depth;
- if !comment_depth = 0 then () else comment lexbuf) )
- and action_0 lexbuf = (
- (incr comment_depth; comment lexbuf) )
- and state_0 lexbuf = (
- let val currChar = getNextChar lexbuf in
- case currChar of
- #"*" => state_77 lexbuf
- | #"(" => state_76 lexbuf
- | #"\^Z" => action_2 lexbuf
- | #"\^@" => action_2 lexbuf
- | _ => action_3 lexbuf
- end)
- and state_1 lexbuf = (
- let val currChar = getNextChar lexbuf in
- if currChar >= #"\^A" andalso currChar <= #"\^Y" then state_58 lexbuf
- else case currChar of
- #"\^_" => state_58 lexbuf
- | #"\^^" => state_58 lexbuf
- | #"\^]" => state_58 lexbuf
- | #"\^\" => state_58 lexbuf
- | #"\^[" => state_58 lexbuf
- | #"\127" => state_58 lexbuf
- | #"\255" => state_58 lexbuf
- | #"\\" => state_61 lexbuf
- | #"\^Z" => state_59 lexbuf
- | #"\^@" => action_8 lexbuf
- | _ => state_60 lexbuf
- end)
- and state_2 lexbuf = (
- let val currChar = getNextChar lexbuf in
- if currChar >= #"\^A" andalso currChar <= #"\^Y" then action_19 lexbuf
- else case currChar of
- #"\^_" => action_19 lexbuf
- | #"\^^" => action_19 lexbuf
- | #"\^]" => action_19 lexbuf
- | #"\^\" => action_19 lexbuf
- | #"\^[" => action_19 lexbuf
- | #"\127" => action_19 lexbuf
- | #"\255" => action_19 lexbuf
- | #"\\" => state_48 lexbuf
- | #"\"" => action_12 lexbuf
- | #"\^Z" => action_18 lexbuf
- | #"\^@" => action_18 lexbuf
- | _ => action_20 lexbuf
- end)
- and state_3 lexbuf = (
- let val currChar = getNextChar lexbuf in
- case currChar of
- #"}" => action_22 lexbuf
- | #"{" => action_21 lexbuf
- | #"*" => state_38 lexbuf
- | #"(" => state_37 lexbuf
- | #"\"" => action_23 lexbuf
- | #"\^Z" => action_26 lexbuf
- | #"\^@" => action_26 lexbuf
- | _ => action_27 lexbuf
- end)
- and state_4 lexbuf = (
- let val currChar = getNextChar lexbuf in
- if currChar >= #"A" andalso currChar <= #"Z" then state_18 lexbuf
- else if currChar >= #"f" andalso currChar <= #"z" then state_18 lexbuf
- else case currChar of
- #"d" => state_18 lexbuf
- | #"c" => state_18 lexbuf
- | #"b" => state_18 lexbuf
- | #"a" => state_18 lexbuf
- | #"\r" => state_7 lexbuf
- | #"\t" => state_7 lexbuf
- | #"\n" => state_7 lexbuf
- | #" " => state_7 lexbuf
- | #"|" => action_37 lexbuf
- | #"{" => action_34 lexbuf
- | #"e" => state_24 lexbuf
- | #"`" => action_33 lexbuf
- | #"_" => action_38 lexbuf
- | #"^" => action_47 lexbuf
- | #"]" => action_41 lexbuf
- | #"[" => action_40 lexbuf
- | #"?" => action_43 lexbuf
- | #"=" => action_35 lexbuf
- | #";" => action_36 lexbuf
- | #"-" => action_48 lexbuf
- | #"+" => action_44 lexbuf
- | #"*" => state_12 lexbuf
- | #")" => action_46 lexbuf
- | #"(" => state_10 lexbuf
- | #"\"" => action_32 lexbuf
- | #"\^Z" => action_49 lexbuf
- | #"\^@" => action_49 lexbuf
- | _ => action_50 lexbuf
- end)
- and state_7 lexbuf = (
- setLexLastPos lexbuf (getLexCurrPos lexbuf);
- setLexLastAction lexbuf (magic action_28);
- let val currChar = getNextChar lexbuf in
- case currChar of
- #"\r" => state_32 lexbuf
- | #"\t" => state_32 lexbuf
- | #"\n" => state_32 lexbuf
- | #" " => state_32 lexbuf
- | _ => backtrack lexbuf
- end)
- and state_10 lexbuf = (
- setLexLastPos lexbuf (getLexCurrPos lexbuf);
- setLexLastAction lexbuf (magic action_45);
- let val currChar = getNextChar lexbuf in
- case currChar of
- #"*" => action_29 lexbuf
- | _ => backtrack lexbuf
- end)
- and state_12 lexbuf = (
- setLexLastPos lexbuf (getLexCurrPos lexbuf);
- setLexLastAction lexbuf (magic action_42);
- let val currChar = getNextChar lexbuf in
- case currChar of
- #")" => action_30 lexbuf
- | _ => backtrack lexbuf
- end)
- and state_18 lexbuf = (
- setLexLastPos lexbuf (getLexCurrPos lexbuf);
- setLexLastAction lexbuf (magic action_31);
- let val currChar = getNextChar lexbuf in
- if currChar >= #"0" andalso currChar <= #"9" then state_27 lexbuf
- else if currChar >= #"A" andalso currChar <= #"Z" then state_27 lexbuf
- else if currChar >= #"a" andalso currChar <= #"z" then state_27 lexbuf
- else case currChar of
- #"'" => state_27 lexbuf
- | #"_" => state_27 lexbuf
- | _ => backtrack lexbuf
- end)
- and state_24 lexbuf = (
- setLexLastPos lexbuf (getLexCurrPos lexbuf);
- setLexLastAction lexbuf (magic action_31);
- let val currChar = getNextChar lexbuf in
- if currChar >= #"0" andalso currChar <= #"9" then state_27 lexbuf
- else if currChar >= #"A" andalso currChar <= #"Z" then state_27 lexbuf
- else if currChar >= #"a" andalso currChar <= #"n" then state_27 lexbuf
- else if currChar >= #"p" andalso currChar <= #"z" then state_27 lexbuf
- else case currChar of
- #"'" => state_27 lexbuf
- | #"_" => state_27 lexbuf
- | #"o" => state_28 lexbuf
- | _ => backtrack lexbuf
- end)
- and state_27 lexbuf = (
- setLexLastPos lexbuf (getLexCurrPos lexbuf);
- setLexLastAction lexbuf (magic action_31);
- let val currChar = getNextChar lexbuf in
- if currChar >= #"0" andalso currChar <= #"9" then state_27 lexbuf
- else if currChar >= #"A" andalso currChar <= #"Z" then state_27 lexbuf
- else if currChar >= #"a" andalso currChar <= #"z" then state_27 lexbuf
- else case currChar of
- #"'" => state_27 lexbuf
- | #"_" => state_27 lexbuf
- | _ => backtrack lexbuf
- end)
- and state_28 lexbuf = (
- setLexLastPos lexbuf (getLexCurrPos lexbuf);
- setLexLastAction lexbuf (magic action_31);
- let val currChar = getNextChar lexbuf in
- if currChar >= #"0" andalso currChar <= #"9" then state_27 lexbuf
- else if currChar >= #"A" andalso currChar <= #"Z" then state_27 lexbuf
- else if currChar >= #"g" andalso currChar <= #"z" then state_27 lexbuf
- else case currChar of
- #"'" => state_27 lexbuf
- | #"_" => state_27 lexbuf
- | #"e" => state_27 lexbuf
- | #"d" => state_27 lexbuf
- | #"c" => state_27 lexbuf
- | #"b" => state_27 lexbuf
- | #"a" => state_27 lexbuf
- | #"f" => state_29 lexbuf
- | _ => backtrack lexbuf
- end)
- and state_29 lexbuf = (
- setLexLastPos lexbuf (getLexCurrPos lexbuf);
- setLexLastAction lexbuf (magic action_31);
- let val currChar = getNextChar lexbuf in
- if currChar >= #"0" andalso currChar <= #"9" then state_27 lexbuf
- else if currChar >= #"A" andalso currChar <= #"Z" then state_27 lexbuf
- else if currChar >= #"a" andalso currChar <= #"z" then state_27 lexbuf
- else case currChar of
- #"'" => state_27 lexbuf
- | #"_" => state_27 lexbuf
- | _ => backtrack lexbuf
- end)
- and state_32 lexbuf = (
- setLexLastPos lexbuf (getLexCurrPos lexbuf);
- setLexLastAction lexbuf (magic action_28);
- let val currChar = getNextChar lexbuf in
- case currChar of
- #"\r" => state_32 lexbuf
- | #"\t" => state_32 lexbuf
- | #"\n" => state_32 lexbuf
- | #" " => state_32 lexbuf
- | _ => backtrack lexbuf
- end)
- and state_37 lexbuf = (
- setLexLastPos lexbuf (getLexCurrPos lexbuf);
- setLexLastAction lexbuf (magic action_27);
- let val currChar = getNextChar lexbuf in
- case currChar of
- #"*" => action_24 lexbuf
- | _ => backtrack lexbuf
- end)
- and state_38 lexbuf = (
- setLexLastPos lexbuf (getLexCurrPos lexbuf);
- setLexLastAction lexbuf (magic action_27);
- let val currChar = getNextChar lexbuf in
- case currChar of
- #")" => action_25 lexbuf
- | _ => backtrack lexbuf
- end)
- and state_48 lexbuf = (
- setLexLastPos lexbuf (getLexCurrPos lexbuf);
- setLexLastAction lexbuf (magic action_17);
- let val currChar = getNextChar lexbuf in
- if currChar >= #"0" andalso currChar <= #"9" then state_51 lexbuf
- else case currChar of
- #"\"" => action_14 lexbuf
- | #"\\" => action_14 lexbuf
- | #"b" => action_14 lexbuf
- | #"n" => action_14 lexbuf
- | #"r" => action_14 lexbuf
- | #"t" => action_14 lexbuf
- | #"\r" => state_49 lexbuf
- | #"\t" => state_49 lexbuf
- | #"\n" => state_49 lexbuf
- | #" " => state_49 lexbuf
- | #"^" => state_52 lexbuf
- | _ => backtrack lexbuf
- end)
- and state_49 lexbuf = (
- let val currChar = getNextChar lexbuf in
- case currChar of
- #"\r" => state_49 lexbuf
- | #"\t" => state_49 lexbuf
- | #"\n" => state_49 lexbuf
- | #" " => state_49 lexbuf
- | #"\\" => action_13 lexbuf
- | _ => backtrack lexbuf
- end)
- and state_51 lexbuf = (
- let val currChar = getNextChar lexbuf in
- if currChar >= #"0" andalso currChar <= #"9" then state_54 lexbuf
- else backtrack lexbuf
- end)
- and state_52 lexbuf = (
- let val currChar = getNextChar lexbuf in
- if currChar >= #"@" andalso currChar <= #"_" then action_15 lexbuf
- else backtrack lexbuf
- end)
- and state_54 lexbuf = (
- let val currChar = getNextChar lexbuf in
- if currChar >= #"0" andalso currChar <= #"9" then action_16 lexbuf
- else backtrack lexbuf
- end)
- and state_58 lexbuf = (
- setLexLastPos lexbuf (getLexCurrPos lexbuf);
- setLexLastAction lexbuf (magic action_9);
- let val currChar = getNextChar lexbuf in
- case currChar of
- #"`" => action_10 lexbuf
- | _ => backtrack lexbuf
- end)
- and state_59 lexbuf = (
- setLexLastPos lexbuf (getLexCurrPos lexbuf);
- setLexLastAction lexbuf (magic action_8);
- let val currChar = getNextChar lexbuf in
- case currChar of
- #"`" => action_10 lexbuf
- | _ => backtrack lexbuf
- end)
- and state_60 lexbuf = (
- setLexLastPos lexbuf (getLexCurrPos lexbuf);
- setLexLastAction lexbuf (magic action_11);
- let val currChar = getNextChar lexbuf in
- case currChar of
- #"`" => action_10 lexbuf
- | _ => backtrack lexbuf
- end)
- and state_61 lexbuf = (
- setLexLastPos lexbuf (getLexCurrPos lexbuf);
- setLexLastAction lexbuf (magic action_7);
- let val currChar = getNextChar lexbuf in
- if currChar >= #"0" andalso currChar <= #"9" then state_62 lexbuf
- else case currChar of
- #"\\" => state_63 lexbuf
- | #"b" => state_63 lexbuf
- | #"n" => state_63 lexbuf
- | #"r" => state_63 lexbuf
- | #"t" => state_63 lexbuf
- | #"`" => state_65 lexbuf
- | #"^" => state_64 lexbuf
- | _ => backtrack lexbuf
- end)
- and state_62 lexbuf = (
- let val currChar = getNextChar lexbuf in
- if currChar >= #"0" andalso currChar <= #"9" then state_69 lexbuf
- else backtrack lexbuf
- end)
- and state_63 lexbuf = (
- let val currChar = getNextChar lexbuf in
- case currChar of
- #"`" => action_4 lexbuf
- | _ => backtrack lexbuf
- end)
- and state_64 lexbuf = (
- let val currChar = getNextChar lexbuf in
- if currChar >= #"@" andalso currChar <= #"_" then state_67 lexbuf
- else backtrack lexbuf
- end)
- and state_65 lexbuf = (
- setLexLastPos lexbuf (getLexCurrPos lexbuf);
- setLexLastAction lexbuf (magic action_10);
- let val currChar = getNextChar lexbuf in
- case currChar of
- #"`" => action_4 lexbuf
- | _ => backtrack lexbuf
- end)
- and state_67 lexbuf = (
- let val currChar = getNextChar lexbuf in
- case currChar of
- #"`" => action_5 lexbuf
- | _ => backtrack lexbuf
- end)
- and state_69 lexbuf = (
- let val currChar = getNextChar lexbuf in
- if currChar >= #"0" andalso currChar <= #"9" then state_70 lexbuf
- else backtrack lexbuf
- end)
- and state_70 lexbuf = (
- let val currChar = getNextChar lexbuf in
- case currChar of
- #"`" => action_6 lexbuf
- | _ => backtrack lexbuf
- end)
- and state_76 lexbuf = (
- setLexLastPos lexbuf (getLexCurrPos lexbuf);
- setLexLastAction lexbuf (magic action_3);
- let val currChar = getNextChar lexbuf in
- case currChar of
- #"*" => action_0 lexbuf
- | _ => backtrack lexbuf
- end)
- and state_77 lexbuf = (
- setLexLastPos lexbuf (getLexCurrPos lexbuf);
- setLexLastAction lexbuf (magic action_3);
- let val currChar = getNextChar lexbuf in
- case currChar of
- #")" => action_1 lexbuf
- | _ => backtrack lexbuf
- end)
- and main lexbuf =
- (setLexStartPos lexbuf (getLexCurrPos lexbuf);
- state_4 lexbuf)
-
- and action lexbuf =
- (setLexStartPos lexbuf (getLexCurrPos lexbuf);
- state_3 lexbuf)
-
- and string lexbuf =
- (setLexStartPos lexbuf (getLexCurrPos lexbuf);
- state_2 lexbuf)
-
- and char lexbuf =
- (setLexStartPos lexbuf (getLexCurrPos lexbuf);
- state_1 lexbuf)
-
- and comment lexbuf =
- (setLexStartPos lexbuf (getLexCurrPos lexbuf);
- state_0 lexbuf)
-
- (* The following checks type consistency of actions *)
- val _ = fn _ => [action_50, action_49, action_48, action_47, action_46, action_45, action_44, action_43, action_42, action_41, action_40, action_39, action_38, action_37, action_36, action_35, action_34, action_33, action_32, action_31, action_30, action_29, action_28];
- val _ = fn _ => [action_27, action_26, action_25, action_24, action_23, action_22, action_21];
- val _ = fn _ => [action_20, action_19, action_18, action_17, action_16, action_15, action_14, action_13, action_12];
- val _ = fn _ => [action_11, action_10, action_9, action_8, action_7, action_6, action_5, action_4];
- val _ = fn _ => [action_3, action_2, action_1, action_0];
-
- end
-