Skip to content

Commit 5015b37

Browse files
authored
Merge pull request #76 from krperry/master
Fixed readme and variables.
2 parents ddc37cb + 15f74e1 commit 5015b37

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ are all invalid.
220220

221221
Numeric variables have no suffix, whereas string variables are always suffixed by '$'. Note that 'I' and 'I$' are
222222
considered to be separate variables. Note that string literals must always be enclosed within double quotes (not single quotes).
223-
Using no quotes will result in a syntax error. In addition, for floating point numbers less than one (e.g. 0.67), the decimal point must always be prefixed by a zero (e.g. .67 will be flagged as a syntax error).
223+
Using no quotes will result in a syntax error.
224224

225225
Array variables are defined using the **DIM** statement, which explicitly lists how
226226
many dimensions the array has, and the sizes of those dimensions:

basicparser.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,9 +1025,14 @@ def __factor(self):
10251025
self.__operand_stack.append(self.__sign*self.__symbol_table[self.__token.lexeme])
10261026

10271027
else:
1028-
raise RuntimeError('Name ' + self.__token.lexeme + ' is not defined' +
1029-
' in line ' + str(self.__line_number))
1030-
1028+
# default variables values for undefined variables.
1029+
if self.__token.lexeme.endswith ("$"):
1030+
# default string
1031+
self.__operand_stack.append("")
1032+
else:
1033+
#default int
1034+
self.__operand_stack.append(0)
1035+
10311036
self.__advance()
10321037

10331038
elif self.__token.category == Token.LEFTPAREN:

0 commit comments

Comments
 (0)