SlideShare a Scribd company logo
An Annotation Framework for Statically-Typed Syntax Trees Loren Abrams  Ray Toal Loyola Marymount University Los Angeles CA USA IASTED SEA 2009 2009-11-03
Outline Overview Previous Work Motivating Example Some Theoretical Contributions An Annotation Framework Implementation of a Parser Generator Conclusions
Goals To contribute to parser generation theory and practice with a grammar annotation framework that is Terse (more convention, less markup) Fully declarative Grammar-independent Supportive of statically typed host languages To demonstrate feasibility with a prototype parser generator
Contributions A grammar-independent annotation  framework  (not “just another generator”) Distillation of embedded abstract syntax tree specification (useful for understanding) Definition of  statically-typed  AST specification Prototype parser generator  very lightweight self-contained, easy to integrate
Previous Research Grammars : CFG, (E)BNF, XBNF, SDF, PEG Parser Generators : Lex/Yacc, Flex/Bison, JavaCC, AntLR, SableCC,  Rats! Tree Builders : JTB, JJTree Parser Generation Design Axes Concrete vs. Abstract Tree Production Static vs. Dynamic Typing Inline vs. External Specification
Motivating Example (1 of 2) Given a grammar such as this one... ID  => @[A-Za-z][A-Za-z0-9_]+ NUMLIT  => @\d+(\.\d+([Ee][+-]?\d+)?)? STRLIT  => @"[^"\p{Cc}]*" SKIP  => @\s+ Program => Block Block  => (Dec ";")* (Stmt ";")+ Dec  => "var" ID ("=" Exp)? | "fun" ID "(" IdList? ")" "=" Exp Stmt  => ID "=" Exp |  "read" IdList |  "write" ExpList |  "while" Exp "do" Block "end" IdList  => ID ("," ID)*  ExpList => Exp ("," Exp)* Exp  => Term (("+" | "-") Term)* Term  => Factor (("*" | "/") Factor)* Factor  => NUMLIT | STRLIT | ID | Call | "(" Exp ")" Call  => ID "(" ExpList? ")"
Motivating Example (2 of 2) ...we want to annotate the grammar to produce  statically-typed  ASTs var y; fun half(x) = x / 2; while x - (5 * x) do write half(10.4), x+2; read x; end;
Describing the ASTs Each node in the generated AST is an object of some AST node class The fields of each object are name-value pairs, with values we define recursively as being The value  null Strings (which come from token literals) References to nodes Lists of values
Annotating the Grammar Our contribution is to exhibit a high-level approach to annotation The approach must be fully declarative and support statically typed ASTs The key idea is to ensure each type of value (on the previous slide) is producible Our current work is only for  embedded  annotations, but it should extend to AST descriptions  external  to the grammar
Annotation Highlights Each rule execution produces a value (null, string, node-ref, list) We  tag  syntax elements and AST node expressions: tags become field names Expressions not tagged get the name of the construct (convention!) Different tag binding symbols for scalar and list values Simple notation for node class hierarchies
Annotation Example (1 of 3) Value of rule is last value produced params  is a scalar variable;  decs  and  stmts  are list variables;  block ,  exp  are implicit variables Var  and  Fun  are subclasses of  Dec Note how some values can be null Program => Block {Program block} Block  => ( decs *: Dec  ";")* ( stmts *: Stmt  ";")+  {Block  decs   stmts } Dec   => " var " ID ("="  Exp )? {Var:Dec id  exp } |  "fun" ID "(" params:IdList? ")" "="  Exp {Fun:Dec id  params   exp }
Annotation Example (2 of 3) Value of  IdList  is just the value of  id left  is a scalar variable, note how it gets “reassigned” Stmt  => ID "=" Exp {Assign:Stmt id exp} |  "read" IdList {Read:Stmt idList} |  "write" ExpList {Write:Stmt expList} |  "while" Exp "do" Block "end" {While:Stmt exp block} IdList  => id*:ID ("," id*:ID)* ExpList => exp*:Exp ("," exp*:Exp)* Exp  => left:Term (op:("+" | "-") right:Term left:{Bin:Exp op left right} )* Term  => left:Factor (op:("*" | "/") right:Factor left:{Bin:Exp op left right} )*
Annotation Example (3 of 3) Used  value  since  numlit  and  strlit  would not be nice field names Type of  Factor  rule is  Exp  (most general superclass) ^exp  required to avoid  “)”  as the value Factor  => value:NUMLIT {NumLit:Exp value} |  value:STRLIT {StrLit:Exp value} |  ID {Ref:Exp id} |  Call |  "(" Exp ")" ^exp Call  => ID "(" args:ExpList? ")" {Call:Exp id args}
Parser Generator Implementation A parser generator reads a description (like the one on the last three slides) and outputs A scanner A parser, producing an AST (only) A set of AST node classes, each with setters, getters, and (possibly) visit methods A visitor framework for using the generated AST (without touching the tree classes, of course) Interesting implementation : token set, types, etc. are  computed  (inference algorithm)
Prototype Implementation (1 of 2) Initial implementation is a proof of concept Description elements fixed, not yet pluggable : for scalar binding *: for list binding { } for node expressions : for subclassing Produces incomplete parsers, though scanner, tree classes, and navigation are fully implemented.
Prototype Implementation (2 of 2) Java only Microsyntax specification uses Java regexes (nice) Packaged as altgen-m-n.jar (m and n are version numbers)  — under 5 0KB Further info at http://xlg.cs.lmu.edu/altgen Planned open source distribution at Google Code
Summary Presentation of a terse, declarative, grammar-independent annotation framework for the generation of statically type abstract syntax trees Presentation of a prototype parser generator using the framework Java implementation of the prototype is only 50KB
Questions?
Ad

