Does LCC build abstract syntax tree?

  • Permalink
  • submit to reddit
  • Email
  • Follow


I find a paper (http://drhanson.s3.amazonaws.com/storage/documents/
lean.pdf) that saying (on page 21)  that one of mistakes is LCC
doesn't have an AST.
I am confused here - isn't the Tree struct defined in C.h the AST?
There is no nodes in that tree build to represent none terminals, and
it looks to me the exact kind of AST...

Could some one on the list please answer my (possibly stupid) question?
0
Reply lianghancn (3) 9/22/2009 3:12:48 AM

See related articles to this posting


The link I posted is broken due to some reasons.. the paper can be
found on the LCC site http://www.cs.princeton.edu/software/lcc/doc/index.html
Under the "Talk" category.

0
Reply Qubeley 9/22/2009 3:18:48 AM
comp.compilers.lcc 1251 articles. 0 followers. Post

1 Replies
300 Views

Similar Articles

[PageSpeed] 9


  • Permalink
  • submit to reddit
  • Email
  • Follow


Reply:

Similar Artilces:

build a syntax tree
Hi I've some trivial question: for exercise I want to parse a string that like this: "x -34 + 65 * 96 = 102" now if I had this ("(25+24)/2") is extremely easy to have a result but I want to resolve the above string (for the 'x' variable) what can I do? Especially for symbolic function I think that I've to build an 'operations tree' with a variable table. I want to know how Derive parse this kind of string. If I've to build a tree, please give me resources and/or examples of what physically is a tree and how to build on python. Thanks :) ...

C++ Abstract Syntax Tree
Is there to your knowledge any existing free C++ open source code that parses C++ code and generates an abstract syntax tree? Thanks Wouter Lievens wrote: > Is there to your knowledge any existing free C++ open source code that > parses C++ code and generates an abstract syntax tree? I think there's some grammar for PCCTS 1.x (looak at www.antlr.org). PCCTS generates C++ code so that would be what you need. rgds Sebastian Kaliszewski "Wouter Lievens" <lievenswouter@snotmail.com> wrote > Is there to your knowledge any existing free C++ open source code that &g...

Abstract Syntax Tree conundrum
Hello, It looks like the compiler and parser modules both implement Python ASTs. Is one of these preferred over the other, or do they play different roles? What I'm trying to do is this- (1) Inspect a block of python source (2) Execute selected statements from the source The compiler's AST implementation seems better for (1), but I can't for the life of me figure out how to compile it into a code object, and there's not even an apparent way to convert it back into source (I suppose I could write a function to do this, but it seems like there should be a better way). On the...

RM and abstract syntax trees
In the following I compare different techniques for representing an Abstract Syntax Tree (AST), concluding that RM is poorly suited. In LISP, S-expressions (parenthesized lists) are well suited to representing ASTs because S-expressions naturally nest, allow for native representation of data types like 32 bit integers, and symbolic names allow for AST nodes to be tagged with their type. S-expressions are implemented using pointers. The interesting thing is that the use of pointers is hidden from the programmer. For example, it is impossible to print the address of a cons cell. ...

concrete vs. abstract syntax trees
Hello, I'm trying to nail down the difference between concrete and abstract syntax trees. In my C parser (http://code.google.com/p/pycparser/) I construct an AST directly from the parser (which uses the yacc-like PLY Python module), and I'm not sure where the concrete syntax tree is in that process. Is this correct to say that if I semi-mechanically translate the BNF of a language to a yacc grammar, what I'll get from parsing is a concrete syntax tree? If so, this tree is almost useless for any kind of interesting interaction (especially for languages like C where some things lik...

