X-Git-Url: https://git.kianting.info/?a=blobdiff_plain;f=ocaml_yacc%2Flexer.mll;fp=ocaml_yacc%2Flexer.mll;h=a134e2ee9633ffa107ea23b590ec766f7180bbf3;hb=1ea8dfd99517fdfe98c81aa206ad2615c1113426;hp=0000000000000000000000000000000000000000;hpb=c2cab771be8b40c091556c7df314b6a5abbe366e;p=uann diff --git a/ocaml_yacc/lexer.mll b/ocaml_yacc/lexer.mll new file mode 100644 index 0000000..a134e2e --- /dev/null +++ b/ocaml_yacc/lexer.mll @@ -0,0 +1,22 @@ +(* File lexer.mll *) +{ +open Parser(* The type token is defined in parser.mli *) +exception Eof +} +rule token = parse + [' ' '\t'] { token lexbuf } (* skip blanks *) + | ['\n' ]{ EOL } + | ['i']['n'] { IN } + | ('_'|['a'-'z']|['A'-'Z']) as lxm { ID((String.make 1 lxm)) } + | ('_'|['a'-'z']|['A'-'Z'])(['0'-'9']|'_'|['a'-'z']|['A'-'Z'])+ as lxm { ID(lxm) } + | ['0'-'9']+ as lxm { INT(lxm) } + | '+' { PLUS } + | '-' { MINUS } + | '*' { TIMES } + | '/' { DIV } + | '(' { LPAREN } + | ')' { RPAREN } + | ['-']['>'] { IMPLY } + | ['=']['>'] { FUNC } + | '=' { ASSIGN } + | eof { raise Eof }