More Related Content

What's hot (20)

Compiler Construction | Lecture 8 | Type Constraints
Compiler Construction | Lecture 8 | Type ConstraintsCompiler Construction | Lecture 8 | Type Constraints
Compiler Construction | Lecture 8 | Type Constraints
Eelco Visser
 
CS4200 2019 | Lecture 4 | Syntactic Services
CS4200 2019 | Lecture 4 | Syntactic ServicesCS4200 2019 | Lecture 4 | Syntactic Services
CS4200 2019 | Lecture 4 | Syntactic Services
Eelco Visser
 
Regular expressions in Python
Regular expressions in PythonRegular expressions in Python
Regular expressions in Python
Sujith Kumar
 
Php basics
Php basicsPhp basics
Php basics
hamfu
 
Python language data types
Python language data typesPython language data types
Python language data types
Hoang Nguyen
 
Java 8 Lambda Built-in Functional Interfaces
Java 8 Lambda Built-in Functional InterfacesJava 8 Lambda Built-in Functional Interfaces
Java 8 Lambda Built-in Functional Interfaces
Ganesh Samarthyam
 
Declare Your Language: Syntax Definition
Declare Your Language: Syntax DefinitionDeclare Your Language: Syntax Definition
Declare Your Language: Syntax Definition
Eelco Visser
 
Denis Lebedev, Swift
Denis  Lebedev, SwiftDenis  Lebedev, Swift
Denis Lebedev, Swift
Yandex
 
Clean code _v2003
 Clean code _v2003 Clean code _v2003
Clean code _v2003
R696
 
Declare Your Language: Transformation by Strategic Term Rewriting
Declare Your Language: Transformation by Strategic Term RewritingDeclare Your Language: Transformation by Strategic Term Rewriting
Declare Your Language: Transformation by Strategic Term Rewriting
Eelco Visser
 
Introduction To Python
Introduction To  PythonIntroduction To  Python
Introduction To Python
shailaja30
 
Scala is java8.next()
Scala is java8.next()Scala is java8.next()
Scala is java8.next()
daewon jeong
 
Javaz. Functional design in Java 8.
Javaz. Functional design in Java 8.Javaz. Functional design in Java 8.
Javaz. Functional design in Java 8.
Vadim Dubs
 
