How to serialize antlr3 AST

I just started using antlr3 and am trying to serialize AST output from .g grammar.
Thanks
Lezan

+3
source share
2 answers

As Vladimir noted, you can use your own AST node class, which has built-in serialization capabilities. You can also use the tree adapter to create the types of nodes you need.

If you only need serialization and not de-serialization, you might just do:

ast.toStringTree()

LISP. AST node toString(). toStringTree() node toStringTree, , toString. , .

+2

CommonTree, Parser, Serializable.

() . ( ANTLR) " " - , , .

, Tree :

options {
  ASTLabelType = MyOwnTreeClass;
}

.

+2

Source: https://habr.com/ru/post/1723350/


All Articles