Skip to content

Commit 464662d

Browse files
committed
Fix syntax of calculator.dana
Fixed various lexical and syntax errors found in the program.
1 parent 1428f98 commit 464662d

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

dana/programs/calculator.dana

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def main
99
if c = '+' or c = '-' or c = '*' or c = '/':
1010
return: true
1111
else:
12-
return false
12+
return: false
1313

1414
(*
1515
Conversion from part of a string to an int
@@ -44,7 +44,7 @@ def main
4444
*)
4545

4646
var buf is byte[256]
47-
var idx len start end a b is int
47+
var idx len start p_end a b is int
4848
var op is byte
4949

5050
loop lines:
@@ -57,27 +57,27 @@ def main
5757
idx := 0
5858

5959
loop a_start:
60-
if idx == len:
60+
if idx = len:
6161
writeString: "Invalid\n"
6262
continue: lines
6363
elif is_number(buf[idx]):
6464
break: a_start
6565
idx := idx + 1
66-
start := idx;
66+
start := idx
6767

6868
loop a_end:
69-
if idx == len:
69+
if idx = len:
7070
writeString: "Invalid\n"
7171
continue: lines
7272
elif not is_number(buf[idx]):
7373
break: a_end
7474
idx := idx + 1
75-
end := idx;
75+
p_end := idx
7676

77-
a := string_to_int(buff, start, end);
77+
a := string_to_int(buff, start, p_end)
7878

7979
loop op_detect:
80-
if idx == len:
80+
if idx = len:
8181
writeString: "Invalid\n"
8282
continue: lines
8383
elif is_operator(buf[idx]):
@@ -86,21 +86,21 @@ def main
8686
op := buf[idx]
8787

8888
loop b_start:
89-
if idx == len:
89+
if idx = len:
9090
writeString: "Invalid\n"
9191
continue: lines
9292
elif is_number(buf[idx]):
9393
break: b_start
9494
idx := idx + 1
95-
start := idx;
95+
start := idx
9696

9797
loop b_end:
98-
if idx == len or not is_number(buf[idx]):
98+
if idx = len or not is_number(buf[idx]):
9999
break: b_end
100100
idx := idx + 1
101-
end := idx;
101+
p_end := idx
102102

103-
b := string_to_int(buff, start, end);
103+
b := string_to_int(buff, start, p_end)
104104

105105
# We have finished parsing now we can calculate
106106

0 commit comments

Comments
 (0)