X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Flexer.mll;h=8f56d5b51ea238fd9d8c0e10b86a273e800c9380;hb=70a08a62b9312ed1bbcb7c89d47f9a25fa221e34;hp=a9b11d1047eaeb12ef82758f801cbff517efef2a;hpb=b14ff66c953e6a73e9ac2fe8d42dd68e92e58f53;p=goals.git diff --git a/src/lexer.mll b/src/lexer.mll index a9b11d1..8f56d5b 100644 --- a/src/lexer.mll +++ b/src/lexer.mll @@ -28,13 +28,13 @@ exception SyntaxError of string let new_line lexbuf = let pos = lexbuf.lex_curr_p in lexbuf.lex_curr_p <- - { pos with pos_bol = lexbuf.lex_curr_pos; pos_lnum = pos.pos_lnum + 1 } + { pos with pos_bol = pos.pos_cnum; pos_lnum = pos.pos_lnum + 1 } } let white = [' ' '\t']+ let newline = '\r' | '\n' | "\r\n" let comment = '#' (_#'\n')* -let id = ['a'-'z' 'A'-'Z' '_'] ['a'-'z' 'A'-'Z' '0'-'9' '_']* +let id = ['a'-'z' 'A'-'Z' '_'] ['a'-'z' 'A'-'Z' '0'-'9' '_' '-']* rule read = parse @@ -43,6 +43,7 @@ rule read = | newline { new_line lexbuf; read lexbuf } | "," { COMMA } | ":" { COLON } + | ";" { SEMICOLON } | "=" { EQUALS } | "(" { LEFT_PAREN } | ")" { RIGHT_PAREN } @@ -51,10 +52,25 @@ rule read = | '"' { read_string (Ast.Substs.create ()) lexbuf } | "{" { read_code (Ast.Substs.create ()) (ref 1) lexbuf } | "goal" { GOAL } + | "tactic" + { TACTIC_KEYWORD } + | "function" + { FUNCTION } | "let" { LET } - | "*" id { let id = Lexing.lexeme lexbuf in - let len = String.length id in - TACTIC (String.sub id 1 (len-1)) } + | "include" + { INCLUDE } + | "-include" + { OPTINCLUDE } + | "returning" + { RETURNING } + | "expression" + { EXPRESSION } + | "string" + { STRING_KEYWORD } + | "strings" + { STRINGS } + | "*" id { (* NB: The initial '*' is part of the name. *) + TACTIC (Lexing.lexeme lexbuf) } | id { ID (Lexing.lexeme lexbuf) } | _ { raise (SyntaxError ("unexpected character: " ^ Lexing.lexeme lexbuf)) } @@ -105,7 +121,8 @@ and read_string buf = *) and read_code buf level = parse - | '{' { incr level; read_code buf level lexbuf } + | '{' { Ast.Substs.add_char buf '{'; + incr level; read_code buf level lexbuf } | '}' { decr level; if !level = 0 then CODE (Ast.Substs.get buf) else (