Skip to content

Execute user code in Parse() rather than Execute() #53

Open

Description

I was hoping to use this parser generator to parse YAML, but to do this, I need to depend on indenting while matching rules. Executing user code in Execute() thus is too late for me.

Is it possible, and if not, how difficult would it be to add functionality needed to do something that'd enable early code execution?

Activity

  1. pointlander commented on Aug 20, 2016

    @pointlander
    Owner

    Some PEGs do support early code execution (http://piumarta.com/software/peg/),
    but I don't think this is a good idea in general because PEGs do
    backtracking. Example:
    a <- { code } 'a' / 'b'
    with early code execution 'code' would be executed even if the next
    character isn't 'a'. You might want to use:
    https://github.com/go-yaml/yaml
    You could still use my implementation of peg by handling the significance
    of white space after parsing. You could call AST() and then do a transform
    on the ast as a function of white space.

    On Sat, Aug 20, 2016 at 1:25 PM, wvxvw notifications@github.com wrote:

    I was hoping to use this parser generator to parse YAML, but to do this, I
    need to depend on indenting while matching rules. Executing user code in
    Execute() thus is too late for me.

    Is it possible, and if not, how difficult would it be to add functionality
    needed to do something that'd enable early code execution?

    —
    You are receiving this because you are subscribed to this thread.
    Reply to this email directly, view it on GitHub
    #53, or mute the thread
    https://github.com/notifications/unsubscribe-auth/AAPZFBBFFoYZ7PtWaAkpNAmiWs0bPnTOks5qh1TFgaJpZM4JpJTz
    .

  2. pointlander commented on Aug 20, 2016

    @pointlander
    Owner

    &{ ... } is a predicate

    peg/peg.go

    Line 1407 in 1d0268d

    case TypePredicate:

    is the code generated for a predicate.
    Example:
    a <- &{ false }
    is a rule that will always fail.
    If you want to put code inline with peg you could use !{ ... }

    On Sat, Aug 20, 2016 at 2:05 PM, Andrew Snodgrass pointlander@gmail.com
    wrote:

    Some PEGs do support early code execution (http://piumarta.com/software/
    peg/), but I don't think this is a good idea in general because PEGs do
    backtracking. Example:
    a <- { code } 'a' / 'b'
    with early code execution 'code' would be executed even if the next
    character isn't 'a'. You might want to use:
    https://github.com/go-yaml/yaml
    You could still use my implementation of peg by handling the significance
    of white space after parsing. You could call AST() and then do a transform
    on the ast as a function of white space.

    On Sat, Aug 20, 2016 at 1:25 PM, wvxvw notifications@github.com wrote:

    I was hoping to use this parser generator to parse YAML, but to do this,
    I need to depend on indenting while matching rules. Executing user code in
    Execute() thus is too late for me.

    Is it possible, and if not, how difficult would it be to add
    functionality needed to do something that'd enable early code execution?

    —
    You are receiving this because you are subscribed to this thread.
    Reply to this email directly, view it on GitHub
    #53, or mute the thread
    https://github.com/notifications/unsubscribe-auth/AAPZFBBFFoYZ7PtWaAkpNAmiWs0bPnTOks5qh1TFgaJpZM4JpJTz
    .

  3. awalterschulze commented on Aug 21, 2016

    @awalterschulze

    @wvxvw I would really liked to see your completed parser.
    Since I would like to create a parser, in future, that satisfies this interface:
    http://katydid.github.io/parser/addingparsers.html
    This way I can have a yaml validator language.

  4. awalterschulze commented on Aug 24, 2016

    @awalterschulze

    Ok I just skimmed the yaml spec. I think I will be preferring your PEG spec :) I am patient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions