Browse Source

Arrow replaced by *(e).id in parser

Phyks (Lucas Verney) 5 years ago
parent
commit
6e6645c6a8
25 changed files with 33855 additions and 33918 deletions
  1. 6
    1
      TODO
  2. BIN
      ast.cmi
  3. 0
    3
      ast.mli
  4. BIN
      ast_typing.cmi
  5. BIN
      ast_typing.cmo
  6. 0
    1
      ast_typing.ml
  7. 2519
    2541
      compiler.annot
  8. BIN
      compiler.cmi
  9. BIN
      compiler.cmo
  10. 0
    1
      compiler.ml
  11. BIN
      lexer.cmi
  12. BIN
      lexer.cmo
  13. BIN
      main.cmi
  14. BIN
      main.cmo
  15. BIN
      minic++
  16. 29235
    29219
      parser.annot
  17. BIN
      parser.cmi
  18. BIN
      parser.cmo
  19. 3
    3
      parser.ml
  20. 3
    3
      parser.mly
  21. 1
    0
      test.py
  22. 2088
    2143
      typer.annot
  23. BIN
      typer.cmi
  24. BIN
      typer.cmo
  25. 0
    3
      typer.ml

+ 6
- 1
TODO View File

@@ -1,6 +1,11 @@
1 1
 * Makefile pourri
2 2
 * Typing
3
-    * testfile-incomplete_type-1.cpp
3
+    * bad/subtyping1
4
+    * bad/constructor1
5
+    * bad/extra_qualification1
6
+    * bad/assign4
7
+    * bad/overload1
8
+    * good/subtype2, 3
4 9
 * Fonctions
5 10
     * Surcharge
6 11
 * Classes

BIN
ast.cmi View File


+ 0
- 3
ast.mli View File

@@ -20,12 +20,9 @@ type qvar = Qident of qident | QUTimes of qvar | QEComm of qvar
20 20
 
21 21
 type expr = EInt of int 
22 22
             | EThis
23
-            | EFalse 
24
-            | ETrue 
25 23
             | ENull
26 24
             | EQident of qident 
27 25
             | Dot of expr * ident 
28
-            | Arrow of expr * ident 
29 26
             | Assign of expr * expr
30 27
             | Apply of expr * (expr list)
31 28
             | Instance of tident * (expr list)

BIN
ast_typing.cmi View File


BIN
ast_typing.cmo View File


+ 0
- 1
ast_typing.ml View File

@@ -26,7 +26,6 @@ type at_expr = ATEInt of int
26 26
             | ATENull
27 27
             | ATEQident of at_qident * bool (* Bool is true for locals *)
28 28
             | ATDot of at_expr * at_ident 
29
-            | ATArrow of at_expr * at_ident 
30 29
             | ATAssign of at_expr * at_expr
31 30
             | ATApply of at_ident * ((at_expr*bool)list) (* Bool is true if passed by reference *)
32 31
             | ATInstance of at_tident * (at_expr list)

+ 2519
- 2541
compiler.annot
File diff suppressed because it is too large
View File


BIN
compiler.cmi View File


BIN
compiler.cmo View File


+ 0
- 1
compiler.ml View File

@@ -131,7 +131,6 @@ let rec mips_expr locals = function
131 131
                     ++ lw a0 areg (ofs, a0);
132 132
                 data = nop;
133 133
             }
134
-    | ATArrow (e, ident) -> assert false
135 134
     | ATAssign (ATEQident (ATIdent i, local), e2) ->
136 135
             let mips_for_e2 = mips_expr locals e2 in
137 136
             

BIN
lexer.cmi View File


BIN
lexer.cmo View File


BIN
main.cmi View File


BIN
main.cmo View File


BIN
minic++ View File


+ 29235
- 29219
parser.annot
File diff suppressed because it is too large
View File


BIN
parser.cmi View File


BIN
parser.cmo View File


+ 3
- 3
parser.ml View File

@@ -1493,7 +1493,7 @@ and _menhir_run82 : _menhir_env -> 'ttv_tail * _menhir_state * 'tv_expr * Lexing
1493 1493
         let _startpos = _startpos_x_ in
1494 1494
         let _v : 'tv_expr = 
