concrete-syntax-tree

How do I translate LR(1) Parse into a Abstract syntax tree?

瘦欲@ 提交于 2019-12-11 03:17:51
问题 I have coded a table driven LR(1) parser and it is working very well however I am having a bit of a disconnect on the stage of turing a parse into a syntax tree/abstract syntax tree. This is a project that I m very passionate about but I have really just hit a dead end here. Thank you for your help in advance. Edit: Also my parser just uses a 2d array and an action object that tells it where to go next or if its a reduction where to go and how many items to pop. I noticed that many people use

When to use an abstract or concrete syntax tree?

馋奶兔 提交于 2019-12-07 04:11:47
问题 I've been doing research on compilers. The lexer seems to be very straight forward: Take a "sentence" and break it up into words (or tokens). To ensure correct grammar a parser is needed. The parser generally takes the tokens and builds a tree that results in a root node (words into sentences, paragraphs, pages, etc...). From this question it would seem a parser would build an AST. The AST only contains what is necessary to execute the code, so things like parentheses would be unnecessary

Parse tree and grammar information

橙三吉。 提交于 2019-12-06 02:12:26
问题 Does anyone know where to find good online resources with examples of how to make grammars and parse trees? Preferably introductory materials. Info that is n00b friendly, haven't found anything good with Google myself. Edit: I'm thinking about theory, not a specific parser software. 回答1: Not online, but maybe you should take a look at Compilers: Principles, Techniques, and Tools (2nd Edition) by Aho et al. This is a standard text that has been evolving for 30 years (if you count the 1st

When to use an abstract or concrete syntax tree?

会有一股神秘感。 提交于 2019-12-05 09:39:27
I've been doing research on compilers. The lexer seems to be very straight forward: Take a "sentence" and break it up into words (or tokens). To ensure correct grammar a parser is needed. The parser generally takes the tokens and builds a tree that results in a root node (words into sentences, paragraphs, pages, etc...). From this question it would seem a parser would build an AST. The AST only contains what is necessary to execute the code, so things like parentheses would be unnecessary since operator precedence is built into an AST. An AST is probably all a compiler needs. But what about

What is the difference between an Abstract Syntax Tree and a Concrete Syntax Tree?

一个人想着一个人 提交于 2019-11-26 05:42:26
问题 I\'ve been reading a bit about how interpreters/compilers work, and one area where I\'m getting confused is the difference between an AST and a CST. My understanding is that the parser makes a CST, hands it to the semantic analyzer which turns it into an AST. However, my understanding is that the semantic analyzer simply ensures that rules are followed. I don\'t really understand why it would actually make any changes to make it abstract rather than concrete. Is there something that I\'m