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]
[-- 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

View File

@ -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":

View File

@ -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:

View File

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

View File

@ -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