Learn Python The Hard Way Presentation
Learn Python The Hard Way PresentationLearn Python The Hard Way Presentation
Learn Python The Hard Way Presentation
Amira ElSharkawy
 
Java q ref 2018
Java q ref 2018Java q ref 2018
Java q ref 2018
Christopher Akinlade
 
Modern C++ Explained: Move Semantics (Feb 2018)
Modern C++ Explained: Move Semantics (Feb 2018)Modern C++ Explained: Move Semantics (Feb 2018)
Modern C++ Explained: Move Semantics (Feb 2018)
Olve Maudal
 
Declare Your Language: Name Resolution
Declare Your Language: Name ResolutionDeclare Your Language: Name Resolution
Declare Your Language: Name Resolution
Eelco Visser
 
Compiler Construction | Lecture 4 | Parsing
Compiler Construction | Lecture 4 | Parsing Compiler Construction | Lecture 4 | Parsing
Compiler Construction | Lecture 4 | Parsing
Eelco Visser
 
Java 8 Lambda Expressions
Java 8 Lambda ExpressionsJava 8 Lambda Expressions
Java 8 Lambda Expressions
Scott Leberknight
 
Introduction to Python - Part Two
Introduction to Python - Part TwoIntroduction to Python - Part Two
Introduction to Python - Part Two
amiable_indian
 
Compiler Construction | Lecture 8 | Type Constraints
Compiler Construction | Lecture 8 | Type ConstraintsCompiler Construction | Lecture 8 | Type Constraints
Compiler Construction | Lecture 8 | Type Constraints
Eelco Visser
 
CS4200 2019 | Lecture 4 | Syntactic Services
CS4200 2019 | Lecture 4 | Syntactic ServicesCS4200 2019 | Lecture 4 | Syntactic Services
CS4200 2019 | Lecture 4 | Syntactic Services
Eelco Visser
 
Regular expressions in Python
Regular expressions in PythonRegular expressions in Python
Regular expressions in Python
Sujith Kumar
 
Php basics
Php basicsPhp basics
Php basics
hamfu
 
Python language data types
Python language data typesPython language data types
Python language data types
Hoang Nguyen
 
Java 8 Lambda Built-in Functional Interfaces
Java 8 Lambda Built-in Functional InterfacesJava 8 Lambda Built-in Functional Interfaces
Java 8 Lambda Built-in Functional Interfaces
Ganesh Samarthyam
 
Declare Your Language: Syntax Definition
Declare Your Language: Syntax DefinitionDeclare Your Language: Syntax Definition
Declare Your Language: Syntax Definition
Eelco Visser
 
Denis Lebedev, Swift
Denis  Lebedev, SwiftDenis  Lebedev, Swift
Denis Lebedev, Swift
Yandex
 
Clean code _v2003
 Clean code _v2003 Clean code _v2003
Clean code _v2003
R696
 
Declare Your Language: Transformation by Strategic Term Rewriting
Declare Your Language: Transformation by Strategic Term RewritingDeclare Your Language: Transformation by Strategic Term Rewriting
Declare Your Language: Transformation by Strategic Term Rewriting
Eelco Visser
 
Introduction To Python
Introduction To  PythonIntroduction To  Python
Introduction To Python
shailaja30
 
Scala is java8.next()
Scala is java8.next()Scala is java8.next()
Scala is java8.next()
daewon jeong
 
Javaz. Functional design in Java 8.
Javaz. Functional design in Java 8.Javaz. Functional design in Java 8.
Javaz. Functional design in Java 8.
Vadim Dubs
 
Learn Python The Hard Way Presentation
Learn Python The Hard Way PresentationLearn Python The Hard Way Presentation
Learn Python The Hard Way Presentation
Amira ElSharkawy
 
Modern C++ Explained: Move Semantics (Feb 2018)
Modern C++ Explained: Move Semantics (Feb 2018)Modern C++ Explained: Move Semantics (Feb 2018)
Modern C++ Explained: Move Semantics (Feb 2018)
Olve Maudal
 
