diff --git a/design/spec.md b/design/spec.md index f45ac57..70bfd74 100644 --- a/design/spec.md +++ b/design/spec.md @@ -320,7 +320,7 @@ this without hand-writing a parser. ``` -> ( | | )* -> "+" | "#" | "-" - -> [] ":" + -> [] ":" * -> [] ["=" ] -> [] "." @@ -330,7 +330,7 @@ this without hand-writing a parser. | | | - -> + -> [ "::"] -> "*" -> "*" ":" -> ":" @@ -362,9 +362,10 @@ this without hand-writing a parser. | | | + | -> -> ":" - -> "[" + "]" + -> [ "::"] "[" + "]" -> "[" "." "]" -> "[" "\" ? "/" ? "]" -> "[" "#" "]" @@ -386,6 +387,7 @@ this without hand-writing a parser. -> "[" "break" [] "]" -> "[" "return" [] "]" -> "=" + -> "." -> /-?[1-9][0-9]*/ | /-?0[0-7]*/ @@ -397,15 +399,16 @@ this without hand-writing a parser. -> "(." * ")" -> "true" | "false" - -> ":" - -> "|" - -> "|" - -> "*" - -> "[" * "]" [":" ] - -> /[a-z][A-Za-z]*/ - -> /[A-Z][A-Za-z]*/ - -> "+" | "++" | "-" | "--" | "*" | "/" | "%" - | "!!" | "||" | "&&" | "^^" - | "!" | "|" | "&" | "^" | "<<" | ">>" - | "<" | ">" | "<=" | ">=" | "=" + -> ":" + -> "|" ["=" ] + -> "|" + -> "|" + -> "*" + -> "[" * "]" [":" ] + -> /[a-z][A-Za-z]*/ + -> /[A-Z][A-Za-z]*/ + -> "+" | "++" | "-" | "--" | "*" | "/" | "%" + | "!!" | "||" | "&&" | "^^" + | "!" | "|" | "&" | "^" | "<<" | ">>" + | "<" | ">" | "<=" | ">=" | "=" ``` diff --git a/entity/misc.go b/entity/misc.go index 7708e61..956938b 100644 --- a/entity/misc.go +++ b/entity/misc.go @@ -267,5 +267,5 @@ type ConstantDeclaration struct { func (this *ConstantDeclaration) Position () errors.Position { return this.Pos } func (this *ConstantDeclaration) Type () Type { return this.Ty } func (this *ConstantDeclaration) String () string { - return fmt.Sprint("| ", this.Name, " ", this.Value) + return fmt.Sprint("| ", this.Name, " = ", this.Value) } diff --git a/parser/fspl/parser_test.go b/parser/fspl/parser_test.go index 0d18c0c..8ce6986 100644 --- a/parser/fspl/parser_test.go +++ b/parser/fspl/parser_test.go @@ -13,9 +13,9 @@ testString (test, - StructArray: 31:24:340920:(. x:Int y:Int) - String: *:U8 + FileDescriptor: I32 -| stdin 0 -| stdout 1 -| stderr 2`, +| stdin = 0 +| stdout = 1 +| stderr = 2`, // input ` BasicInt: Int @@ -34,9 +34,9 @@ StructArray: 31:24:340920:(. y:Int) String: *:U8 + FileDescriptor: I32 -| stdin 0 -| stdout 1 -| stderr 2 +| stdin = 0 +| stdout = 1 +| stderr = 2 `) } diff --git a/parser/fspl/toplevel.go b/parser/fspl/toplevel.go index c31875b..c7364c7 100644 --- a/parser/fspl/toplevel.go +++ b/parser/fspl/toplevel.go @@ -186,7 +186,8 @@ func (this *treeParser) parseConstantDeclaration () (*entity.ConstantDeclaration declaration.Name = this.Value() this.Next() - if this.Is(startTokensExpression...) { + if this.Is(lexer.Symbol) && this.ValueIs("=") { + this.Next() value, err := this.parseExpression() if err != nil { return nil, err } declaration.Value = value