Good Representation for an Abstract Syntax Tree
I'm in the process of writing an interpreter for lambda calculus (i.e. a small functional programming language) in C. I've previously written one in Haskell so I understand at least some of the concepts involved in writing an interpreter and I know how to define a grammar and use lex/yacc to parse it. What I don't know is how to represent the abstract syntax tree (AST) of my language in C. In Haskell I used what's called an algebraic data type like so: data Exp = Lam Id Exp | Var Id | App Exp Exp | Lit Int Legend: Exp - expression (i.e. one of Lam, ...

Abstract Syntax Trees, Semantic Analysis
Anyone here familiar with abstract syntax trees in doing semantic analysis? -- I use CodeWorker to build parse trees and to do semantic analysis. CodeWorker is a parsing tool and a source code generator, available under the LGPL lisence at "http://www.codeworker.org". Perhaps could you have a look... "news.tkdsoftware.com" <chris@noreply.nospam.tkdsoftware.com> wrote in message news:<wcNNTP.01c4a6f8.689f0a10.1011.0@tkdsoftware.com>... > Anyone here familiar with abstract syntax trees in doing semantic analysis? > > -- "news.tkdsoftware.c...

Building the syntax tree for the interpreter pattern
Hi, I need to implement the interpreter for a simple langauge: "arithmetic operators (+, -, *, / ) or an integer are a terminal expression a full line of input passed to the parser to be our only non-terminal expression." ("3+4-6\7*-9...") as i understand the non terminal expression contain a list of of other expressions for which it call an operation(supposly ''Evaluate' in this case) So i am thinking of a parser object which parse the input and build the tree of the expression Where should the parser exist? should it be outside of the none ...

representing functions with arguments in an abstract syntax tree
Hello, I'm attempting to build an interpreter for a pascal-like language. Currently, I don't generate any assembly. Instead, I just build an abstract syntax tree representing what I've parsed from a user's program and use a C backend to evaluate the tree. I'm using Lex, Yacc and C. Now, there are some functions that are built into this language and others which are not. The problem I'm having is that I haven't found a way to represent functions and handle generating their arguments. For example, an example code block in this language looks like: if (cpu_temp >...

Parsing expressions directly into an abstract syntax tree
I have been working out an algorithm to parse expressions directly into an abstract syntax tree, in a way that allows you to give the parser arbitrary prefix, postfix, and infix operators, specifying the precedence and associativity for each operator. The parsing itself is done from left-to-right, with one lookahead token, and very little recursion. (recursion only happens when encountering a parenthesized sub-expression, and even that could be done away with fairly easily) As far as I can tell, what I've got so far is something very similar to operator precedence bottom-up parsing, but ...

Design Pattern for creating Abstract Syntax Tree??
Interpreter Pattern should be used when there is a language to interpret,and we can represent statements in the language as Abstract Syntax Trees. But, my requirement is to create the Abstract Syntax Tree itself. What pattern can be used in that case? qazmlp wrote: > Interpreter Pattern should be used when there is a language to > interpret,and we can represent statements in the language as Abstract > Syntax Trees. > > But, my requirement is to create the Abstract Syntax Tree itself. What > pattern can be used in that case? Create it from what? If from a language, the pa...

Common Lisp, the abstract syntax tree, introspection.
With common lisp and I am assuming the introspection properties. How can I add code to common lisp code that will tell me when a function is called and when has finished executing. I want to take any lisp code and this particular modification to the code. I figure with lisp's AST analysis, this should be possible. For example, pseudo code, hello_world.lisp: (defun hello-world () (format t "Hello World")) (hello-world) ---- And then I have a utility to load hello_world.lisp and execute the hello-world call. At the command line: #Inspect: hello-world function was called ...

Wanted: Spec for the Abstract Syntax Tree for JavaScript
Hi This is a bit theoretical for this group, but let's try anyway. I'm writing yet another Python to JavaScript translator (yawn) and would like to do it via abstract syntax trees (AST). http://en.wikipedia.org/wiki/Abstract_syntax_tree http://code.google.com/p/js4py/source/browse/trunk/sandbox/py2js-v02/ With Python, since 2.5, compilation proceeds via an AST, which is available from within a Python script. http://docs.python.org/library/ast.html The key thing there is a file Python.asdl, which describes the abstract syntax of Python. I wish to create a similar file...

Bison: reentrant C++ abstract-syntax-tree parser
I'm trying to use bison to make an abstract syntax tree. I'm trying to do it in a nice C++ sort of way. But I'm finding it very difficult, and would really find it helpful if someone could point me to an example of "best practice". I'd really like to just return an object in response to a grammar rule, like I did with JavaCC. But bison wants to put all possible return types in a union, and it's not allowed to put a class in a union, so I can't. I found some examples which used pointers instead. So when the grammar matched a rule, it created a new instance of...

ML-Yacc abstract syntax tree source position
I've got a grammar for ML-Yacc, whose third clause (after the second %%) is as follows: program : exp (exp) exp : decs (A.LetExp {decs = decs, body = A.NilExp, pos = ????}); decs : dec (dec :: []) decs : dec decs (dec :: decs) dec : tydec (tydec) tydec : TYPE ID EQ ty (A.TypeDec [{name = symbol ID1, ty = ty, pos = TYPE1left}]) ty : ID (A.NameTy (symbol ID1, ID1left)) The grammar is in-progress, so the rules (such as the exp rule) will look quite...

Generating Code for Compound Conditional Expressions from an Abstract Syntax Tree?
Does anyone know of any links to any really good examples of: Generating Code for Compound Conditional Expressions from an Abstract Syntax Tree? seescreen@gmail.com writes: > Does anyone know of any links to any really good examples of: > Generating Code for Compound Conditional Expressions from an Abstract > Syntax Tree? Read chapter 7 of "Basics of Compiler Design", which you can download from http://www.diku.dk/~torbenm/Basics/ . It shows how logical expressions, including sequential operators, can be compiled. Torben On Jun 3, 12:42 am, seescr...@gmail.com wrote...

Re: ** ML-Yacc abstract syntax tree source position
On 20 Aug 2005, Denis Bueno wrote: > exp : decs (A.LetExp {decs = decs, > body = A.NilExp, > pos = ????}); > The grammar is in-progress, so the rules (such as the exp rule) will > look quite different when I'm actually done. The problem is that I have > no idea what position I should use for ???? above. Try decsleft or decsright. See the rule for ty' in 110.0.7/sml-nj/parse/ml.grm for an example of such usage. Roger ...

Re: ** ML-Yacc abstract syntax tree source position #3
On 25 Aug 2005, Brian Hulley wrote: > I've noticed a strange thing with ML-yacc: the right position of any > non-terminal is just bound to zero even though the left positions are > propagated correctly. (For terminals both left and right are correctly > propagated) Thus for example in the rule: > > exp4n: exp5n ARROW exp4n (PT.PT(PT.FUNTYPE(exp5n, exp4n), exp5nleft, > exp4nright)) > > exp4nright (and exp4n1right) is always zero... Perhaps a bug in > ML-yacc? It works for me. In the runn...

Re: ** ML-Yacc abstract syntax tree source position #2
On 20 Aug 2005, Denis Bueno wrote: > I've got a grammar for ML-Yacc, whose third clause (after the second > %%) is as follows: I struggled with ML-Lex and ML-Yacc and ended up merging the documentation into my own notes to produce a "User's Guide to ML-Lex and ML-Yacc", 66 pages. This contains a fully worked example, an index, and is GPLed. http://rogerprice.org/ug/ug.pdf Best Regards, Roger Roger Price wrote: > On 20 Aug 2005, Denis Bueno wrote: > > > I've got a grammar for ML-Yacc, whose third clause (after the second > &g...

Excellent example of code generation from abstract syntax trees using Lex and Yacc
http://www.epaperpress.com/lexandyacc/index.html This is the most succinct example of code generation that I have ever encountered. It includes an interpreter, a code generator, and graphical output of the abstract syntax tree diagram. Because of this one example I finally understand the best way to generate code. I have struggled with obtaining this knowledge for twenty years carefully studying the relevant chapters of the Dragon book. Now finally with one succinct example, I got it. I want to make sure that I share this information in a way that others can most easily reach it. I have r...

ANN compiler2 : Produce bytecode from Python 2.5 Abstract Syntax Trees
Announcing: compiler2 --------------------- For all you bytecode enthusiasts: 'compiler2' is an alternative to the standard library 'compiler' package, with several advantages. Improved pure-python compiler - Produces identical bytecode* to the built-in compile function for all /Lib and Lib/test modules, including 'peephole' optimizations - Works with 2.5's 'factory-installed' ASTs, rather than 2.4's 'after-market' version - Is significantly faster * Except for the pesky stack-depth calculation Possible applications - Understan...

LiveAST: a pure Ruby 1.9.2 library obtaining live abstract syntax trees
= LiveAST == Summary A pure Ruby library for obtaining live abstract syntax trees of methods and procs. == Synopsis require 'live_ast' class Greet def default "hello" end end #### ASTs of methods m = Greet.instance_method(:default) p m.to_ast # => s(:defn, :default, s(:args), s(:scope, s(:block, # s(:str, "hello")))) #### ASTs of lambdas, procs, blocks f = lambda { "foo" } p f.to_ast # => s(:iter, s(:call, nil, :lambda, s(:arglist)), nil, # s(:str, "foo&quo...

Need to build a tree buttom-up (parse tree)
Hello out there, continuing my adventures with "Parsing C" :) I need to build a parse tree. Now these trees are built "buttom-up": for an expression like 8 + 7 * 5 one would build a tree like + /\ 8 * /\ 7 5 that is, starting at the simplest components and building up more complex structures. Now I would love to use struct::tree from tcllib, but I don't see a way to use it in this context. Seems to me, there you start out with a root node - thus building the tree "top-down". Q 1) Is there a way to use struct::tree for what I need here? Q 2) if { ...

about syntax trees
Hello, I'm relatively new to parsing. I've managed to code a recursive-descent ll(1) parser in c (thus, a stack/table based one). My question is about syntax trees. If I trace each accepting operation with a printf, this is what I get for the expression: a+b*c accept on: a accept on: + accept on: b accept on: * accept on: c However I can see ast's being more like this all over the place: + /|\ b | a * c But I cannot think of a way you get exactly this, any pointers or advises? thanks so much. On Mar 19, 8:40 pm, chinlu chinawa <chinluchin...@yahoo.co.uk> wrote: ...