Language design | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
0

Language design

So I’ve been doing some research into building a programming language and now know that they usually have separate lexers, parsers, abstract syntax trees and action trees. Could anyone explain about these in detail, particularly the differences between lexers and parsers and between ASTs and action trees? If I succeed in making one (both interpreted and compiled) I plan to create a course for it here! XD

19th Dec 2018, 11:01 PM
Myersj281
Myersj281 - avatar
4 Antworten
+ 1
Lexical analysis converts the characters found in the source code into tokens (e.g. 'i', 'n', 't' becomes a symbol "int" or '1', '2', '3' becomes a number 123.) Parsing deals with those tokens to recognize syntax (e.g. symbol equal number semicolon becomes an assignment statement [x=1;].) Abstract Syntax Trees is a way to store the tokens to reflect the source syntax. Using these trees make it easier for scope checking during semantic checking. Don't know any action trees. Could you possibly mean activation trees?
20th Dec 2018, 10:56 PM
John Wells
John Wells - avatar
+ 2
This a more detailed course in compilers. https://www.tutorialspoint.com/compiler_design/index.htm
20th Dec 2018, 11:48 PM
John Wells
John Wells - avatar
+ 1
He actually stated he made up the term as he didn't know what to call it. You were right about the article. AST in my mind are his action trees. He didn't add type information to his AST making the action tree by combining types with his AST. I'd leave the types empty while building the AST and fill them in his action tree step.
20th Dec 2018, 11:39 PM
John Wells
John Wells - avatar
0
no i believe they say action trees (possibly an unrecognized term for activation trees?). Everything I know on this topic comes from these to articles: https://medium.freecodecamp.org/the-programming-language-pipeline-91d3f449c919 https://blog.usejournal.com/writing-your-own-programming-language-and-compiler-with-JUMP_LINK__&&__python__&&__JUMP_LINK-a468970ae6df I believe ATs were covered in the first
20th Dec 2018, 11:05 PM
Myersj281
Myersj281 - avatar