Next Previous Contents

# The Styx Handbook

## Lars Dölle, Heike Manns lars.doelle@on-line.de heike@free-it.org

Version 2.0.1, 7 July 2012

Styx is a scanner and parser generator designed to address some shortcomings of the traditional lex/yacc combination. It has unique features like automatic derivation of depth grammar, production of the derivation tree including it's C interface which provides access to the abstract syntax tree, preservation of full source information and pretty printing to facilitate source-source translation, persistence to aid rapid interpreter writing. For application in contemporary computing environments, it supports unicode, reentrancy and offers thread-safeness. Last but not least, Styx works well under many different OSes, among them dos, windows, and serveral unixes. It has been successfully used in many applications and is known to provide rapid compiler development. Both from our practical experience as well as from the amount of written code, the gain in development time for realistic languages versus lex/yacc is a factor of about 5-10.

## 1. Introduction and Overview

- 1.1 The supported translation framework
- 1.2 Reasons for this framework
- 1.3 The role of Styx within this framework
- 1.4 The supported language model
- 1.5 Comparison to the lex/yacc combination

## 2. A walk-through applying Styx

- 2.1 The language definition
- 2.2 The derived depth grammar / term algebra
- 2.3 Testing the language definition
- 2.4 The C language interface
- 2.5 Using the interface

## 3. The Styx Language Specification

- 3.1 The overall source
- 3.2 Lexical Conventions
- 3.3 The Regular Grammar
- 3.4 The Context-Free Grammar

## 4. The Concrete Derivation Tree

## 5. Mapping Trees to Terms

- 5.1 Well-formed productions
- 5.2 An induced congruence relation
- 5.3 Classes and Representatives
- 5.4 Compatibility Conditions
- 5.5 Conversion to term algebras
- 5.6 A note on the implementation
- 5.7 Relation between the abstract grammar and the algebra.

## 6. The Handyman's Guide to Styx

- 6.1 Setting up a Styx project
- 6.2 Writing and Testing a Grammar
- 6.3 Using the generated interface
- 6.4 Putting it all together

## 7. A realistic Styx example

- 7.1 The concrete PL0 syntax
- 7.2 The generated abstract grammar
- 7.3 An example PL0 program
- 7.4 The Semantic of PL0 programs
- 7.5 Implementing a PL0 interpreter

## 8. Further aspects

- 8.1 Some notes on dangling else grammars and abstraction
- 8.2 The error recovery mechanism
- 8.3 Using persistence
- 8.4 Unicode support
- 8.5 The preprocessing facility
- 8.6 Using early reduction
- 8.7 Parsing from strings and special files
- 8.8 Using the scanner alone
- 8.9 Integration of external scanner and parser
- 8.10 Constructing and accessing a derivation tree
- 8.11 Meta-operations
- 8.12 Pretty printing
- 8.13 Programming language support

## 9. Odds'n'Ends

- 9.1 Disadvantages with regard to lex/yacc
- 9.2 Intensive grammar abstractions
- 9.3 Pretty printing
- 9.4 '.ant' vs. '.int' C-Interface
- 9.5 Reentrancy and thread-safeness
- 9.6 Meaning of the name "Styx"
- 9.7 Installation, Availability and License
- 9.8 Authors and Credits
- 9.9 Copyright and Trademarks

## 10. References

- 10.1 Language Reference
- 10.2 Library Reference
- 10.3 Manual pages
- 10.4 Styx based example applications

## 11. Bibliography

- 11.1 Recommended books on compiler construction

## 12. Appendix

Next Previous Contents