我在Go中使用Ragel 6.10。我确信这可能是我的代码有问题,但当我尝试将堆栈与扫描块一起使用时,会出现一些奇怪的错误。我正在尝试设置括号匹配,我的代码大致如下所示;
ObjectValues := |*
# other stuff
'}' => { fret; };
*|
main := ('{' @{fcall ObjectValues;})*;
看看指南的第46页,这似乎是可能的。当我跑Ragel的时候
ragel -G2 -Z main.rl
. 当我尝试编译时,我得到以下错误(它只发生在-G2 FSM生成中);
graphql_collections.rl:47[/Users/nathanfisher/workspace/go/src/github.com/nfisher/gir/graphql_collections.go:325:2]: syntax error: unexpected goto at end of statement
graphql_collections.go:60[/Users/nathanfisher/workspace/go/src/github.com/nfisher/gir/graphql_collections.go:60:1]: label _again defined and not used
注释掉fret行将删除错误,并警告无法访问POSTOP和prepush。
完整代码在这里;
https://github.com/nfisher/gir/blob/broken/graphql_collections.rl#L47
这里有一个工作的最小测试用例;
https://gist.github.com/nfisher/649ca816f82bb3ccd7164331ac2324ac
测试用例错误;
main.rl:13[/Users/nathanfisher/workspace/go/src/github.com/nfisher/gir/command/runner/main.go:119:2]: syntax error: unexpected goto at end of statement
main.go:59[/Users/nathanfisher/workspace/go/src/github.com/nfisher/gir/command/runner/main.go:59:1]: label _again defined and not used