Skip to content

Commit 23e3351

Browse files
committed
Revert "make assign expression"
This reverts commit 75bc86e.
1 parent 0cb4034 commit 23e3351

File tree

4 files changed

+21
-32
lines changed

4 files changed

+21
-32
lines changed

lib/ast.ml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@ type token =
2121
(* unknown *)
2222
| KWD of char
2323
(* special chars *)
24-
| EQUALS
25-
| ASSIGN
2624
| LEFT_PAREN
2725
| RIGHT_PAREN
26+
| EQUALS
2827
| COMMA
2928
| SEMICOLON
3029
(* end of file *)

lib/ast.mli

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,24 @@
11
open Core
22

33
type token =
4-
(* commands *)
54
| DEF
65
| EXTERN
7-
(* control *)
86
| IF
97
| THEN
108
| ELSE
119
| FOR
1210
| IN
13-
(* operators *)
1411
| BINARY
1512
| UNARY
16-
(* var definition *)
1713
| VAR
18-
(* primary *)
1914
| IDENT of string
2015
| NUMBER of float
21-
(* unknown *)
2216
| KWD of char
23-
(* special chars *)
24-
| EQUALS
25-
| ASSIGN
2617
| LEFT_PAREN
2718
| RIGHT_PAREN
19+
| EQUALS
2820
| COMMA
2921
| SEMICOLON
30-
(* end of file *)
3122
| EOF
3223
[@@deriving sexp]
3324

lib/lexer.mll

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,25 @@
1616
| newline { read lexbuf }
1717
| "def" { DEF }
1818
| "extern" { EXTERN }
19-
| "if" { IF }
20-
| "then" { THEN }
21-
| "else" { ELSE }
22-
| "for" { FOR }
23-
| "in" { IN }
24-
| "binary" { BINARY }
25-
| "unary" { UNARY }
26-
| "var" { VAR }
27-
| id { IDENT (Lexing.lexeme lexbuf) }
28-
| float { NUMBER (float_of_string (Lexing.lexeme lexbuf)) }
29-
| ":=" { ASSIGN }
30-
| "(" { LEFT_PAREN }
31-
| ")" { RIGHT_PAREN }
32-
| "," { COMMA }
33-
| ";" { SEMICOLON }
19+
| "if" { IF }
20+
| "then" { THEN }
21+
| "else" { ELSE }
22+
| "for" { FOR }
23+
| "in" { IN }
24+
| "binary" { BINARY }
25+
| "unary" { UNARY }
26+
| "var" { VAR }
27+
| id { IDENT (Lexing.lexeme lexbuf) }
28+
| float { NUMBER (float_of_string (Lexing.lexeme lexbuf)) }
29+
| "=" { EQUALS }
30+
| "(" { LEFT_PAREN }
31+
| ")" { RIGHT_PAREN }
32+
| "," { COMMA }
33+
| ";" { SEMICOLON }
3434
(* '#' marks the beginning of a comment *)
3535
| "#" { read_comment lexbuf }
36-
| _ { KWD (Lexing.lexeme_char lexbuf 0) }
37-
| eof { EOF }
36+
| _ { KWD (Lexing.lexeme_char lexbuf 0) }
37+
| eof { EOF }
3838

3939
and read_comment =
4040
parse

lib/parser.mly

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
%token <float> NUMBER
1313
%token <char> KWD
1414
%token EQUALS
15-
%token ASSIGN
1615
%token LEFT_PAREN
1716
%token RIGHT_PAREN
1817
%token COMMA
@@ -29,7 +28,7 @@
2928
| Some p -> p
3029
%}
3130

32-
%start < [ `Expr of Ast.Expr.No_binop.func
31+
%start < [`Expr of Ast.Expr.No_binop.func
3332
| `Extern of Ast.proto
3433
| `Def of Ast.Expr.No_binop.func
3534
| `Eof ]> toplevel
@@ -76,7 +75,7 @@ block:
7675

7776
(* var
7877
* ::= 'var' identifier ('=' expression)? *)
79-
var: name = IDENT; e = option(ASSIGN; e = expr { e }) { (name, e) }
78+
var: name = IDENT; e = option(EQUALS; e = expr { e }) { (name, e) }
8079

8180
(* unary
8281
* ::= primary

0 commit comments

Comments
 (0)