diff --git a/parser/func_test.go b/parser/func_test.go index 2073388..f221b9e 100644 --- a/parser/func_test.go +++ b/parser/func_test.go @@ -33,7 +33,8 @@ func ro eMath --- [++ x] [-- y] - [set z [+ [* 250 0] 98 x [/ 9832 y] 930]] + [= z [+ [* 250 0] 98 x [/ 9832 y] 930]] + [== 4 4] [! true] [~ 1] [~= x] @@ -100,9 +101,9 @@ func ro gControlFlow [otherThing] func ro hSetPhrase --- - [set x:Int 3] - [set y:{Int} [loc x]] - [set z:{Int 8}] + [= x:Int 3] + [= y:{Int} [loc x]] + [= z:{Int 8}] 398 9 2309 @@ -111,7 +112,7 @@ func ro hSetPhrase 478 555 123 - [set bird:Bird] + [= bird:Bird] .that .whenYou 99999 .this 324 diff --git a/parser/phrase.go b/parser/phrase.go index 98a9a3e..c25458b 100644 --- a/parser/phrase.go +++ b/parser/phrase.go @@ -17,6 +17,7 @@ var operatorTokens = []lexer.TokenKind { lexer.TokenKindPercentAssignment, lexer.TokenKindTilde, lexer.TokenKindTildeAssignment, + lexer.TokenKindAssignment, lexer.TokenKindEqualTo, lexer.TokenKindNotEqualTo, lexer.TokenKindLessThanEqualTo, @@ -102,7 +103,6 @@ func (parser *ParsingOperation) parseBlock ( block = append(block, phrase) if err != nil { return } } - return } // parseBlockLevelPhrase parses a phrase that is not being used as an argument @@ -214,7 +214,7 @@ func (parser *ParsingOperation) parseBlockLevelPhrase ( if err != nil { return } // if this is a set phrase, parse initialization values under it - if phrase.kind == PhraseKindSet { + if phrase.kind == PhraseKindAssign { var values Argument values, err = parser.parseInitializationValues(indent) @@ -308,6 +308,8 @@ func (parser *ParsingOperation) parsePhraseCommand () ( if parser.token.Is(lexer.TokenKindColon) { kind = PhraseKindCase + } else if parser.token.Is(lexer.TokenKindAssignment) { + kind = PhraseKindAssign } else { kind = PhraseKindOperator } @@ -328,8 +330,6 @@ func (parser *ParsingOperation) parsePhraseCommand () ( identifier := command.value.(Identifier) if len(identifier.trail) == 1 { switch identifier.trail[0] { - case "set": - kind = PhraseKindSet case "loc": kind = PhraseKindReference case "defer": diff --git a/parser/tree-tostring.go b/parser/tree-tostring.go index 79124b1..35a3d35 100644 --- a/parser/tree-tostring.go +++ b/parser/tree-tostring.go @@ -233,8 +233,10 @@ func (argument *Argument) ToString (indent int, breakLine bool) (output string) stringValue = "~" case lexer.TokenKindTildeAssignment: stringValue = "~=" - case lexer.TokenKindEqualTo: + case lexer.TokenKindAssignment: stringValue = "=" + case lexer.TokenKindEqualTo: + stringValue = "==" case lexer.TokenKindNotEqualTo: stringValue = "!=" case lexer.TokenKindLessThanEqualTo: diff --git a/parser/tree.go b/parser/tree.go index f6f5ae8..257960a 100644 --- a/parser/tree.go +++ b/parser/tree.go @@ -230,7 +230,7 @@ const ( PhraseKindCall = iota PhraseKindCallExternal PhraseKindOperator - PhraseKindSet + PhraseKindAssign PhraseKindReference PhraseKindDefer PhraseKindIf diff --git a/tests/parser/func/main.arf b/tests/parser/func/main.arf index 7eee736..fcb1671 100644 --- a/tests/parser/func/main.arf +++ b/tests/parser/func/main.arf @@ -37,8 +37,9 @@ func ro eMath --- ++ x -- y - set z [+ [* 0372 00] 98 x [/ 9832 y] 930] + = z [+ [* 0372 00] 98 x [/ 9832 y] 930] + == 4 4 ! true ~ 0b01 ~= x @@ -123,13 +124,13 @@ func ro gControlFlow func ro hSetPhrase --- - set x:Int 3 + = x:Int 3 # loc is a reference, similar to * in C - set y:{Int} [loc x] - set z:{Int 8} + = y:{Int} [loc x] + = z:{Int 8} 398 9 2309 983 -2387 478 555 123 - set bird:Bird + = bird:Bird .that .whenYou 99999 .this 324