diff options
author | Alex AUVOLAT <alex.auvolat@ens.fr> | 2013-11-14 17:58:57 +0100 |
---|---|---|
committer | Alex AUVOLAT <alex.auvolat@ens.fr> | 2013-11-14 17:58:57 +0100 |
commit | 5dacc48b53568f673b03de794a9a13f7a5c11b0f (patch) | |
tree | 6040bbc45a0ee0ede2af63377c0df43920650b1a /src/lexer.mll | |
parent | d9fab442401005b49b9221b9d897501fef9a4d8d (diff) | |
download | LPC-Projet-5dacc48b53568f673b03de794a9a13f7a5c11b0f.tar.gz LPC-Projet-5dacc48b53568f673b03de794a9a13f7a5c11b0f.zip |
Imported MIPS ASM definitions and more docs.
Diffstat (limited to 'src/lexer.mll')
-rw-r--r-- | src/lexer.mll | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/lexer.mll b/src/lexer.mll index f2f47ef..7daa65c 100644 --- a/src/lexer.mll +++ b/src/lexer.mll @@ -36,6 +36,11 @@ if Sset.mem (!type_names) s then TIDENT s else IDENT s + + let newline lexbuf = + let pos = lexbuf.lex_curr_p in + lexbuf.lex_curr_p <- + { pos with pos_lnum = pos.pos_lnum + 1; pos_bol = pos.pos_cnum } } let digit = ['0'-'9'] @@ -45,11 +50,13 @@ let octal = ['0'-'7'] let hexa = ['0'-'9' 'a'-'f' 'A'-'F'] rule token = parse - | ['\n' ' ' '\t']+ { token lexbuf } + | [' ' '\t']+ { token lexbuf } + | '\n' { newline lexbuf; token lexbuf } | ident as id { id_or_kwd id } | "//" { short_comment lexbuf; token lexbuf } | "/*" { long_comment lexbuf; token lexbuf } | "#include <iostream>" { INCLUDE_IOSTREAM } + | "std::cout" { STD_COUT } | "0x" (hexa+ as n) { INTVAL(int_of_string("0x" ^ n)) } | ['1'-'9'] digit* as n { INTVAL(int_of_string(n)) } | '0' (octal+ as n) { INTVAL(int_of_string("0o" ^ n)) } @@ -81,6 +88,7 @@ rule token = parse | "." { DOT } | ";" { SEMICOLON } | "::" { DOUBLECOLON } + | ":" { COLON } | "<<" { LFLOW } | "{" { LBRACE } | "}" { RBRACE } |