Skip to content

2. Parser

Pawel Lampe edited this page Feb 23, 2022 · 1 revision

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

  • Validating GDScript code on the syntax level
  • Builing a parse tree for educational purposes

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
Clone this wiki locally