programming language independent abstract syntax trees
play

Programming Language Independent Abstract Syntax Trees Nordic - PowerPoint PPT Presentation

Programming Language Independent Abstract Syntax Trees Nordic Workshop on Programming Theory 2003 Karl Trygve Kalleberg <karltk@ii.uib.no> Magne Haveraaen <magne@ii.uib.no> Department of Informatics University of Bergen, Norway


  1. Programming Language Independent Abstract Syntax Trees Nordic Workshop on Programming Theory 2003 Karl Trygve Kalleberg <karltk@ii.uib.no> Magne Haveraaen <magne@ii.uib.no> Department of Informatics University of Bergen, Norway

  2. Overview ● Motivation – Better understand common/emerging ● Programming concepts ● Language properties – Language tool interoperability ● Transformation ● Refactoring ● Approach – Analysis + synthesis  formalism

  3. CSTs and ASTs A = 42 + 23; Stmt Expr SEMI Assign BinaryOp Var Plus Expr EQUAL Expr BinaryOp Id Integer Integer A A Expr Expr PLUS 42 23 Integer Integer 42 23

  4. Programming languages vs programming concepts language ( λ x. Display x) “Hello world” ++++++++[>+++++++++<-]>.<+++++[>++++++<-]>-.+++++++.. +++.<++++++++[>>++++<<-]>>.<<++++[>------<-]>.<++++[> ++++++<-]>.+++.------.--------.>+.

  5. Language evolution ● New concepts expressed through – Idioms ● language-specific recipies – Patterns ● recipies common to a class of languages ● New concepts require – Adaptation to existing semantics – Possibly new syntax

  6. Evolution: if + goto label: while (cond) { ... code ... ... code ... if (cond) goto label; } if (!cond) goto label1; if (cond) { ... code ... ... code ... goto label2 } else { label1: ... code ... ... code ... } label2:

  7. Evolution: assertions ● Assertions in Java 1.4 if (!cond) throw new AssertionError(stringExpr); assert cond : stringExpr;

  8. Evolution: contracts ● Pre/post conditions and class-invariants in Eiffel func(arg: TYPE) is require boolean-expression ... do body ... ensure boolean-expression ... end

  9. Use case: CodeBoost Refine to obtain accurate information Perform transformation Emit code AST AST CST CST Source code CST CST Source code

  10. Accurate information ● for(exp1; exp2; exp3) body; ● Undecideable termination ● Sugar for exp1; while(exp2){body; exp3;} ● for x in [1,2,3]: body ● Will always terminate ● map( λ x.body, [1,2,3])

  11. Structuring and reuse ● Many concepts – Classes, inheritance, aspects, coordination, patterns, best practices ● Fewer constructs – package , class , template ● Experimentation easier at the abstract level – Not compounded by syntax – Allows domain-specific structuring

  12. Conclusion ● Build more abstract AST using accurate information – Support language evolution in tandem with concept evolution – Increase convenience for tools – Simplify reasoning for programmer ● Not a new language! – Represented in contemporary languages

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend