Yacc and Lex and Bison and Flex


 
Building Parsers with Java
By Steven  John  Metsker

Table of Contents
Preface

    Content

A variety of tools that facilitate parser building are freely available on the Internet. The tools yacc and bison accept the design of a language (its grammar ) and generate a parser. The tools lex and flex help to collect characters into words, numbers , or tokens. All these tools generate C code, but there are newer tools that are oriented toward Java, such as the javacc tool.

All these tools require a developer to design a parser in one language and then generate it in another language. For example, to use javacc you must enter a grammar according to the rules of javacc. Then you can feed these rules to the tool to generate the Java code of a parser.

The use of a generator forces you to work in two languages: the language of the generator and the target language, C or Java. This book does not use generators, advocating instead that you enter Java code directly from the grammar. Sequences, alternations , and repetitions in the grammar become Sequence , Alternation , and Repetition objects in your code. The advantage is that the only language you need to know to start creating parsers is Java.

An advantage of using generators such as yacc is that they produce parsers that are much faster than parsers built with the techniques used in this book. The value of this speed depends on the length of the language elements your parser must face. If you create a parser using the techniques in this book and find that you want more speed, you can consider porting your parser to use a tool such as yacc. At that point, you will be comfortable with the rules and meaning of your language, and that will make implementation in yacc much easier.

If you have used yacc or other parser generators, you will find the material in this book familiar territory. Similarly, learning the techniques in this book will prepare you to use parser generators. All parser tools share the aim of helping you to become a language developer.


   
Top


Building Parsers with Java
Building Parsers With Javaв„ў
ISBN: 0201719622
EAN: 2147483647
Year: 2000
Pages: 169

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net