Skip to content

Commit

Permalink
fixed printing string variable
Browse files Browse the repository at this point in the history
  • Loading branch information
mrredo committed Apr 9, 2023
1 parent 36b9f98 commit 738b382
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
16 changes: 15 additions & 1 deletion lexer/lexerFunction.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,21 @@ func ParseFunctionCall(curT Token, sec Token, lexer *Lexer) (string, []interface
if tok.Type == RPAREN {
break
}
if tok.Type == STRING {
if tok.Type == IDENTIFIER {
o, err := ParseExpression(tok, lexer)
if err != nil {
return "", nil, err
}
oo, ok := o.(string)
if ok {
args = append(args, oo)
// tok = lexer.NextToken()
continue
}

}
if tok.Type == STRING {

args = append(args, tok.Value[1:len(tok.Value)-1])

tok = lexer.NextToken()
Expand Down
6 changes: 3 additions & 3 deletions lexer/lexerVariable.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ func ParseVariable(curToken Token, sec Token, lexer *Lexer) (key string, value i
return "", nil, errors.New("var err unkown")
}
if keyT.Type != IDENTIFIER {
return "", nil, errors.New(fmt.Sprintf("expected an identifier, but got '%s'", keyT.Value))
return "", nil, fmt.Errorf("expected an identifier, but got '%s'", keyT.Value)
}
if VariableExists(keyT.Value) {
return "", nil, errors.New(fmt.Sprintf("'%s' is already declared", keyT.Value))
return "", nil, fmt.Errorf("'%s' is already declared", keyT.Value)
}
Eq := lexer.NextToken()
//fmt.Println(Eq)
if Eq.Type != ASSIGN {
return "", nil, errors.New(fmt.Sprintf("'=' sign is expected after the '%s'", keyT.Value))
return "", nil, fmt.Errorf("'=' sign is expected after the '%s'", keyT.Value)
}
valT := lexer.NextToken()

Expand Down
8 changes: 8 additions & 0 deletions lexer/parseExpressionv2.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package lexer
/*
parse mathemetical expressions and everything else and parse function arguments too
*/
func ParseExpressionV2(tok Token, l *Lexer) {

}

0 comments on commit 738b382

Please sign in to comment.