remoo69 / Compiler-Sheesh

Compiler for the self-developed language Sheesh#.
MIT License
2 stars 1 forks source link

semantic issue with end value in for-to loop #54

Closed jldav1d closed 1 week ago

jldav1d commented 1 week ago

Expected: No Semantic Errors Actual: Parsing Error

Code:

sheesh(){
    for (i = 0 to (-5) step 1) {
          up("Hello")#
}

Error Message:

Traceback (most recent call last):
  File "C:\Python312\Lib\tkinter\__init__.py", line 1948, in __call__
    return self.func(*args)
           ^^^^^^^^^^^^^^^^
  File "C:\Users\David\Downloads\sheesh#\Compiler-Sheesh\Sheesh# Compiler.py", line 125, in run_parser
    tokens, error = lex.Lexer.tokenize(code)
                    ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\David\Downloads\sheesh#\Compiler-Sheesh\source\LexicalAnalyzer\Lexer.py", line 142, in tokenize
    lexemes, error = Lexer.gettokens(line)
                     ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\David\Downloads\sheesh#\Compiler-Sheesh\source\LexicalAnalyzer\Lexer.py", line 98, in gettokens
    token = symb.Token(value=current_token, type=category, line=symb.Token.line_num, position=symb.Token.tok_num, numerical_value=float(current_token))
                                                                                                                                  ^^^^^^^^^^^^^^^^^^^^
ValueError: could not convert string to float: '(-5)'
remoo69 commented 1 week ago

fixed

image