Declare Your Language: Name Resolution
Declare Your Language: Name ResolutionDeclare Your Language: Name Resolution
Declare Your Language: Name Resolution
Eelco Visser
 
Compiler Construction | Lecture 4 | Parsing
Compiler Construction | Lecture 4 | Parsing Compiler Construction | Lecture 4 | Parsing
Compiler Construction | Lecture 4 | Parsing
Eelco Visser
 
Introduction to Python - Part Two
Introduction to Python - Part TwoIntroduction to Python - Part Two
Introduction to Python - Part Two
amiable_indian
 

Viewers also liked (8)

Yil_sonu_proje_sunusu
Yil_sonu_proje_sunusuYil_sonu_proje_sunusu
Yil_sonu_proje_sunusu
Mehmet Arslan
 
Semantic analyzer for marathi text
Semantic analyzer for marathi textSemantic analyzer for marathi text
Semantic analyzer for marathi text
eSAT Journals
 
sCode optimization
sCode optimizationsCode optimization
sCode optimization
Satyamevjayte Haxor
 
Lecture 10 semantic analysis 01
Lecture 10 semantic analysis 01Lecture 10 semantic analysis 01
Lecture 10 semantic analysis 01
Iffat Anjum
 
Ch5a
Ch5aCh5a
Ch5a
kinnarshah8888
 
Lecture 11 semantic analysis 2
Lecture 11 semantic analysis 2Lecture 11 semantic analysis 2
Lecture 11 semantic analysis 2
Iffat Anjum
 
Syntax and semantics of propositional logic
Syntax and semantics of propositional logicSyntax and semantics of propositional logic
Syntax and semantics of propositional logic
Janet Stemwedel
 
sampling methods in research design
sampling  methods in research designsampling  methods in research design
sampling methods in research design
Tesfahunegn Minwuyelet
 
Yil_sonu_proje_sunusu
Yil_sonu_proje_sunusuYil_sonu_proje_sunusu
Yil_sonu_proje_sunusu
Mehmet Arslan
 
Semantic analyzer for marathi text
Semantic analyzer for marathi textSemantic analyzer for marathi text
Semantic analyzer for marathi text
eSAT Journals
 
Lecture 10 semantic analysis 01
Lecture 10 semantic analysis 01Lecture 10 semantic analysis 01
Lecture 10 semantic analysis 01
Iffat Anjum
 
Lecture 11 semantic analysis 2
Lecture 11 semantic analysis 2Lecture 11 semantic analysis 2
Lecture 11 semantic analysis 2
Iffat Anjum
 
Syntax and semantics of propositional logic
Syntax and semantics of propositional logicSyntax and semantics of propositional logic
Syntax and semantics of propositional logic
Janet Stemwedel
 
Ad

Similar to An Annotation Framework for Statically-Typed Syntax Trees (20)

Lec 1-Introduction.ppt power point of intro
Lec 1-Introduction.ppt power point of introLec 1-Introduction.ppt power point of intro
Lec 1-Introduction.ppt power point of intro
rabiyanaseer1
 
Gunosy.go #4 go
Gunosy.go #4 goGunosy.go #4 go
Gunosy.go #4 go
Taku Fukushima
 
Convention-Based Syntactic Descriptions
Convention-Based Syntactic DescriptionsConvention-Based Syntactic Descriptions
Convention-Based Syntactic Descriptions
Ray Toal
 
Falcon初印象
Falcon初印象Falcon初印象
Falcon初印象
勇浩 赖
 
Pseudo dynamic immutable records in C++
Pseudo dynamic immutable records in C++Pseudo dynamic immutable records in C++
Pseudo dynamic immutable records in C++
ant_pt
 
Beginning Scala Svcc 2009
Beginning Scala Svcc 2009Beginning Scala Svcc 2009
Beginning Scala Svcc 2009
David Pollak
 
