Design Pattern for Parsing LOGO Turtle Code
-
15-02-2021 - |
문제
In wikipedia, Logo Programming is a multi-paradigm computer programming language used in education. I want to make an application like TurtleGraphicEditor (which using logo programing) using C#. I want each logo command act as method, example command "forward val" act as "forward(float val)", etc. What is design pattern that suitable for parsing the Logo code?
해결책
This is a very general question. Here are some topics that you might want to read up on:
- lexers
- parsers (as you mentioned)
- abstract syntax trees
- compilers
- domain-specific languages
- interpreters
A general design for such an application might have two main components:
- read text, lex and parse into abstract syntax tree
- walk the syntax tree, either evaluating it or transforming it (compiling) into source code in a different language
But be warned! This is not trivial!
다른 팁
Interpreter is ideal solution
제휴하지 않습니다 StackOverflow