Lexer, Parser, Eval in Godot

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Panagiotis Halatsako

As a weekend project, I need a process that would parse a script file of a “custom” language, read into godot and populate some scenes with logic (hint: it’s part of an adventure game concept).

Is using GDNative C/C++ a good idea to implement a small lexer/parser and eval, assuming that in godot I might not be as comfortable to do these operations and they might clunky and slower?

From my experience, small interpreters dont use too much cpu or ram, so gdscript should be fine, it has a pretty good match statement, but if you are more comfortable in c++, then just use that.

RazorSh4rk | 2020-05-24 21:48

:bust_in_silhouette: Reply From: Zylann

Godot has the Expression class, which can help parsing expressions for custom interpreters: Expression — Godot Engine (stable) documentation in English

Interesting, so the rest Lexer / Parser would be implemented as an autoload script, right?

Panagiotis Halatsako | 2020-05-27 10:24

Autoload is not required to use Expression, it’s up to you how you set this up.

Zylann | 2020-05-27 11:55

Just thinking out loud there :slight_smile:

Thanks for your help very much!

Panagiotis Halatsako | 2020-05-27 12:35