X-Git-Url: http://git.joshuawise.com/snipe.git/blobdiff_plain/12aa4087bee3e70f170d7457794921de4e385227..0a24e44d4e9f82f8d3d83de8e58c83c8cf2868b6:/parse/l1.lex.sml diff --git a/parse/l1.lex.sml b/parse/l1.lex.sml deleted file mode 100644 index 70eb999..0000000 --- a/parse/l1.lex.sml +++ /dev/null @@ -1,581 +0,0 @@ -functor L1LexFn(structure Tokens : L1_TOKENS)= - struct - structure UserDeclarations = - struct -(* L1 Compiler - * Lexer - * Author: Kaustuv Chaudhuri - * Modified: Frank Pfenning - *) - -structure A = Ast -structure S = Symbol - -type pos = int -type svalue = Tokens.svalue -type ('a,'b) token = ('a,'b) Tokens.token -type lexresult = (svalue,pos) Tokens.token - -local - val commentLevel = ref 0 - val commentPos = ref 0 -in - fun enterComment yypos = - ( commentLevel := !commentLevel + 1 ; - commentPos := yypos ) - - fun exitComment () = - ( commentLevel := !commentLevel - 1 ; - !commentLevel = 0 ) - - fun number (yyt, yyp) = - let - val ext = ParseState.ext (yyp, yyp + size yyt) - val numOpt = Word32Signed.fromString yyt - handle Overflow => - ( ErrorMsg.error ext - ("integral constant `" ^ yyt ^ "' too large") ; - NONE ) - in - case numOpt - of NONE => ( ErrorMsg.error ext - ("cannot parse integral constant `" ^ yyt ^ "'"); - Tokens.INTNUM (Word32Signed.ZERO, yyp, yyp + size yyt) ) - | SOME n => Tokens.INTNUM (n,yyp,yyp + size yyt) - end - - fun eof () = - ( if (!commentLevel > 0) - then (ErrorMsg.error (ParseState.ext (!commentPos,!commentPos)) "unterminated comment") - else (); - Tokens.EOF (0,0) ) (* bogus position information; unused *) - -end - -end (* end of user routines *) -exception LexError (* raised if illegal leaf action tried *) -structure Internal = - struct - -datatype yyfinstate = N of int -type statedata = {fin : yyfinstate list, trans: string} -(* transition & final state table *) -val tab = let -val s = [ - (0, -"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" -), - (1, -"\007\007\007\007\007\007\007\007\007\038\040\007\038\007\007\007\ -\\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\ -\\038\007\007\037\007\035\007\007\034\033\030\028\007\026\007\022\ -\\020\020\020\020\020\020\020\020\020\020\007\019\007\018\007\007\ -\\007\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\ -\\010\010\010\010\010\010\010\010\010\010\010\007\007\007\007\010\ -\\007\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\ -\\010\010\012\010\010\010\010\010\010\010\010\009\007\008\007\007\ -\\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\ -\\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\ -\\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\ -\\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\ -\\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\ -\\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\ -\\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\ -\\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007" -), - (3, -"\041\041\041\041\041\041\041\041\041\041\046\041\041\041\041\041\ -\\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\ -\\041\041\041\041\041\041\041\041\041\041\044\041\041\041\041\042\ -\\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\ -\\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\ -\\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\ -\\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\ -\\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\ -\\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\ -\\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\ -\\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\ -\\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\ -\\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\ -\\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\ -\\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\ -\\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041" -), - (5, -"\047\047\047\047\047\047\047\047\047\047\048\047\047\047\047\047\ -\\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\ -\\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\ -\\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\ -\\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\ -\\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\ -\\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\ -\\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\ -\\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\ -\\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\ -\\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\ -\\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\ -\\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\ -\\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\ -\\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\ -\\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047" -), - (10, -"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\011\011\011\011\011\011\011\011\011\011\000\000\000\000\000\000\ -\\000\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\ -\\011\011\011\011\011\011\011\011\011\011\011\000\000\000\000\011\ -\\000\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\ -\\011\011\011\011\011\011\011\011\011\011\011\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" -), - (12, -"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\011\011\011\011\011\011\011\011\011\011\000\000\000\000\000\000\ -\\000\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\ -\\011\011\011\011\011\011\011\011\011\011\011\000\000\000\000\011\ -\\000\011\011\011\011\013\011\011\011\011\011\011\011\011\011\011\ -\\011\011\011\011\011\011\011\011\011\011\011\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" -), - (13, -"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\011\011\011\011\011\011\011\011\011\011\000\000\000\000\000\000\ -\\000\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\ -\\011\011\011\011\011\011\011\011\011\011\011\000\000\000\000\011\ -\\000\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\ -\\011\011\011\011\014\011\011\011\011\011\011\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" -), - (14, -"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\011\011\011\011\011\011\011\011\011\011\000\000\000\000\000\000\ -\\000\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\ -\\011\011\011\011\011\011\011\011\011\011\011\000\000\000\000\011\ -\\000\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\ -\\011\011\011\011\011\015\011\011\011\011\011\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" -), - (15, -"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\011\011\011\011\011\011\011\011\011\011\000\000\000\000\000\000\ -\\000\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\ -\\011\011\011\011\011\011\011\011\011\011\011\000\000\000\000\011\ -\\000\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\ -\\011\011\016\011\011\011\011\011\011\011\011\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" -), - (16, -"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\011\011\011\011\011\011\011\011\011\011\000\000\000\000\000\000\ -\\000\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\ -\\011\011\011\011\011\011\011\011\011\011\011\000\000\000\000\011\ -\\000\011\011\011\011\011\011\011\011\011\011\011\011\011\017\011\ -\\011\011\011\011\011\011\011\011\011\011\011\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" -), - (20, -"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\021\021\021\021\021\021\021\021\021\021\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" -), - (22, -"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\025\000\000\000\000\024\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\023\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" -), - (26, -"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\027\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" -), - (28, -"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\029\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" -), - (30, -"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\032\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\031\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" -), - (35, -"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\036\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" -), - (38, -"\000\000\000\000\000\000\000\000\000\039\000\000\039\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\039\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" -), - (42, -"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\043\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" -), - (44, -"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\045\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" -), -(0, "")] -fun f x = x -val s = map f (rev (tl (rev s))) -exception LexHackingError -fun look ((j,x)::r, i: int) = if i = j then x else look(r, i) - | look ([], i) = raise LexHackingError -fun g {fin=x, trans=i} = {fin=x, trans=look(s,i)} -in Vector.fromList(map g -[{fin = [], trans = 0}, -{fin = [], trans = 1}, -{fin = [], trans = 1}, -{fin = [], trans = 3}, -{fin = [], trans = 3}, -{fin = [], trans = 5}, -{fin = [], trans = 5}, -{fin = [(N 67)], trans = 0}, -{fin = [(N 8),(N 67)], trans = 0}, -{fin = [(N 6),(N 67)], trans = 0}, -{fin = [(N 54),(N 67)], trans = 10}, -{fin = [(N 54)], trans = 10}, -{fin = [(N 54),(N 67)], trans = 12}, -{fin = [(N 54)], trans = 13}, -{fin = [(N 54)], trans = 14}, -{fin = [(N 54)], trans = 15}, -{fin = [(N 54)], trans = 16}, -{fin = [(N 48),(N 54)], trans = 10}, -{fin = [(N 16),(N 67)], trans = 0}, -{fin = [(N 14),(N 67)], trans = 0}, -{fin = [(N 51),(N 67)], trans = 20}, -{fin = [(N 51)], trans = 20}, -{fin = [(N 39),(N 67)], trans = 22}, -{fin = [(N 28)], trans = 0}, -{fin = [(N 63)], trans = 0}, -{fin = [(N 57)], trans = 0}, -{fin = [(N 35),(N 67)], trans = 26}, -{fin = [(N 22)], trans = 0}, -{fin = [(N 33),(N 67)], trans = 28}, -{fin = [(N 19)], trans = 0}, -{fin = [(N 37),(N 67)], trans = 30}, -{fin = [(N 25)], trans = 0}, -{fin = [(N 60)], trans = 0}, -{fin = [(N 12),(N 67)], trans = 0}, -{fin = [(N 10),(N 67)], trans = 0}, -{fin = [(N 41),(N 67)], trans = 35}, -{fin = [(N 31)], trans = 0}, -{fin = [(N 65),(N 67)], trans = 0}, -{fin = [(N 2),(N 67)], trans = 38}, -{fin = [(N 2)], trans = 38}, -{fin = [(N 4)], trans = 0}, -{fin = [(N 77)], trans = 0}, -{fin = [(N 77)], trans = 42}, -{fin = [(N 70)], trans = 0}, -{fin = [(N 77)], trans = 44}, -{fin = [(N 73)], trans = 0}, -{fin = [(N 75)], trans = 0}, -{fin = [(N 81)], trans = 0}, -{fin = [(N 79)], trans = 0}]) -end -structure StartStates = - struct - datatype yystartstate = STARTSTATE of int - -(* start state definitions *) - -val COMMENT = STARTSTATE 3; -val COMMENT_LINE = STARTSTATE 5; -val INITIAL = STARTSTATE 1; - -end -type result = UserDeclarations.lexresult - exception LexerError (* raised if illegal leaf action tried *) -end - -fun makeLexer yyinput = -let val yygone0=1 - val yyb = ref "\n" (* buffer *) - val yybl = ref 1 (*buffer length *) - val yybufpos = ref 1 (* location of next character to use *) - val yygone = ref yygone0 (* position in file of beginning of buffer *) - val yydone = ref false (* eof found yet? *) - val yybegin = ref 1 (*Current 'start state' for lexer *) - - val YYBEGIN = fn (Internal.StartStates.STARTSTATE x) => - yybegin := x - -fun lex () : Internal.result = -let fun continue() = lex() in - let fun scan (s,AcceptingLeaves : Internal.yyfinstate list list,l,i0) = - let fun action (i,nil) = raise LexError - | action (i,nil::l) = action (i-1,l) - | action (i,(node::acts)::l) = - case node of - Internal.N yyk => - (let fun yymktext() = substring(!yyb,i0,i-i0) - val yypos = i0+ !yygone - open UserDeclarations Internal.StartStates - in (yybufpos := i; case yyk of - - (* Application actions *) - - 10 => let val yytext=yymktext() in Tokens.LPAREN (yypos, yypos + size yytext) end -| 12 => let val yytext=yymktext() in Tokens.RPAREN (yypos, yypos + size yytext) end -| 14 => let val yytext=yymktext() in Tokens.SEMI (yypos, yypos + size yytext) end -| 16 => let val yytext=yymktext() in Tokens.ASSIGN (yypos, yypos + size yytext) end -| 19 => let val yytext=yymktext() in Tokens.PLUSEQ (yypos, yypos + size yytext) end -| 2 => (lex ()) -| 22 => let val yytext=yymktext() in Tokens.MINUSEQ (yypos, yypos + size yytext) end -| 25 => let val yytext=yymktext() in Tokens.STAREQ (yypos, yypos + size yytext) end -| 28 => let val yytext=yymktext() in Tokens.SLASHEQ (yypos, yypos + size yytext) end -| 31 => let val yytext=yymktext() in Tokens.PERCENTEQ (yypos, yypos + size yytext) end -| 33 => let val yytext=yymktext() in Tokens.PLUS (yypos, yypos + size yytext) end -| 35 => let val yytext=yymktext() in Tokens.MINUS (yypos, yypos + size yytext) end -| 37 => let val yytext=yymktext() in Tokens.STAR (yypos, yypos + size yytext) end -| 39 => let val yytext=yymktext() in Tokens.SLASH (yypos, yypos + size yytext) end -| 4 => (ParseState.newline(yypos); lex()) -| 41 => let val yytext=yymktext() in Tokens.PERCENT (yypos, yypos + size yytext) end -| 48 => let val yytext=yymktext() in Tokens.RETURN (yypos, yypos + size yytext) end -| 51 => let val yytext=yymktext() in number (yytext, yypos) end -| 54 => let val yytext=yymktext() in let - val id = Symbol.symbol yytext - in - Tokens.IDENT (id, yypos, yypos + size yytext) - end end -| 57 => (YYBEGIN COMMENT; enterComment yypos; lex()) -| 6 => let val yytext=yymktext() in Tokens.LBRACE (yypos, yypos + size yytext) end -| 60 => (ErrorMsg.error (ParseState.ext (yypos, yypos)) "unbalanced comments"; - lex()) -| 63 => (YYBEGIN COMMENT_LINE; lex()) -| 65 => (YYBEGIN COMMENT_LINE; lex()) -| 67 => let val yytext=yymktext() in ErrorMsg.error (ParseState.ext (yypos,yypos)) - ("illegal character: \"" ^ yytext ^ "\""); - lex () end -| 70 => (enterComment yypos; lex()) -| 73 => (if exitComment () then YYBEGIN INITIAL else (); lex()) -| 75 => (ParseState.newline yypos; lex ()) -| 77 => (lex()) -| 79 => (ParseState.newline yypos; YYBEGIN INITIAL; lex()) -| 8 => let val yytext=yymktext() in Tokens.RBRACE (yypos, yypos + size yytext) end -| 81 => (lex()) -| _ => raise Internal.LexerError - - ) end ) - - val {fin,trans} = Unsafe.Vector.sub(Internal.tab, s) - val NewAcceptingLeaves = fin::AcceptingLeaves - in if l = !yybl then - if trans = #trans(Vector.sub(Internal.tab,0)) - then action(l,NewAcceptingLeaves -) else let val newchars= if !yydone then "" else yyinput 1024 - in if (size newchars)=0 - then (yydone := true; - if (l=i0) then UserDeclarations.eof () - else action(l,NewAcceptingLeaves)) - else (if i0=l then yyb := newchars - else yyb := substring(!yyb,i0,l-i0)^newchars; - yygone := !yygone+i0; - yybl := size (!yyb); - scan (s,AcceptingLeaves,l-i0,0)) - end - else let val NewChar = Char.ord(Unsafe.CharVector.sub(!yyb,l)) - val NewState = Char.ord(Unsafe.CharVector.sub(trans,NewChar)) - in if NewState=0 then action(l,NewAcceptingLeaves) - else scan(NewState,NewAcceptingLeaves,l+1,i0) - end - end -(* - val start= if substring(!yyb,!yybufpos-1,1)="\n" -then !yybegin+1 else !yybegin -*) - in scan(!yybegin (* start *),nil,!yybufpos,!yybufpos) - end -end - in lex - end -end