uppercase typenames, lowercase identifiers

development
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) {
switch (type) {
case Type::Integer:
return "int";
return "Int";
case Type::Boolean:
return "bool";
return "Bool";
default:
case Type::Invalid:
return "<invalid>";

View File

@ -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;

View File

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

View File

@ -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 {

View File

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