diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main.ml | 8 | ||||
-rw-r--r-- | src/parser.mly | 11 | ||||
-rw-r--r-- | src/pretty_typing.ml | 60 | ||||
-rwxr-xr-x | src/test.sh | 8 | ||||
-rw-r--r-- | src/typing.ml | 7 |
5 files changed, 16 insertions, 78 deletions
diff --git a/src/main.ml b/src/main.ml index 9fb4e46..35bd6e0 100644 --- a/src/main.ml +++ b/src/main.ml @@ -47,11 +47,13 @@ let () = try let p = Parser.prog Lexer.token buf in - let t = Typing.prog p in close_in f; if !dump then Pretty.print_prog p; - if !dumpt then Pretty_typing.print_prog t; + if not !parse_only then begin + let t = Typing.prog p in + if !dumpt then Pretty_typing.print_prog t; + end with | Lexer.Lexing_error s -> localisation (Lexing.lexeme_start_p buf); @@ -63,7 +65,7 @@ let () = exit 1 | Typing.Error (loc, msg) -> localisation2 loc; - eprintf "%s" msg; + eprintf "%s@." msg; exit 1 | _ -> diff --git a/src/parser.mly b/src/parser.mly index 39fdf7d..a079886 100644 --- a/src/parser.mly +++ b/src/parser.mly @@ -109,12 +109,13 @@ member: ; cls_proto: -| ident = typed_var +| ident = typed_qvar LPAREN args = separated_list(COMMA, typed_var) RPAREN - { { - p_ret_type = Some(fst ident); - p_name = snd ident; - p_class = None; + { + let (vt, vc, vn) = ident in { + p_ret_type = Some(vt); + p_name = vn; + p_class = vc; p_args = args; p_loc = $startpos, $endpos } } | cls = TIDENT diff --git a/src/pretty_typing.ml b/src/pretty_typing.ml index 371b210..709611b 100644 --- a/src/pretty_typing.ml +++ b/src/pretty_typing.ml @@ -9,66 +9,6 @@ open Parser open Typing open Ast -let token_str = function - | CLASS -> "class" - | ELSE -> "else" - | FALSE -> "false" - | FOR -> "for" - | IF -> "if" - | INT -> "int" - | NEW -> "new" - | NULL -> "NULL" - | PUBLIC -> "public" - | RETURN -> "return" - | THIS -> "this" - | TRUE -> "true" - | VIRTUAL -> "virtual" - | VOID -> "void" - | WHILE -> "while" - | IDENT(s) -> "'"^s^"'" - | TIDENT(s) -> "\""^s^"\"" - | ASSIGN -> "=" - | LOR -> "||" - | LAND -> "&&" - | EQ -> "==" - | NE -> "!=" - | LT -> "<" - | LE -> "<=" - | GT -> ">" - | GE -> ">=" - | PLUS -> "+" - | MINUS -> "-" - | TIMES -> "*" - | DIV -> "/" - | MOD -> "%" - | NOT -> "!" - | INCR -> "++" - | DECR -> "--" - | REF -> "&" - (* and also : unary dereference, plus, minus *) - | LPAREN -> "(" - | RPAREN -> ")" - | RARROW -> "->" - | DOT -> "." - (* OTHER SYMBOLZ *) - | SEMICOLON -> ";" - | DOUBLECOLON -> "::" - | LFLOW -> "<<" - | LBRACE -> "{" - | RBRACE -> "}" - | COMMA -> "," - | COLON -> ":" - (* DATAZ *) - | INTVAL(i) -> "#" ^ (string_of_int i) - | STRVAL(s) -> "`" ^ s ^ "`" - (* STUPIDITIEZS *) - | STD_COUT -> "std::cout" - | INCLUDE_IOSTREAM -> "#include <iostream>" - | EOF -> "end." - -let print_tok t = - print_string ((token_str t) ^ "\n") - let csl f l = List.fold_left (fun x t -> (if x = "" then "" else x ^ ", ") ^ (f t)) "" l diff --git a/src/test.sh b/src/test.sh index fc241bf..603b404 100755 --- a/src/test.sh +++ b/src/test.sh @@ -4,14 +4,14 @@ echo "Testing SYNTAX/" for a in ../tests/syntax/good/*.cpp; do - if ./main.byte -parse-only $a; + if ./main.byte --parse-only $a; then echo "OK $a"; else echo "FAIL $a"; fi; done; for a in ../tests/syntax/bad/*.cpp; do - if ./main.byte -parse-only $a 2> /dev/null; + if ./main.byte --parse-only $a 2> /dev/null; then echo "FAIL $a"; else echo "OK $a"; fi; @@ -20,7 +20,7 @@ done; echo "---" echo "Testing TYPING/ only against parsing" for a in ../tests/typing/*/*.cpp; do - if ./main.byte -parse-only $a; + if ./main.byte --parse-only $a; then echo "OK $a"; else echo "FAIL $a"; fi; @@ -29,7 +29,7 @@ done; echo "---" echo "Testing EXEC/ only against parsing" for a in ../tests/exec/*.cpp; do - if ./main.byte -parse-only $a; + if ./main.byte --parse-only $a; then echo "OK $a"; else echo "FAIL $a"; fi; diff --git a/src/typing.ml b/src/typing.ml index 1a5e566..4d5b0c2 100644 --- a/src/typing.ml +++ b/src/typing.ml @@ -29,7 +29,7 @@ and texpr_desc = | TEIdent of ident | TEAssign of texpression * texpression | TECallFun of ident * texpression list (* changé : te -> ident *) -(* | TECallMeth of texpression * ident * texpression list *) (* changé : te -> ident *) +(* | TECallMethod of texpression * ident * texpression list *) (* changé : te -> ident *) | TEUnary of unop * texpression | TEBinary of texpression * binop * texpression | TEMember of texpression * ident @@ -67,11 +67,6 @@ and ts_desc = | TSWriteCout of tstr_expression list and tblock = tstatement list -(*and fun_type = { - f_args : type_ref list; - f_block : tblock; } -peut être effacé *) - and tproto = { tp_loc : loc; tp_name : ident; |