SourceForge.net Logo
What's New | What is Hyacc | Features | Example | Download | License | History | References | Contact

What's New?

Hyacc 0.98 is released on January 01, 2017.

What is Hyacc, and why it is special

Many people have used Yacc. It is a LALR(1) parser generator, often used with the lexical analyzer Lex to create compilers. There are many variations of Yacc, most famous ones are like Bison and Byacc (Berkely yacc). The problem with LALR(1) parser generators is that they contain "mysterious" reduce/reduce conflicts even for deterministic and unambiguous grammars, and these require the language designer to tweak the grammar which is often a time-consuming and painful process, and the resulted grammar may not be the same as before modification.

Hyacc is similar to Yacc in that it is a parser generator. It is different from yacc in that it is a LR(1)/LALR(1)/LR(0) parser generator, which means it can accept all LR(1) grammars. This is more powerful than LALR(1) algorithm. A LR(1) parser generator also does not have the "mysterious reduce/reduce conflict" problem. Hyacc also supports LR(k) for limited cases.

Hyacc is pronounced as "HiYacc", means Hawaii Yacc.

Specifically, based on the original Knuth LR(1) algorithm, three optimizations are used:

  1. LR(1) parser generation by combining compatible states [1].
  2. Remove unit productions [2].
  3. Further remove repeated states after the previous step.
Besides, Hyacc also implemented:
  1. LR(1) parser generation by lane-tracing [3][4].
  2. LALR(1) based on lane-tracing.
  3. LR(0).
  4. A LR(k) algorithm that works for limited cases.

Hyacc is compatible with Yacc and Bison in the format of input file and command line switches. So anyone used Yacc or Bison before should be able to start using Hyacc immediately.

Hyacc is ANSI C compliant, and can be easily ported to other platforms.

Features

Current features: What's not working and to be implemented:

Example

Here is a yacc input file calc.y for an infix notation calculator, modified from an example from Bison's online document.

Type the command: hyacc calc.y -v -t -g -D0
-v asks for the generation of y.output
-D0 asks for printing all the relevant information into y.output
-t asks for generating y.parse that contains all the parsing details when the generated parser parses an input.
-g asks for generating y.gviz that can be used as input file to graphviz.

The generated files are: y.tab.c, y.output and y.gviz.
Using graphviz, based on the genereated file y.gviz, this is the graphviz-generated parsing machine.
Now compile y.tab.c with a C compiler, which gives calc.exe.
Use the input file input.txt (don't forget the newline at the end), type: calc < input.txt
The answer is given in the standard output as:
# 25
#
and a y.parse file is generated, which shows the parsing process for the formular in input.txt.

Download

Hyacc can be compiled and used in Unix, Linux and Windows, or any system that supports ANSI C.

Documentations (included in the source packages): readme.pdf, hyaccmanpage

Source package: Hyacc project page. Or directly go to the download page.

License

Hyacc source code is released under the GPL license.

The only exception is the parser engine file "hyaccpar", which is released under the BSD license. This guarantees that the generated parser can be used in both open source and commercial softwares. A similar situation was addressed by Richard Stallman in the release notes of Bison 1.23 and 1.24.

History

Releases of Hyacc so far:

Compared to version 0.97, version 0.98 added these changes:

Compared to version 0.95, version 0.97 added these changes:

Compared to version 0.9, version 0.95 added these changes:

References

  1. David Pager, Xin Chen. A New Algorithm To Evaluate Terminal Heads Of Length K. The Second Asia-Pacific Programming Languages and Compilers Workshop (APPLC), Shenzhen, China, February 23, 2013 (In conjunction with CGO'13)
  2. Xin Chen, David Pager. Extension to the Unit Production Elimination Algorithm. Proceedings of the 2012 International Conference on Software Engineering Research and Practice, p.433-439. Las Vegas, July 2012
  3. David Pager, Xin Chen. The Lane Table Method Of Constructing LR(1) Parsers. The First Asia-Pacific Programming Languages and Compilers Workshop (APPLC) Beijing, China, June 14, 2012
  4. Xin Chen, David Pager. The Edge-Pushing LR(k) Algorithm. Proceedings of International Conference on Software Engineering Research and Practice, p.490-495. Las Vegas, July 18-21, 2011
  5. Xin Chen, David Pager. LR(1) Parser Generator Hyacc. Proceedings of International Conference on Software Engineering Research and Practice, p.471-477. Las Vegas, July 18-21, 2011
  6. Xin Chen, David Pager. Full LR(1) Parser Generator Hyacc And Study On The Performance of LR(1) Algorithms. Proceedings of The Fourth International C* Conference on Computer Science & Software Engineering, p.83-92. Montreal, Canada, May 16-18, 2011
  7. Xin Chen. Measuring and extending LR(1) parsing. PhD dissertation. University of Hawaii. August 2009
  8. Pager, D., A Practical General Method for Constructing LR(k) Parsers. Acta Informatica 7, 249 - 268 (1977)
  9. Pager, D., Eliminating Unit Productions from LR Parsers. Acta Informatica 9, 31 - 59 (1977)
  10. Pager, D., The Lane-Tracing Algorithm for Constructing LR(k) Parsers and Ways of Enhancing Its Efficiency. Information Sciences 12, 19 - 42 (1977)
  11. Pager, D., The lane tracing algorithm for constructing LR(k) parsers. Proceedings of the fifth annual ACM symposium on Theory of computing, 172 - 181 (1973)
Other implementations of [1].
  1. Implementation in Forthan: LR. By C. Wetherell and A. Shannon (1981)
  2. Implementation in Objective Caml: Menhir. By François Pottier and Yann Régis-Gianas (2004 ~ 2007)
  3. Implementation in Python. By Jason Evans (2007)

Contact

Please contact chenx AT hawaii DOT edu for any comments or bug report.



Copyrighted (2007 - 2017) @ X.C. Created on: 8/26/2007, Last modified: 1/19/2017