Presentation is loading. Please wait.

Presentation is loading. Please wait.

Grammatica :: Parser Gen anurag naidu Winter 2006-2 Compiler Construction.

Similar presentations


Presentation on theme: "Grammatica :: Parser Gen anurag naidu Winter 2006-2 Compiler Construction."— Presentation transcript:

1 Grammatica :: Parser Gen anurag naidu Winter 2006-2 Compiler Construction

2 About Grammatica  Authors Per Cederberg (Creator, Dynabyte) Marielle Fois (Testing and suggestions)  Acknowledges Flex, Bison, ANTLR, and SableCC  Last stable version Version 1.4 (2003-08-27) Compatible with Mono 0.26 (#NET 1.0) Compatible with Java 1.3

3 Features  Parser generator in Java and C#  Clear separation of grammar and code - Grammar file can be reused  Supports LL(k) grammar - Easier error recovery and detailed error messages  Automatic error recovery - Reports all syntax errors in input

4 What it lacks  Supports only Java 1.3 - Grammar file can be reused - Cannot give exclusive names to generated file - [--javaclassname ] option prefixes name  No support for LR grammar - Even though it asks for a grammar types

5 Grammatica grammar structure %header% GRAMMARTYPE = "LL"... %tokens%... %productions%... STRING_TOKEN = "Value" REGEXP_TOKEN = >  Uses EBNF grammar notation  Grammar file structure Has 3 sections Java and C# comment structure anywhere in file  Supports following header parameters AUTHOR COPYRIGHT DATE DESCRIPTION GRAMMARTYPE VERSION

6 … contd %header% GRAMMARTYPE = "LL"... %tokens%... %productions%...  Grouping options "{...}" is equivalent to "(...)*" “[...]" is equivalent to "(...)?“ “(…)” is the normal grouping  Resolves ambiguities through finite look-ahead.  Reports all infinite ambiguities.

7 Command Line Options %header% GRAMMARTYPE = "LL"... %tokens%... %productions%...  Grouping options "{...}" is equivalent to "(...)*" “[...]" is equivalent to "(...)?“ “(…)” is the normal grouping  Resolves ambiguities through finite look-ahead.  Reports all infinite ambiguities.  Syntax: Grammatica [ ]

8 Options & Bugs  [--debug] This option validates the grammar However  It does not support grammar with loops  Absolutely does not permit any ambiguity  [--profile] This option is supposed to generate statistical analysis of an input to a grammar However  It never works (Division by zero error  )

9 Options & Bugs  [--tokenize] Tokenizes the input and gives line/col number for each token  [--parse] Generates a parse tree for the given input to the grammar  [--javaoutput] Generates a Java parser at the specified location Samples …….

10 Conclusion  Parser generator for Java and C#  Easy to use  Error messages are descriptive  Some options do not execute at all [--profile]  Cannot handle top level recursion  Code generated has callbacks to be overloaded, however code is dependent heavily on the packaged jar  Un-annotated grammar makes for lesser flexibility in tree traversal and tailored output

11 Acknowledgements  Grammatica http://grammatica.percederberg.net/


Download ppt "Grammatica :: Parser Gen anurag naidu Winter 2006-2 Compiler Construction."

Similar presentations


Ads by Google