Domain Specific Languages In Scala Duse3
Domain Specific Languages In Scala Duse3Domain Specific Languages In Scala Duse3
Domain Specific Languages In Scala Duse3
Peter Maas
 
Open Source Compiler Construction for the JVM [LCA2011 Miniconf]
Open Source Compiler Construction for the JVM [LCA2011 Miniconf]Open Source Compiler Construction for the JVM [LCA2011 Miniconf]
Open Source Compiler Construction for the JVM [LCA2011 Miniconf]
Tom Lee
 
Scala 2 + 2 > 4
Scala 2 + 2 > 4Scala 2 + 2 > 4
Scala 2 + 2 > 4
Emil Vladev
 
Ch2
Ch2Ch2
Ch2
kinnarshah8888
 
Python 3000
Python 3000Python 3000
Python 3000
Alexandro Colorado
 
ANSI C REFERENCE CARD
ANSI C REFERENCE CARDANSI C REFERENCE CARD
ANSI C REFERENCE CARD
Tia Ricci
 
Javascript2839
Javascript2839Javascript2839
Javascript2839
Ramamohan Chokkam
 
Json
JsonJson
Json
elliando dias
 
ITU - MDD - XText
ITU - MDD - XTextITU - MDD - XText
ITU - MDD - XText
Tonny Madsen
 
Summary of C++17 features
Summary of C++17 featuresSummary of C++17 features
Summary of C++17 features
Bartlomiej Filipek
 
XPath - XML Path Language
XPath - XML Path LanguageXPath - XML Path Language
XPath - XML Path Language
yht4ever
 
Strings v.1.1
Strings v.1.1Strings v.1.1
Strings v.1.1
BG Java EE Course
 
The Kotlin Programming Language
The Kotlin Programming LanguageThe Kotlin Programming Language
The Kotlin Programming Language
intelliyole
 
Embedded Typesafe Domain Specific Languages for Java
Embedded Typesafe Domain Specific Languages for JavaEmbedded Typesafe Domain Specific Languages for Java
Embedded Typesafe Domain Specific Languages for Java
Jevgeni Kabanov
 
Lec 1-Introduction.ppt power point of intro
Lec 1-Introduction.ppt power point of introLec 1-Introduction.ppt power point of intro
Lec 1-Introduction.ppt power point of intro
rabiyanaseer1
 
Convention-Based Syntactic Descriptions
Convention-Based Syntactic DescriptionsConvention-Based Syntactic Descriptions
Convention-Based Syntactic Descriptions
Ray Toal
 
Falcon初印象
Falcon初印象Falcon初印象
Falcon初印象
勇浩 赖
 
Pseudo dynamic immutable records in C++
Pseudo dynamic immutable records in C++Pseudo dynamic immutable records in C++
Pseudo dynamic immutable records in C++
ant_pt
 
Beginning Scala Svcc 2009
Beginning Scala Svcc 2009Beginning Scala Svcc 2009
Beginning Scala Svcc 2009
David Pollak
 
Domain Specific Languages In Scala Duse3
Domain Specific Languages In Scala Duse3Domain Specific Languages In Scala Duse3
Domain Specific Languages In Scala Duse3
Peter Maas
 
Open Source Compiler Construction for the JVM [LCA2011 Miniconf]
Open Source Compiler Construction for the JVM [LCA2011 Miniconf]Open Source Compiler Construction for the JVM [LCA2011 Miniconf]
Open Source Compiler Construction for the JVM [LCA2011 Miniconf]
Tom Lee
 
ANSI C REFERENCE CARD
ANSI C REFERENCE CARDANSI C REFERENCE CARD
ANSI C REFERENCE CARD
Tia Ricci
 
XPath - XML Path Language
XPath - XML Path LanguageXPath - XML Path Language
XPath - XML Path Language
yht4ever
 
The Kotlin Programming Language
The Kotlin Programming LanguageThe Kotlin Programming Language
The Kotlin Programming Language
intelliyole
 
