You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Execute user code in Parse() rather than Execute() #53
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?
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.
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?
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 !{ ... }
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.
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?
@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.
Activity
pointlander commentedon Aug 20, 2016
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:
pointlander commentedon Aug 20, 2016
&{ ... } is a predicate
peg/peg.go
Line 1407 in 1d0268d
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:
awalterschulze commentedon Aug 21, 2016
@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.
awalterschulze commentedon Aug 24, 2016
Ok I just skimmed the yaml spec. I think I will be preferring your PEG spec :) I am patient.