diff --git a/parser/func_test.go b/parser/func_test.go index c111e6d..7ad00d2 100644 --- a/parser/func_test.go +++ b/parser/func_test.go @@ -101,9 +101,9 @@ func ro gControlFlow [otherThing] func ro hDataInit --- - [let x:Int 3] - [let y:{Int} [loc x]] - [let z:Int:8 (398 9 2309 983 -2387 478 555 123)] - [let bird:Bird ((99999) 324)] + [= x:Int 3] + [= y:{Int} [loc x]] + [= z:Int:8 (398 9 2309 983 -2387 478 555 123)] + [= bird:Bird ((99999) 324)] `, test) } diff --git a/parser/phrase.go b/parser/phrase.go index bcf71f3..da04024 100644 --- a/parser/phrase.go +++ b/parser/phrase.go @@ -312,8 +312,6 @@ func (parser *ParsingOperation) parsePhraseCommand () ( identifier := command.value.(Identifier) if len(identifier.trail) == 1 { switch identifier.trail[0] { - case "let": - kind = PhraseKindLet case "loc": kind = PhraseKindReference case "defer": diff --git a/parser/tree-tostring.go b/parser/tree-tostring.go index 8e2685b..b6e9d64 100644 --- a/parser/tree-tostring.go +++ b/parser/tree-tostring.go @@ -95,7 +95,7 @@ func (what Type) ToString () (output string) { return } -func (declaration Declaration) ToString (indent int) (output string) { +func (declaration Declaration) ToString () (output string) { output += declaration.name + ":" output += declaration.what.ToString() return @@ -142,7 +142,7 @@ func (argument Argument) ToString (indent int, breakLine bool) (output string) { case ArgumentKindDeclaration: output += doIndent ( indent, - argument.value.(Declaration).ToString(indent)) + argument.value.(Declaration).ToString()) if breakLine { output += "\n" } case ArgumentKindInt, ArgumentKindUInt, ArgumentKindFloat: @@ -260,11 +260,11 @@ func (behavior FaceBehavior) ToString (indent int) (output string) { output += doIndent(indent, behavior.name, "\n") for _, inputItem := range behavior.inputs { - output += doIndent(indent + 1, "> ", inputItem.ToString(indent), "\n") + output += doIndent(indent + 1, "> ", inputItem.ToString(), "\n") } for _, outputItem := range behavior.outputs { - output += doIndent(indent + 1, "< ", outputItem.ToString(indent), "\n") + output += doIndent(indent + 1, "< ", outputItem.ToString(), "\n") } return @@ -280,7 +280,6 @@ func (phrase Phrase) ToString (indent int, ownLine bool) (output string) { switch phrase.kind { case PhraseKindOperator, - PhraseKindLet, PhraseKindAssign: switch phrase.operator { @@ -373,6 +372,17 @@ func (phrase Phrase) ToString (indent int, ownLine bool) (output string) { return } +func (funcOutput FuncOutput) ToString (indent int) (output string) { + output += doIndent(indent + 1) + output += "< " + funcOutput.Declaration.ToString() + if funcOutput.argument.kind != ArgumentKindNil { + output += " " + funcOutput.argument.ToString(indent, false) + } + output += "\n" + + return +} + func (block Block) ToString (indent int) (output string) { for _, phrase := range block { output += phrase.ToString(indent, true) @@ -391,15 +401,15 @@ func (section FuncSection) ToString (indent int) (output string) { if section.receiver != nil { output += doIndent ( indent + 1, - "@ ", section.receiver.ToString(indent), "\n") + "@ ", section.receiver.ToString(), "\n") } for _, inputItem := range section.inputs { - output += doIndent(indent + 1, "> ", inputItem.ToString(indent), "\n") + output += doIndent(indent + 1, "> ", inputItem.ToString(), "\n") } for _, outputItem := range section.outputs { - output += doIndent(indent + 1, "< ", outputItem.ToString(indent), "\n") + output += outputItem.ToString(indent) } output += doIndent(indent + 1, "---\n") diff --git a/parser/tree.go b/parser/tree.go index ad935ab..c89b899 100644 --- a/parser/tree.go +++ b/parser/tree.go @@ -217,7 +217,6 @@ const ( PhraseKindCall = iota PhraseKindCallExternal PhraseKindOperator - PhraseKindLet PhraseKindAssign PhraseKindReference PhraseKindDefer diff --git a/tests/parser/func/main.arf b/tests/parser/func/main.arf index 0f33b45..3c47e1c 100644 --- a/tests/parser/func/main.arf +++ b/tests/parser/func/main.arf @@ -124,11 +124,11 @@ func ro gControlFlow func ro hDataInit --- - let x:Int 3 + = x:Int 3 # loc is a reference, similar to * in C - let y:{Int} [loc x] - let z:Int:8 (398 9 2309 983 -2387 + = y:{Int} [loc x] + = z:Int:8 (398 9 2309 983 -2387 478 555 123) - let bird:Bird ( + = bird:Bird ( (99999) 324)