FAQ
I wrote a parser generator (a la yacc) based on PEGs for Go. It was
inspired by the PEG.js project.

The repo is here: https://github.com/PuerkitoBio/pigeon

and the introductory blog post:
http://0value.com/A-PEG-parser-generator-for-Go

Full doc on godoc as usual: http://godoc.org/github.com/PuerkitoBio/pigeon

Martin

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Kurt Jung at Apr 14, 2015 at 11:38 am
    Excellent work! It's really nice to see a PEG parser generator for Go. I
    hope to see it in the standard library someday.

    -- Kurt

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Andrewchamberss at Apr 14, 2015 at 8:33 pm
    Very cool.

    Why use a special arrow characte btw? Is there an alternative syntax for
    normal keyboards?
    On Monday, April 13, 2015 at 11:19:49 PM UTC+12, Martin Angers wrote:

    I wrote a parser generator (a la yacc) based on PEGs for Go. It was
    inspired by the PEG.js project.

    The repo is here: https://github.com/PuerkitoBio/pigeon

    and the introductory blog post:
    http://0value.com/A-PEG-parser-generator-for-Go

    Full doc on godoc as usual: http://godoc.org/github.com/PuerkitoBio/pigeon

    Martin
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Martin Angers at Apr 14, 2015 at 8:34 pm
    oh sure, there are four alternatives:

    '=', '<-' and the two left arrow unicode code points.
    On Tue, 14 Apr 2015 at 16:33 wrote:

    Very cool.

    Why use a special arrow characte btw? Is there an alternative syntax for
    normal keyboards?

    On Monday, April 13, 2015 at 11:19:49 PM UTC+12, Martin Angers wrote:

    I wrote a parser generator (a la yacc) based on PEGs for Go. It was
    inspired by the PEG.js project.

    The repo is here: https://github.com/PuerkitoBio/pigeon

    and the introductory blog post:
    http://0value.com/A-PEG-parser-generator-for-Go

    Full doc on godoc as usual:
    http://godoc.org/github.com/PuerkitoBio/pigeon

    Martin
    --
    You received this message because you are subscribed to a topic in the
    Google Groups "golang-nuts" group.
    To unsubscribe from this topic, visit
    https://groups.google.com/d/topic/golang-nuts/NyM3DEPtX94/unsubscribe.
    To unsubscribe from this group and all its topics, send an email to
    golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Peter Kleiweg at Apr 15, 2015 at 11:31 am
    What happens when an expression return an error? Does that make the match
    fail, and the parser backtrack?

    With 'and' and 'not' expressions, what is the meaning of boolean return
    value?

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Martin Angers at Apr 15, 2015 at 11:50 am
    No, an action code block is always called when a match succeeded, and
    cannot turn that into a match fail. Returning an error doesn't change that,
    it just adds the error to the list of errors encountered (that can be
    useful to return a specific error when you know for sure that backtracking
    cannot match anything else - that's what pigeon does in its grammar for
    unclosed literals, for example).

    For & and !, the boolean decides whether it is a match or not (& is a match
    if it returns true, ! is a match if it returns false). This is like the
    non-code block version of & and ! operators.
    On Wednesday, 15 April 2015 07:31:37 UTC-4, Peter Kleiweg wrote:

    What happens when an expression return an error? Does that make the match
    fail, and the parser backtrack?

    With 'and' and 'not' expressions, what is the meaning of boolean return
    value?
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Peter Kleiweg at Apr 15, 2015 at 12:58 pm
    How do I convert a labeled terminal to a string? Something like this:

         Term <- term:[a-z]+ space:[ \t\r\f\n]* {
              // termString is term as string
              return termString, nil
         }

    Whatever I try, I get "interface conversion: interface is []interface {}".
    Why isn't it a []byte, just like c.text?

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Peter Kleiweg at Apr 15, 2015 at 1:03 pm
    You might want to give all generated names for "internal" use a common,
    documenten prefix, to prevent name clashes with user defined names in
    future releases of your software.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Martin Angers at Apr 15, 2015 at 2:09 pm
    When the expression is a sequence (Term = label:('a' 'b' 'c')) or a
    repetition as in your case (Term = term:[a-z]+), the value is a
    []interface{} because the label holds multiple separate matches. `c.text`,
    on the other hand, is the whole match associated with the code block (e.g.
    it could be "abc\n\t" in your case, as a []byte).

    I agree that this is a confusing thing, I will try to better document this.

    Good point for the prefix to avoid name clashes, I will think about that.
    On Wed, 15 Apr 2015 at 09:03 Peter Kleiweg wrote:

    You might want to give all generated names for "internal" use a common,
    documenten prefix, to prevent name clashes with user defined names in
    future releases of your software.

    --
    You received this message because you are subscribed to a topic in the
    Google Groups "golang-nuts" group.
    To unsubscribe from this topic, visit
    https://groups.google.com/d/topic/golang-nuts/NyM3DEPtX94/unsubscribe.
    To unsubscribe from this group and all its topics, send an email to
    golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedApr 13, '15 at 11:19a
activeApr 15, '15 at 2:09p
posts9
users4
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase