From 6d25b4f3fc23601b3a84b4a70aab40ba429ac4b9 Mon Sep 17 00:00:00 2001 From: xleroy Date: Tue, 30 Dec 2008 14:48:33 +0000 Subject: Reorganized the development, modularizing away machine-dependent parts. Started to merge the ARM code generator. Started to add support for PowerPC/EABI. Use ocamlbuild to construct executable from Caml files. git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@930 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e --- backend/CMlexer.mll | 132 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 backend/CMlexer.mll (limited to 'backend/CMlexer.mll') diff --git a/backend/CMlexer.mll b/backend/CMlexer.mll new file mode 100644 index 0000000..9854117 --- /dev/null +++ b/backend/CMlexer.mll @@ -0,0 +1,132 @@ +(* *********************************************************************) +(* *) +(* The Compcert verified compiler *) +(* *) +(* Xavier Leroy, INRIA Paris-Rocquencourt *) +(* *) +(* Copyright Institut National de Recherche en Informatique et en *) +(* Automatique. All rights reserved. This file is distributed *) +(* under the terms of the GNU General Public License as published by *) +(* the Free Software Foundation, either version 2 of the License, or *) +(* (at your option) any later version. This file is also distributed *) +(* under the terms of the INRIA Non-Commercial License Agreement. *) +(* *) +(* *********************************************************************) + +{ +open Camlcoq +open CMparser +exception Error of string +} + +let blank = [' ' '\009' '\012' '\010' '\013'] +let floatlit = + ['0'-'9'] ['0'-'9' '_']* + ('.' ['0'-'9' '_']* )? + (['e' 'E'] ['+' '-']? ['0'-'9'] ['0'-'9' '_']*)? +let ident = ['A'-'Z' 'a'-'z' '_'] ['A'-'Z' 'a'-'z' '_' '0'-'9']* +let intlit = "-"? ( ['0'-'9']+ | "0x" ['0'-'9' 'a'-'f' 'A'-'F']+ + | "0o" ['0'-'7']+ | "0b" ['0'-'1']+ ) +let stringlit = "\"" [ ^ '"' ] * '"' + +rule token = parse + | blank + { token lexbuf } + | "/*" { comment lexbuf; token lexbuf } + | "absf" { ABSF } + | "alloc" { ALLOC } + | "&" { AMPERSAND } + | "&&" { AMPERSANDAMPERSAND } + | "!" { BANG } + | "!=" { BANGEQUAL } + | "!=f" { BANGEQUALF } + | "!=u" { BANGEQUALU } + | "|" { BAR } + | "||" { BARBAR } + | "^" { CARET } + | "case" { CASE } + | ":" { COLON } + | "," { COMMA } + | "default" { DEFAULT } + | "$" { DOLLAR } + | "else" { ELSE } + | "=" { EQUAL } + | "==" { EQUALEQUAL } + | "==f" { EQUALEQUALF } + | "==u" { EQUALEQUALU } + | "exit" { EXIT } + | "extern" { EXTERN } + | "float" { FLOAT } + | "float32" { FLOAT32 } + | "float64" { FLOAT64 } + | "floatofint" { FLOATOFINT } + | "floatofintu" { FLOATOFINTU } + | ">" { GREATER } + | ">f" { GREATERF } + | ">u" { GREATERU } + | ">=" { GREATEREQUAL } + | ">=f" { GREATEREQUALF } + | ">=u" { GREATEREQUALU } + | ">>" { GREATERGREATER } + | ">>u" { GREATERGREATERU } + | "if" { IF } + | "in" { IN } + | "int" { INT } + | "int16s" { INT16S } + | "int16u" { INT16U } + | "int32" { INT32 } + | "int8s" { INT8S } + | "int8u" { INT8U } + | "intoffloat" { INTOFFLOAT } + | "intuoffloat" { INTUOFFLOAT } + | "{" { LBRACE } + | "{{" { LBRACELBRACE } + | "[" { LBRACKET } + | "<" { LESS } + | "" { MINUSGREATER } + | "-f" { MINUSF } + | "%" { PERCENT } + | "%u" { PERCENTU } + | "+" { PLUS } + | "+f" { PLUSF } + | "?" { QUESTION } + | "}" { RBRACE } + | "}}" { RBRACERBRACE } + | "]" { RBRACKET } + | "return" { RETURN } + | ")" { RPAREN } + | ";" { SEMICOLON } + | "/" { SLASH } + | "/f" { SLASHF } + | "/u" { SLASHU } + | "stack" { STACK } + | "*" { STAR } + | "*f" { STARF } + | "switch" { SWITCH } + | "tailcall" { TAILCALL } + | "~" { TILDE } + | "var" { VAR } + | "void" { VOID } + + | intlit { INTLIT(Int32.of_string(Lexing.lexeme lexbuf)) } + | floatlit { FLOATLIT(float_of_string(Lexing.lexeme lexbuf)) } + | stringlit { let s = Lexing.lexeme lexbuf in + STRINGLIT(intern_string(String.sub s 1 (String.length s - 2))) } + | ident { IDENT(intern_string(Lexing.lexeme lexbuf)) } + | eof { EOF } + | _ { raise(Error("illegal character `" ^ Char.escaped (Lexing.lexeme_char lexbuf 0) ^ "'")) } + +and comment = parse + "*/" { () } + | eof { raise(Error "unterminated comment") } + | _ { comment lexbuf } -- cgit v1.2.3