douzhan1238
2018-01-30 08:47
浏览 49
已采纳

在Ragel中使用带有扫描仪模块的堆栈的正确方法是什么?

I'm using Ragel 6.10 with Go. I'm sure it's likely an issue with my code but I'm getting some weird errors when I try to use a stack with a scanner block. I'm trying to setup bracket matching and my code looks roughly like this;

ObjectValues := |*
 # other stuff
 '}' => { fret; };
 *|

main := ('{' @{fcall ObjectValues;})*;

Looking at page 46 in the guide it looks like this should be possible. When I run Ragel ragel -G2 -Z main.rl. I get the following error when I try to compile (it only happens for -G2 FSM generation);

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

Commenting out the fret line removes the error and warns postpop and prepush are unreachable.

The full code is here;

https://github.com/nfisher/gir/blob/broken/graphql_collections.rl#L47

A working minimal test-case is here;

https://gist.github.com/nfisher/649ca816f82bb3ccd7164331ac2324ac

Error for test-case;

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
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douti8321 2018-01-30 19:18
    已采纳

    It looks like this is an issue relating to Ragel's generated code in v 6.10. Using the HEAD of ragel-6 branch fixes the issue. Thanks to Adrian Thurston for being super responsive/helpful via Twitter. :)

    Reformatting the code from this;

    compilation error

    To this fixes the error;

    compiles

    已采纳该答案
    打赏 评论

相关推荐 更多相似问题