Changes between Version 23 and Version 24 of AST
- Timestamp:
- 04/20/11 14:12:33 (15 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
AST
v23 v24 13 13 14 14 Questions: 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?18 15 * 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 19 16 * cf. http://www.computing.surrey.ac.uk/research/dsrg/fog/CxxGrammar.y 20 17 * 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 21 19 * What to do about #defines from the system (OSX, etc.)? Determine these automatically, or take as input? 20 21 Notes 22 * ANTLR grammar list: http://www.antlr.org/grammar/list 23 * includes grammars for C and for pre-processor 22 24 23 25 Comments: … … 26 28 * No extern variable declarations can have initializers. 27 29 * 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 29 32 Example: 30 33 {{{ … … 35 38 } 36 39 }}} 37 In the AST, translate this to:40 should be translated to an AST that looks like: 38 41 * Root 39 42 * Globals: x … … 44 47 * int 45 48 * Stmt 46 * print x 49 * print x /* the global x */ 47 50 * x = 2 48 * print x 51 * print x /* the local x */ 52 53 In 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 49 55 == Elements of a TASS AST == 50 56
