JetPAG

From Wikipedia, the free encyclopedia

JetPAG (Jet Parser Auto-Generator) is an open source LL(k) parser and lexical analyzer generator, licensed under the GNU General Public License. It is a personal work of Tareq H. Sharafy

Contents

[edit] History

Tareq started JetPAG as a small program written for practice purposes only. Soon when it started expanding many goals were added rapidly, and it was obvious that JetPAG is worthy being a complete project. Real development of JetPAG started in late 2005, targeting a complete framework for a powerful recursive descent lexical analyzer and parser generator with emphasis on ease of use, code readability and performance for both JetPAG and the generated code. After a long period of in-house development and testing, the first development package of JetPAG was release through SourceForge in 18 November 2006. Development of JetPAG is current at beta stage, current version is 0.6.1. Development of JetPAG is highly active and rapid (project activity at SourceForge is well over 99.4%) and grammars are added to the public archive regularly.

[edit] Overview

Jetpag incorporates several modules: the front end, the analyzers and the code generators.

The front end accepts the metalanguages as an input. Minor optimizations are don at that stage.

The analyzers mainy perform two operations through tree traversal. The first is calculating strong lookahead sets for the elements in the grammar and the second is constructing lookahead paths from the lookahead sets. Lookahead paths group, factorize and perform many enhancements and optimizations to lookahead sets with common properties creating a nested-check tree structure from the lookahead sets, gaining a great overall efficiency and improvement in all cases.

Code generators generate source code for recognizers compatible with the input grammars based on them along with information collected from the analyzers. Currently JetPAG generates source code in C++ only.

The nature of JetPAG's metalanguage and framework make it easy and simple to integrate generated recognizers into larger applications. JetPAG also includes some facilities in the provided framework to aid developers with small utilities and save development time from many minimal language recognition tasks.


[edit] JetPAG grammars

JetPAG's garmmars are written in a meta lanuage based on the EBNF form and regular expressions, with extensive additions and facilities. Parsers and lexical analyzers are simillary defined and generated for simplicity and ease of use. This is a simple example of a grammar for an addition/subtraction calculator:

grammar Calc:

parser CalcP:

expression:
 factor
 ( '+' factor
 | '-' factor
  )*
 ;

factor:
   INT
 | '(' expression ')'
 ;

scanner CalcS:

INT:   '0'-'9'+;
PLUS:  '+';
MINUS: '-';
LP:    '(';
RP:    ')';

[edit] See also

[edit] External links