diff --git a/bootstrap/typecheck.cc b/bootstrap/typecheck.cc index 8d2c689..902cf5c 100644 --- a/bootstrap/typecheck.cc +++ b/bootstrap/typecheck.cc @@ -6,9 +6,9 @@ namespace xlang { std::string typeToString(Type type) { switch (type) { case Type::Integer: - return "int"; + return "Int"; case Type::Boolean: - return "bool"; + return "Bool"; default: case Type::Invalid: return ""; diff --git a/bootstrap/xlang.g4 b/bootstrap/xlang.g4 index 8cb414c..875097c 100644 --- a/bootstrap/xlang.g4 +++ b/bootstrap/xlang.g4 @@ -42,8 +42,8 @@ factor : Minus factor ; argumentList : expr (Comma expr)*; -TypeInteger : 'int'; -TypeBoolean : 'bool'; +TypeInteger : 'Int'; +TypeBoolean : 'Bool'; If : 'if'; Else : 'else'; While : 'while'; @@ -88,7 +88,7 @@ Decrement : '=-'; Comma : ','; Semicolon : ';'; -Identifier : [_a-zA-Z][_a-zA-Z0-9]*; +Identifier : [a-z][_a-zA-Z0-9]*; Integer : [0-9]+; Comment : '//' ~[\n]* '\n' -> skip; diff --git a/test/42.x b/test/42.x index cd4223d..57a8850 100644 --- a/test/42.x +++ b/test/42.x @@ -1,3 +1,3 @@ -main() : int { +main() : Int { print 42; } diff --git a/test/fib.x b/test/fib.x index 9222d17..6d8cd20 100644 --- a/test/fib.x +++ b/test/fib.x @@ -1,18 +1,18 @@ -main() : int { +main() : Int { for i := 0; i < 10; i =+ 1 { print fib_rec(i); print fib_iter(i); } } -fib_rec(n : int) : int { +fib_rec(n : Int) : Int { if n < 2 { return 1; } return fib_rec(n - 1) + fib_rec(n - 2); } -fib_iter(n : int) : int { +fib_iter(n : Int) : Int { x0 := 1; x1 := 1; for i := 0; i < n; i =+ 1 { diff --git a/test/sieve.x b/test/sieve.x index a7a6080..1fb7396 100644 --- a/test/sieve.x +++ b/test/sieve.x @@ -1,4 +1,4 @@ -main() : int { +main() : Int { print 2; for i := 3; i < 100; i =+ 2 { for j := 3; j < i; j =+ 2 {