Embedded Typesafe Domain Specific Languages for Java
Embedded Typesafe Domain Specific Languages for JavaEmbedded Typesafe Domain Specific Languages for Java
Embedded Typesafe Domain Specific Languages for Java
Jevgeni Kabanov
 
Ad

More from Ray Toal (6)

Git workshop
Git workshopGit workshop
Git workshop
Ray Toal
 
Learning and Modern Programming Languages
Learning and Modern Programming LanguagesLearning and Modern Programming Languages
Learning and Modern Programming Languages
Ray Toal
 
Java best practices
Java best practicesJava best practices
Java best practices
Ray Toal
 
unittest in 5 minutes
unittest in 5 minutesunittest in 5 minutes
unittest in 5 minutes
Ray Toal
 
Economics of Open Source Software
Economics of Open Source SoftwareEconomics of Open Source Software
Economics of Open Source Software
Ray Toal
 
Modeling Patterns for JavaScript Browser-Based Games
Modeling Patterns for JavaScript Browser-Based GamesModeling Patterns for JavaScript Browser-Based Games
Modeling Patterns for JavaScript Browser-Based Games
Ray Toal
 
Git workshop
Git workshopGit workshop
Git workshop
Ray Toal
 
Learning and Modern Programming Languages
Learning and Modern Programming LanguagesLearning and Modern Programming Languages
Learning and Modern Programming Languages
Ray Toal
 
Java best practices
Java best practicesJava best practices
Java best practices
Ray Toal
 
unittest in 5 minutes
unittest in 5 minutesunittest in 5 minutes
unittest in 5 minutes
Ray Toal
 
Economics of Open Source Software
Economics of Open Source SoftwareEconomics of Open Source Software
Economics of Open Source Software
Ray Toal
 
Modeling Patterns for JavaScript Browser-Based Games
Modeling Patterns for JavaScript Browser-Based GamesModeling Patterns for JavaScript Browser-Based Games
Modeling Patterns for JavaScript Browser-Based Games
Ray Toal
 

Recently uploaded (20)

Viam product demo_ Deploying and scaling AI with hardware.pdf
Viam product demo_ Deploying and scaling AI with hardware.pdfViam product demo_ Deploying and scaling AI with hardware.pdf
Viam product demo_ Deploying and scaling AI with hardware.pdf
camilalamoratta
 
Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Kit-Works Team Study_아직도 Dockefile.pdf_김성호Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Wonjun Hwang
 
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Markus Eisele
 
AI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of DocumentsAI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of Documents
UiPathCommunity
 
Cybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and MitigationCybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and Mitigation
VICTOR MAESTRE RAMIREZ
 
Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)
Kaya Weers
 
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptxDevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
Justin Reock
 
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier VroomAI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
UXPA Boston
 
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
James Anderson
 
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdfKit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Wonjun Hwang
 
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Safe Software
 
Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptxSmart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Seasia Infotech
 
Mastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B LandscapeMastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B Landscape
marketing943205
 
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
Lorenzo Miniero
 
An Overview of Salesforce Health Cloud & How is it Transforming Patient Care
An Overview of Salesforce Health Cloud & How is it Transforming Patient CareAn Overview of Salesforce Health Cloud & How is it Transforming Patient Care
An Overview of Salesforce Health Cloud & How is it Transforming Patient Care
Cyntexa
 
Config 2025 presentation recap covering both days
Config 2025 presentation recap covering both daysConfig 2025 presentation recap covering both days
Config 2025 presentation recap covering both days
TrishAntoni1
 
Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)
Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)
Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)
CSUC - Consorci de Serveis Universitaris de Catalunya
 
Artificial_Intelligence_in_Everyday_Life.pptx
Artificial_Intelligence_in_Everyday_Life.pptxArtificial_Intelligence_in_Everyday_Life.pptx
Artificial_Intelligence_in_Everyday_Life.pptx
03ANMOLCHAURASIYA
 
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à GenèveUiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPathCommunity
 
