IDE and Visualisation of Abstract Syntax Trees for Coco/R

Slides:



Advertisements
Similar presentations
Compiler Construction
Advertisements

Semantics Static semantics Dynamic semantics attribute grammars
Parsing & Scanning Lecture 2 COMP /25/2004 Derek Ruths Office: DH Rm #3010.
Abstract Syntax Mooly Sagiv html:// 1.
INTERPRETER Main Topics What is an Interpreter. Why should we learn about them.
1 Contents Introduction A Simple Compiler Scanning – Theory and Practice Grammars and Parsing LL(1) Parsing LR Parsing Lex and yacc Semantic Processing.
Programming Language Semantics Mooly SagivEran Yahav Schrirber 317Open space html://
ITP © Ron Poet Lecture 1 1 IT Programming Introduction.
Prof. Bodik CS 164 Lecture 51 Building a Parser I CS164 3:30-5:00 TT 10 Evans.
1 Chapter 5 LL (1) Grammars and Parsers. 2 Naming of parsing techniques The way to parse token sequence L: Leftmost R: Righmost Top-down  LL Bottom-up.
{ Graphite Grigory Arashkovich, Anuj Khanna, Anirban Gangopadhyay, Michael D’Egidio, Laura Willson.
1 Top Down Parsing. CS 412/413 Spring 2008Introduction to Compilers2 Outline Top-down parsing SLL(1) grammars Transforming a grammar into SLL(1) form.
Lesson 3 CDT301 – Compiler Theory, Spring 2011 Teacher: Linus Källberg.
CS412/413 Introduction to Compilers and Translators Spring ’99 Lecture 8: Semantic Analysis and Symbol Tables.
Review 1.Lexical Analysis 2.Syntax Analysis 3.Semantic Analysis 4.Code Generation 5.Code Optimization.
Recursive Descent Parsers Lecture 6 Mon, Feb 2, 2004.
Your name Visualization of abstract syntax trees.
Concepts and Realization of a Diagram Editor Generator Based on Hypergraph Transformation Author: Mark Minas Presenter: Song Gu.
Parser: CFG, BNF Backus-Naur Form is notational variant of Context Free Grammar. Invented to specify syntax of ALGOL in late 1950’s Uses ::= to indicate.
COMP 3438 – Part II-Lecture 6 Syntax Analysis III Dr. Zili Shao Department of Computing The Hong Kong Polytechnic Univ.
CS 2130 Lecture 18 Bottom-Up Parsing or Shift-Reduce Parsing Warning: The precedence table given for the Wff grammar is in error.
Comp 411 Principles of Programming Languages Lecture 3 Parsing
Lecture 7 Syntax Analysis (5) Operator-Precedence Parsing
Announcements/Reading
Teaching Compiler Design
Semantic analysis Jakub Yaghob
Agenda Preliminaries Motivation and Research questions Exploring GLL
Compiler Design (40-414) Main Text Book:
COMP261 Lecture 18 Parsing 3 of 4.
Introduction to Parsing
Programming Languages Translator
CS510 Compiler Lecture 4.
Lexical and Syntax Analysis
Compiler Baojian Hua LR Parsing Compiler Baojian Hua
Unit-3 Bottom-Up-Parsing.
Introduction to Parsing (adapted from CS 164 at Berkeley)
COP 4620 / 5625 Programming Language Translation / Compiler Writing Fall 2003 Lecture 5, 09/25/2003 Prof. Roy Levow.
DATA STRUCTURES AND OBJECT ORIENTED PROGRAMMING IN C++
Top-down parsing cannot be performed on left recursive grammars.
Ch. 4 – Semantic Analysis Errors can arise in syntax, static semantics, dynamic semantics Some PL features are impossible or infeasible to specify in grammar.
Understand the Programming Process
4 (c) parsing.
Top-Down Parsing.
Basic Program Analysis: AST
Syntax Analysis Sections :.
Programming Language Syntax 7
Syntax-Directed Translation
Bottom-up derivation tree, original grammar
Bottom-up derivation tree, original grammar
Parsing & Scanning Lecture 2
ADTs, Grammars, Parsing, Tree traversals
Programming Language Syntax 5
CS 3304 Comparative Languages
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
LL and Recursive-Descent Parsing Hal Perkins Autumn 2011
CS 3304 Comparative Languages
Understand the Programming Process
Design Patterns for Recursive Descent Parsing
Programming.
Kanat Bolazar February 16, 2010
Lesson Objectives Aims Understand Syntax Analysis.
LL and Recursive-Descent Parsing Hal Perkins Autumn 2009
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
LL and Recursive-Descent Parsing Hal Perkins Winter 2008
Arrays.
COP4020 Programming Languages
COP4020 Programming Languages
Course Overview PART I: overview material PART II: inside a compiler
COP 4620 / 5625 Programming Language Translation / Compiler Writing Fall 2003 Lecture 2, 09/04/2003 Prof. Roy Levow.
Parsing CSCI 432 Computer Science Theory
Presentation transcript:

IDE and Visualisation of Abstract Syntax Trees for Coco/R Presented by: Etienne Stalmans Supervisor: Dr K Bradshaw Welcome to this, my final honours presentation. I’m sure you all (except Prof Terry) are pretty tired of hearing about Compilers , I hope to make this as exciting as possible As you all know, my project focused on Coco/R and producing improvements for it I hope to show those improvements to you and to discuss some of the results achieved

Outline Aims of the project IDE Design AST implementation Results Future extensions Questions The talk has been broken down into 5 main areas, The aims of the project – a reminder of what we set out wanting to achieve The design of the IDE and why we made the design decisions How ASTs were generated and visualised Results from our implementation Where we see this going And finally, a chance for you to hurl abuse at me. Outline

Aims Create IDE for Coco/R Automatically Generate ASTs Visualise ASTs Improve learning through visualisation We set out with three main aims for the project These were: Creating an IDE for Coco/R – as none exist at the moment Create an automatic AST creation facility Visualise the ASTs produced by the parser we generate Use the visualisation to improve user understanding and learning Aims

IDE Design Why do we need an IDE? What should be included? What should the IDE look like? How easy is the IDE to learn? Before designing the IDE, we needed to ask ourselves why do we need an IDE? Currently users work in Ultra-edit or Notepad++, save, switch to console, Do a “cmake” to compile the grammar Do a “crun” to execute the grammar As a tutor, I found most students forget to complete one of the steps, Get lost without syntax highlighting – cant find errors Struggle with current error reporting facilities How will the IDE help? Syntax highlighting – makes code more readable (debatable) Easier spotting of errors Common functions more accessible Everything happens in one place Should look like? Uncluttered Grouping of related features Implicit feedback Easy to learn IDE Design

Syntax highlighting aids readability (debatable) Visualisation of data structures Separate areas for editing and information Feedback All actions available, no need to use console

The Abstract Syntax Tree Generic Data Structure Binomial nodes Type Production Left sub-tree Right sub-tree The limitations? Requires generic structure No semantic knowledge, so don’t know what type of node needs to be constructed Type – “string literal value” Production – the non-terminal production within which this node is added Left and right sub-trees, maintain left/right recursive nature of grammar The Abstract Syntax Tree

Code Generation Coco/R automatically generates code Scanner Parser Driver How does AST generation fit in? Modify code generation routines Insert AST code according to rule-set Don’t change the scanner or driver Modify the parser generator routines to include code generation for ASTs Use similar rules to those already present in the Coco/R logic No semantic knowledge available at code gen time, room for possible extension where user includes semantic annotations? Code Generation

Visualising the AST AST generated at run-time Require a means to retrieve it Use reflection Know the data-structure Trivial to walk the tree and visualise Tree walked twice Mini-tree generated Easily extended AST is part of the generated parser, thus only available once that parser is executed Need a means of accessing it Use reflection in C# We know the data structure, makes retrieval with reflection easy Trivial to walk the tree once it is available, use pre-order traversal and draw tree Tree walked twice to get width, ect to prevent overlapping branches Generate mini-tree to use with navigation – context map This visualisation method can easily be extended to provide more/less info Draw different tree graph Visualising the AST

As can be seen, very crisp, clear tree Only necessary information presented Don’t want to overload the user

Results Correct ASTs generated for simple LL(1) grammars Errors start creeping in for more complex grammars If-then-else problem, similar to dangling else situation Incorrect tree is constructed Testing showed correct ASTs Broke down with complex grammars due to lack of semantic knowledge LL(1), so lack ability to look ahead and determine that this might be a three node subtree If-then-else not always the case, if it’s a simple if-then, tree is drawn correctly Relates to dangling else problem Results

Effect on effectiveness Reduces effectiveness as learning aid Confirms results from past studies Opens avenue for future extensions Still viable as demonstration tool Because of problems with more complex grammars And incorrect grammars, made difficult to use as learning aid Could lead to more confussion than actual understanding Confirms results from past studies, where it is stated that need to find perfect examples for visualisation to be effective Difficult to correctly visualise algorithms dynamically Due to algorithm visualisation drawing “a mental model” – makes it hard for computer to decide what should be visualised Still viable as demonstration tool – give correct grammar, will produce correct syntax tree Effect on effectiveness

Future Extensions Ability to handle more complex grammars Will require annotations Visualisation of parsing process Step-by-step visualisation Play/Pause controls Annotations – will alter goal of the system System aims to provide layer of abstraction so that user does not need to understand ASTs in order to be able to visualise AST Provide step-by-step visualisation of data structures, parse stack ect Could be useful for novice users Future Extensions

Questions?