Changes between Version 23 and Version 24 of AST


Ignore:
Timestamp:
04/20/11 14:12:33 (15 years ago)
Author:
Stephen Siegel
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • AST

    v23 v24  
    1313
    1414Questions:
    15  * How to handle pre-processor macros?   Include in AST?
    16  * How abstract should the AST be?
    17  * Should it contain semantic information, e.g., types, and variables?
    1815 * How will it handle things like (foo)*bar: this could be either a cast of *bar to type foo, or it could be the product of foo and bar; you need to know whether foo defines a type, which is some semantic information
    1916   * cf. http://www.computing.surrey.ac.uk/research/dsrg/fog/CxxGrammar.y
    2017   * approach: just choose one way, then change in later pass when analyzing
     18   * ANTLR C grammar shows how this can be handled directly in grammar by processing the typedefs as you parse
    2119 * What to do about #defines from the system (OSX, etc.)?  Determine these automatically, or take as input?
     20
     21Notes
     22 * ANTLR grammar list: http://www.antlr.org/grammar/list
     23    * includes grammars for C and for pre-processor
    2224
    2325Comments:
     
    2628 * No extern variable declarations can have initializers.
    2729 * For scoping issues with blocks, see sec 8.4 of C: A Reference Manual.
    28   * Rewrite blocks to have variables declared separately.  Replace declarations that have initializations with assignment statements.
     30 * Rewrite blocks to have variables declared separately.  Replace declarations that have initializations with assignment statements.
     31
    2932Example:
    3033{{{
     
    3538}
    3639}}}
    37 In the AST, translate this to:
     40should be translated to an AST that looks like:
    3841 * Root
    3942  * Globals: x
     
    4447      * int
    4548    * Stmt
    46      * print x
     49     * print x /* the global x */
    4750     * x = 2
    48      * print x
     51     * print x /* the local x */
     52
     53In other words, in the AST for the block, all the variable decls that occur anywhere in the block are grouped together under one node in the block.   The initializers, however, are translated to statements at the point where the variable was declared in the original source.  So in the end, local variables should not have any initializers associated to them.
     54
    4955== Elements of a TASS AST ==
    5056