1495 1495
 # 170 "parser.mly"
1496
-                           ( Arrow (x, y))
1496
+                           ( Dot (UOp(UTimes, x), y))
1497 1497
 # 1498 "parser.ml"
1498 1498
          in
1499 1499
         _menhir_goto_expr _menhir_env _menhir_stack _menhir_s _v _startpos) : 'freshtv880)) : 'freshtv882)
@@ -3742,7 +3742,7 @@ and _menhir_run59 : _menhir_env -> 'ttv_tail -> _menhir_state -> Lexing.position
3742 3742
     ((let _startpos = _startpos__1_ in
3743 3743
     let _v : 'tv_expr = 
3744 3744
 # 164 "parser.mly"
3745
-           ( ETrue )
3745
+           ( EInt 1 )
3746 3746
 # 3747 "parser.ml"
3747 3747
      in
3748 3748
     _menhir_goto_expr _menhir_env _menhir_stack _menhir_s _v _startpos) : 'freshtv582)
@@ -4297,7 +4297,7 @@ and _menhir_run72 : _menhir_env -> 'ttv_tail -> _menhir_state -> Lexing.position
4297 4297
     ((let _startpos = _startpos__1_ in
4298 4298
     let _v : 'tv_expr = 
4299 4299
 # 163 "parser.mly"
4300
-            ( EFalse )
4300
+            ( EInt 0 )
4301 4301
 # 4302 "parser.ml"
4302 4302
      in
4303 4303
     _menhir_goto_expr _menhir_env _menhir_stack _menhir_s _v _startpos) : 'freshtv536)

+ 3
- 3
parser.mly View File

@@ -160,14 +160,14 @@ qident:
160 160
 expr:
161 161
     x=INT { EInt x }
162 162
     | THIS { EThis }
163
-    | FALSE { EFalse }
164
-    | TRUE { ETrue }
163
+    | FALSE { EInt 0 }
164
+    | TRUE { EInt 1 }
165 165
     | NULL { ENull }
166 166
     | x=qident { EQident x }
167 167
     | TIMES x=expr { UOp (UTimes, x) } %prec UTIMES
168 168
     | x=expr y=paren(separated_list(COMMA, expr)) { Apply (x, y) }
169 169
     | x=expr DOT y=IDENT { Dot (x, y) }
170
-    | x=expr ARROW y=IDENT { Arrow (x, y)}
170
+    | x=expr ARROW y=IDENT { Dot (UOp(UTimes, x), y)}
171 171
     | x=expr ASSIGN y=expr { Assign (x, y) }
172 172
     | NEW t=TIDENT x=paren(separated_list(COMMA, expr))
173 173
         { 

+ 1
- 0
test.py View File

@@ -15,6 +15,7 @@ files = [i for i in os.listdir(sys.argv[1]) if i.endswith(".cpp")]
15 15
 
16 16
 for i in files:
17 17
     try:
18
+        print(i)
18 19
         subprocess.check_call(["./minic++",
19 20
                                "--type-only",
20 21
                                sys.argv[1]+"/"+i],

+ 2088
- 2143
typer.annot
File diff suppressed because it is too large
View File


BIN
typer.cmi View File


BIN
typer.cmo View File


+ 0
- 3
typer.ml View File

@@ -211,8 +211,6 @@ let rec type_expr pos locals = function
211 211
             else
212 212
                 raise (Error ("Operand must be int.", pos))
213 213
     | Incr (incr, expr) -> raise (Error ("Valeur gauche attendue.", pos))
214
-    | ETrue -> ATEInt 1, ATInt
215
-    | EFalse -> ATEInt 0, ATInt
216 214
     | ENull -> ATEInt 0, ATNull
217 215
     | Apply (e, le) -> begin
218 216
         let tmp = type_expr pos locals e in
@@ -265,7 +263,6 @@ let rec type_expr pos locals = function
265 263
                     raise (Error ("No field "^id^" in object "^decl_class.name, pos))
266 264
         | _ -> raise (Error ("Not an instance of a class.", pos))
267 265
     end
268
-    | Arrow _ -> assert false (* TODO *)
269 266
     | Instance _ -> assert false (* TODO *)
270 267
     | EThis -> assert false (* TODO *)
271 268