Unlocking Generative AI in your Web Apps
Unlocking Generative AI in your Web AppsUnlocking Generative AI in your Web Apps
Unlocking Generative AI in your Web Apps
Maximiliano Firtman
 
Viam product demo_ Deploying and scaling AI with hardware.pdf
Viam product demo_ Deploying and scaling AI with hardware.pdfViam product demo_ Deploying and scaling AI with hardware.pdf
Viam product demo_ Deploying and scaling AI with hardware.pdf
camilalamoratta
 
Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Kit-Works Team Study_아직도 Dockefile.pdf_김성호Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Wonjun Hwang
 
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Markus Eisele
 
AI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of DocumentsAI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of Documents
UiPathCommunity
 
Cybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and MitigationCybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and Mitigation
VICTOR MAESTRE RAMIREZ
 
Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)
Kaya Weers
 
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptxDevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
Justin Reock
 
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier VroomAI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
UXPA Boston
 
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
James Anderson
 
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdfKit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Wonjun Hwang
 
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Safe Software
 
Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptxSmart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Seasia Infotech
 
Mastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B LandscapeMastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B Landscape
marketing943205
 
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
Lorenzo Miniero
 
An Overview of Salesforce Health Cloud & How is it Transforming Patient Care
An Overview of Salesforce Health Cloud & How is it Transforming Patient CareAn Overview of Salesforce Health Cloud & How is it Transforming Patient Care
An Overview of Salesforce Health Cloud & How is it Transforming Patient Care
Cyntexa
 
Config 2025 presentation recap covering both days
Config 2025 presentation recap covering both daysConfig 2025 presentation recap covering both days
Config 2025 presentation recap covering both days
TrishAntoni1
 
Artificial_Intelligence_in_Everyday_Life.pptx
Artificial_Intelligence_in_Everyday_Life.pptxArtificial_Intelligence_in_Everyday_Life.pptx
Artificial_Intelligence_in_Everyday_Life.pptx
03ANMOLCHAURASIYA
 
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à GenèveUiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPathCommunity
 
Unlocking Generative AI in your Web Apps
Unlocking Generative AI in your Web AppsUnlocking Generative AI in your Web Apps
Unlocking Generative AI in your Web Apps
Maximiliano Firtman
 

