Skip to content

Semantic actions #399

@fan-tom

Description

@fan-tom

Currently we need to write separate code to convert pest parsed representation to our own AST representation, as shown in JSON example. The drawback of that approach is that you have to keep that conversion in sync with grammar, as they are in different places. Bison have semantic actions and peg crate also supports them (see a:e1 b:e2 c:e3 { rust }). It allows to get you own AST type right after parsing and you can change AST construction steps right when you change your grammar, no need to separate conversion step, you can even avoid creating intermidiate parser-related values (Pair) and just immidiately produce user defined types while parsing

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions