uppercase typenames, lowercase identifiers

This commit is contained in:
Thomas Lindner 2023-01-13 00:09:14 +01:00
parent 3f3f323898
commit fb3de57c08
5 changed files with 10 additions and 10 deletions

View file

@ -6,9 +6,9 @@ namespace xlang {
std::string typeToString(Type type) { std::string typeToString(Type type) {
switch (type) { switch (type) {
case Type::Integer: case Type::Integer:
return "int"; return "Int";
case Type::Boolean: case Type::Boolean:
return "bool"; return "Bool";
default: default:
case Type::Invalid: case Type::Invalid:
return "<invalid>"; return "<invalid>";

View file

@ -42,8 +42,8 @@ factor : Minus factor
; ;
argumentList : expr (Comma expr)*; argumentList : expr (Comma expr)*;
TypeInteger : 'int'; TypeInteger : 'Int';
TypeBoolean : 'bool'; TypeBoolean : 'Bool';
If : 'if'; If : 'if';
Else : 'else'; Else : 'else';
While : 'while'; While : 'while';
@ -88,7 +88,7 @@ Decrement : '=-';
Comma : ','; Comma : ',';
Semicolon : ';'; Semicolon : ';';
Identifier : [_a-zA-Z][_a-zA-Z0-9]*; Identifier : [a-z][_a-zA-Z0-9]*;
Integer : [0-9]+; Integer : [0-9]+;
Comment : '//' ~[\n]* '\n' -> skip; Comment : '//' ~[\n]* '\n' -> skip;

View file

@ -1,3 +1,3 @@
main() : int { main() : Int {
print 42; print 42;
} }

View file

@ -1,18 +1,18 @@
main() : int { main() : Int {
for i := 0; i < 10; i =+ 1 { for i := 0; i < 10; i =+ 1 {
print fib_rec(i); print fib_rec(i);
print fib_iter(i); print fib_iter(i);
} }
} }
fib_rec(n : int) : int { fib_rec(n : Int) : Int {
if n < 2 { if n < 2 {
return 1; return 1;
} }
return fib_rec(n - 1) + fib_rec(n - 2); return fib_rec(n - 1) + fib_rec(n - 2);
} }
fib_iter(n : int) : int { fib_iter(n : Int) : Int {
x0 := 1; x0 := 1;
x1 := 1; x1 := 1;
for i := 0; i < n; i =+ 1 { for i := 0; i < n; i =+ 1 {

View file

@ -1,4 +1,4 @@
main() : int { main() : Int {
print 2; print 2;
for i := 3; i < 100; i =+ 2 { for i := 3; i < 100; i =+ 2 {
for j := 3; j < i; j =+ 2 { for j := 3; j < i; j =+ 2 {