2. Parser (original) (raw)

gdparse is a simple tool for parsing GDScript code. For the purpose of parsing, the EBNF-like GDScript grammar is used. This grammar is further processed by Lark - simple parsing toolkit written in Python - which produces a fully featured parser out of grammar file.

Purposes of gdparse

Parsing with gdparse

To parse a file, use the gdparse command:

gdparse tests/valid-gd-scripts/recursive_tool.gd -p

The command's exit code is 0 if parsing succeeded. It outputs a tree that represents your code's structure straight to the stdout:

start
  class_def
    X
    class_body
      tool_stmt
      signal_stmt	sss
  class_def
    Y
    class_body
      tool_stmt
      signal_stmt	sss
  tool_stmt