Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion cmd/chore/gopminispec/minispec.gop
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import (
"gop/doc/spec/mini"
"gop/tpl"
"os"
)

Expand All @@ -24,4 +25,9 @@ if len(os.Args) < 2 {
return
}

echo mini.parseFile(nil, os.Args[1], nil)
f, err := mini.parseFile(nil, os.Args[1], nil)
if err != nil {
fprintln os.Stderr, err
} else {
tpl.dump f
}
7 changes: 5 additions & 2 deletions doc/spec/mini/mini.gop
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ Block = "{" StatementList "}"
StatementList = *(Statement ";")

Statement =
Declaration | ReturnStmt | BreakStmt | ContinueStmt | GotoStmt | FallthroughStmt |
IfStmt | SwitchStmt | ForStmt | DeferStmt | Block | LabeledStmt | SimpleStmt
Declaration | ReturnStmt | BreakStmt | ContinueStmt | GotoStmt |
FallthroughStmt | IfStmt | SwitchStmt | ForStmt | DeferStmt | Block |
LabeledStmt | CommandStmt | SimpleStmt

ReturnStmt = "return" ?ExpressionList

Expand Down Expand Up @@ -113,6 +114,8 @@ Assignment = ExpressionList (

ExpressionStmt = Expression

CommandStmt = IDENT ?("." IDENT) ExpressionList

EmptyStmt = ""

// -----------------------------------------------------------------
Expand Down
4 changes: 3 additions & 1 deletion tpl/tpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,10 @@ retry:
}
fmt.Print(prefix, "]\n")
}
case nil:
fmt.Fprint(w, prefix, "nil\n")
default:
panic("unexpected node")
panic("unexpected node: " + reflect.TypeOf(ret).String())
}
}

Expand Down