Skip to content

Serialization of the Parser Tree #27

Open
@Goutte

Description

@Goutte

✨ Feature request

Make the parser tree serializable with the \serialize() function.

Motivation

Making the parser tree takes most of the total computation time.
If I could "cache" it somehow, it would be great !

Example

$tree = $parser->program();
print(\serialize($tree));

yields

Serialization of 'Antlr\Antlr4\Runtime\Comparison\Equivalence@anonymous' is not allowed

Alternatives

  • Make the grammar more efficient (there's room, I'm a noob)
  • Use a visitor to transpile to target language (but code gen is always tricky)
  • Make my own AST from the parser tree, and somehow ensure it is serializable (contexts?)
  • How do YOU do it ?

Additional context

The vt time is the visitor. The rest could be cached, perhaps.
On more complex scripts, with nested flow statements, it goes up to seconds.

image

Cyprak is the name of our budding DSL for an online role playing game (and is a pun on sprak == language)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions