Parser now uses new equal signs

This commit is contained in:
Sasha Koshka 2022-09-03 20:32:27 -04:00
parent a665463932
commit 1274eeb400
5 changed files with 20 additions and 16 deletions

View File

@ -33,7 +33,8 @@ func ro eMath
--- ---
[++ x] [++ x]
[-- y] [-- y]
[set z [+ [* 250 0] 98 x [/ 9832 y] 930]] [= z [+ [* 250 0] 98 x [/ 9832 y] 930]]
[== 4 4]
[! true] [! true]
[~ 1] [~ 1]
[~= x] [~= x]
@ -100,9 +101,9 @@ func ro gControlFlow
[otherThing] [otherThing]
func ro hSetPhrase func ro hSetPhrase
--- ---
[set x:Int 3] [= x:Int 3]
[set y:{Int} [loc x]] [= y:{Int} [loc x]]
[set z:{Int 8}] [= z:{Int 8}]
398 398
9 9
2309 2309
@ -111,7 +112,7 @@ func ro hSetPhrase
478 478
555 555
123 123
[set bird:Bird] [= bird:Bird]
.that .that
.whenYou 99999 .whenYou 99999
.this 324 .this 324

View File

@ -17,6 +17,7 @@ var operatorTokens = []lexer.TokenKind {
lexer.TokenKindPercentAssignment, lexer.TokenKindPercentAssignment,
lexer.TokenKindTilde, lexer.TokenKindTilde,
lexer.TokenKindTildeAssignment, lexer.TokenKindTildeAssignment,
lexer.TokenKindAssignment,
lexer.TokenKindEqualTo, lexer.TokenKindEqualTo,
lexer.TokenKindNotEqualTo, lexer.TokenKindNotEqualTo,
lexer.TokenKindLessThanEqualTo, lexer.TokenKindLessThanEqualTo,
@ -102,7 +103,6 @@ func (parser *ParsingOperation) parseBlock (
block = append(block, phrase) block = append(block, phrase)
if err != nil { return } if err != nil { return }
} }
return
} }
// parseBlockLevelPhrase parses a phrase that is not being used as an argument // 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 err != nil { return }
// if this is a set phrase, parse initialization values under it // if this is a set phrase, parse initialization values under it
if phrase.kind == PhraseKindSet { if phrase.kind == PhraseKindAssign {
var values Argument var values Argument
values, err = parser.parseInitializationValues(indent) values, err = parser.parseInitializationValues(indent)
@ -308,6 +308,8 @@ func (parser *ParsingOperation) parsePhraseCommand () (
if parser.token.Is(lexer.TokenKindColon) { if parser.token.Is(lexer.TokenKindColon) {
kind = PhraseKindCase kind = PhraseKindCase
} else if parser.token.Is(lexer.TokenKindAssignment) {
kind = PhraseKindAssign
} else { } else {
kind = PhraseKindOperator kind = PhraseKindOperator
} }
@ -328,8 +330,6 @@ func (parser *ParsingOperation) parsePhraseCommand () (
identifier := command.value.(Identifier) identifier := command.value.(Identifier)
if len(identifier.trail) == 1 { if len(identifier.trail) == 1 {
switch identifier.trail[0] { switch identifier.trail[0] {
case "set":
kind = PhraseKindSet
case "loc": case "loc":
kind = PhraseKindReference kind = PhraseKindReference
case "defer": case "defer":

View File

@ -233,8 +233,10 @@ func (argument *Argument) ToString (indent int, breakLine bool) (output string)
stringValue = "~" stringValue = "~"
case lexer.TokenKindTildeAssignment: case lexer.TokenKindTildeAssignment:
stringValue = "~=" stringValue = "~="
case lexer.TokenKindEqualTo: case lexer.TokenKindAssignment:
stringValue = "=" stringValue = "="
case lexer.TokenKindEqualTo:
stringValue = "=="
case lexer.TokenKindNotEqualTo: case lexer.TokenKindNotEqualTo:
stringValue = "!=" stringValue = "!="
case lexer.TokenKindLessThanEqualTo: case lexer.TokenKindLessThanEqualTo:

View File

@ -230,7 +230,7 @@ const (
PhraseKindCall = iota PhraseKindCall = iota
PhraseKindCallExternal PhraseKindCallExternal
PhraseKindOperator PhraseKindOperator
PhraseKindSet PhraseKindAssign
PhraseKindReference PhraseKindReference
PhraseKindDefer PhraseKindDefer
PhraseKindIf PhraseKindIf

View File

@ -37,8 +37,9 @@ func ro eMath
--- ---
++ x ++ x
-- y -- y
set z [+ [* 0372 00] 98 x [/ 9832 y] 930] = z [+ [* 0372 00] 98 x [/ 9832 y] 930]
== 4 4
! true ! true
~ 0b01 ~ 0b01
~= x ~= x
@ -123,13 +124,13 @@ func ro gControlFlow
func ro hSetPhrase func ro hSetPhrase
--- ---
set x:Int 3 = x:Int 3
# loc is a reference, similar to * in C # loc is a reference, similar to * in C
set y:{Int} [loc x] = y:{Int} [loc x]
set z:{Int 8} = z:{Int 8}
398 9 2309 983 -2387 398 9 2309 983 -2387
478 555 123 478 555 123
set bird:Bird = bird:Bird
.that .that
.whenYou 99999 .whenYou 99999
.this 324 .this 324