JetPAG

JetPAG
Developer(s) Tareq H. Sharafy
Stable release
0.6.1 / February 7, 2007 (2007-02-07)
Preview release
0.6.3 / 2007
Written in C++
Operating system Platform-independent
Type Parser generator
License GNU General Public License
Website JetPAG Homepage

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, and is currently at final beta stages of development.

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 high performance of generated code. After a long period of in-house development and testing, the first development package of JetPAG was released through SourceForge on 18 November 2006. Development of JetPAG is current at beta stage, current version is 0.6.1. The development was delayed from mid-2007 until early 2009 but resumed after.

Overview

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

The front end accepts the grammar metalanguages as an input.

The analyzers mainly 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 using special analysis. From lookahead paths, lookahead sets are transformed to a nested tree form, gaining a great overall efficiency and improvement in most 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 makes 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.

JetPAG grammars

JetPAG's garmmars are written in a meta language based on the EBNF form and regular expressions, with extensive additions and tweaks. The meta language of JetPAG grammars was designed to be maximally flexible handle both simple grammars and large, complicated ones easily. Parsers and lexical analyzers are similarly defined and generated for simplicity and ease of use. This is a simple example of a grammar for a basic calculator:

grammar Calc:

parser CalcP:

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

multiplicative:
 factor
 ( '*' factor
 | '/' factor
  )*
 ;

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

scanner CalcS:

INT:   '0'-'9'+;
PLUS:  '+';
MINUS: '-';
STAR:  '*';
SLASH: '/';
LP:    '(';
RP:    ')';

See also

This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.