An Annotation Framework for Statically-Typed Syntax Trees

  • 1. An Annotation Framework for Statically-Typed Syntax Trees Loren Abrams Ray Toal Loyola Marymount University Los Angeles CA USA IASTED SEA 2009 2009-11-03
  • 2. Outline Overview Previous Work Motivating Example Some Theoretical Contributions An Annotation Framework Implementation of a Parser Generator Conclusions
  • 3. Goals To contribute to parser generation theory and practice with a grammar annotation framework that is Terse (more convention, less markup) Fully declarative Grammar-independent Supportive of statically typed host languages To demonstrate feasibility with a prototype parser generator
  • 4. Contributions A grammar-independent annotation framework (not “just another generator”) Distillation of embedded abstract syntax tree specification (useful for understanding) Definition of statically-typed AST specification Prototype parser generator very lightweight self-contained, easy to integrate
  • 5. Previous Research Grammars : CFG, (E)BNF, XBNF, SDF, PEG Parser Generators : Lex/Yacc, Flex/Bison, JavaCC, AntLR, SableCC, Rats! Tree Builders : JTB, JJTree Parser Generation Design Axes Concrete vs. Abstract Tree Production Static vs. Dynamic Typing Inline vs. External Specification
  • 6. Motivating Example (1 of 2) Given a grammar such as this one... ID => @[A-Za-z][A-Za-z0-9_]+ NUMLIT => @\d+(\.\d+([Ee][+-]?\d+)?)? STRLIT => @"[^"\p{Cc}]*" SKIP => @\s+ Program => Block Block => (Dec ";")* (Stmt ";")+ Dec => "var" ID ("=" Exp)? | "fun" ID "(" IdList? ")" "=" Exp Stmt => ID "=" Exp | "read" IdList | "write" ExpList | "while" Exp "do" Block "end" IdList => ID ("," ID)* ExpList => Exp ("," Exp)* Exp => Term (("+" | "-") Term)* Term => Factor (("*" | "/") Factor)* Factor => NUMLIT | STRLIT | ID | Call | "(" Exp ")" Call => ID "(" ExpList? ")"
  • 7. Motivating Example (2 of 2) ...we want to annotate the grammar to produce statically-typed ASTs var y; fun half(x) = x / 2; while x - (5 * x) do write half(10.4), x+2; read x; end;
  • 8. Describing the ASTs Each node in the generated AST is an object of some AST node class The fields of each object are name-value pairs, with values we define recursively as being The value null Strings (which come from token literals) References to nodes Lists of values
  • 9. Annotating the Grammar Our contribution is to exhibit a high-level approach to annotation The approach must be fully declarative and support statically typed ASTs The key idea is to ensure each type of value (on the previous slide) is producible Our current work is only for embedded annotations, but it should extend to AST descriptions external to the grammar
  • 10. Annotation Highlights Each rule execution produces a value (null, string, node-ref, list) We tag syntax elements and AST node expressions: tags become field names Expressions not tagged get the name of the construct (convention!) Different tag binding symbols for scalar and list values Simple notation for node class hierarchies
  • 11. Annotation Example (1 of 3) Value of rule is last value produced params is a scalar variable; decs and stmts are list variables; block , exp are implicit variables Var and Fun are subclasses of Dec Note how some values can be null Program => Block {Program block} Block => ( decs *: Dec ";")* ( stmts *: Stmt ";")+ {Block decs stmts } Dec => " var " ID ("=" Exp )? {Var:Dec id exp } | "fun" ID "(" params:IdList? ")" "=" Exp {Fun:Dec id params exp }
  • 12. Annotation Example (2 of 3) Value of IdList is just the value of id left is a scalar variable, note how it gets “reassigned” Stmt => ID "=" Exp {Assign:Stmt id exp} | "read" IdList {Read:Stmt idList} | "write" ExpList {Write:Stmt expList} | "while" Exp "do" Block "end" {While:Stmt exp block} IdList => id*:ID ("," id*:ID)* ExpList => exp*:Exp ("," exp*:Exp)* Exp => left:Term (op:("+" | "-") right:Term left:{Bin:Exp op left right} )* Term => left:Factor (op:("*" | "/") right:Factor left:{Bin:Exp op left right} )*
  • 13. Annotation Example (3 of 3) Used value since numlit and strlit would not be nice field names Type of Factor rule is Exp (most general superclass) ^exp required to avoid “)” as the value Factor => value:NUMLIT {NumLit:Exp value} | value:STRLIT {StrLit:Exp value} | ID {Ref:Exp id} | Call | "(" Exp ")" ^exp Call => ID "(" args:ExpList? ")" {Call:Exp id args}
  • 14. Parser Generator Implementation A parser generator reads a description (like the one on the last three slides) and outputs A scanner A parser, producing an AST (only) A set of AST node classes, each with setters, getters, and (possibly) visit methods A visitor framework for using the generated AST (without touching the tree classes, of course) Interesting implementation : token set, types, etc. are computed (inference algorithm)
  • 15. Prototype Implementation (1 of 2) Initial implementation is a proof of concept Description elements fixed, not yet pluggable : for scalar binding *: for list binding { } for node expressions : for subclassing Produces incomplete parsers, though scanner, tree classes, and navigation are fully implemented.
  • 16. Prototype Implementation (2 of 2) Java only Microsyntax specification uses Java regexes (nice) Packaged as altgen-m-n.jar (m and n are version numbers) — under 5 0KB Further info at http://xlg.cs.lmu.edu/altgen Planned open source distribution at Google Code
  • 17. Summary Presentation of a terse, declarative, grammar-independent annotation framework for the generation of statically type abstract syntax trees Presentation of a prototype parser generator using the framework Java implementation of the prototype is only 50KB
  翻译: