The Styx Handbook: Odds'n'Ends

Next Previous Contents

## 9. Odds'n'Ends

This section contains an eclectic collection of topics. Some of them might later evolve into a complete chapter. As a compromise between our intention to release Styx quickly but to provide you with a more or less complete documentation, much had to be left out and others could only be touched shortly. Expect the topics mentioned below to be more well-documented in a later version of this paper.

## 9.1 Disadvantages wrt. lex/yacc

- Mostly disadvantages of the scanner
  - only single-character lookahead (i did this for purpose, since it guarantees a very fast scanner). Because it is a problem only within the scanner and not in the scanner generator, it can easily be fixed.

    Practically, it prevents some lexical grammars to be scanned as expected. As an example, take the floating point literal in Smalltalk, whose denotation partially coinceeds with the integer denotation followed by the statement-terminating period.

  - Irregular lexical syntaxes as used in many languages cannot be scanned. Take Rpg, Fortran or Cobol with their columnar lexical syntax as examples.
- The parser only supports a one-symbol lookahead, while more modern yacc versions come with lalr(2) or even lalr(k). Since lalr(1) is known to handle the deterministic languages, this is not a real issue, since we can always reformulate the grammar to cope with oddities.
- Languages that come with an ill-layered context-free and context-dependend grammar (many do), cannot be parsed without extra tricks. Take the "typedef" declaration of C together with the application of the type name in type denotations as example. Likely examples are languages with defineable operator preceedences as Algol98 or Prolog for instance. Styx provides a few hooks to cope with stuff like this.

## 9.2 Intensive grammar abstractions

Typical example of the problem occurs already when parsing expressions. As a result we want to get something like 'expr ::= varid | lit | funid(expr,...)', but we have prefix, infix, postfix, distfix order and whatever syntactical sugar in the surface grammar. Further, the 'funid' tokens come in as keywords and not as regular names.

- Node rotation
- keyword --> symbol replacements

Method to solve the problem would be to have some 'interface time' reduction rules. The impact of such rules wrt. the abstraction congruence and to unparsing remains to be investigated.

[TODO --> Lars]

## 9.3 Pretty printing

- Allows to "translate" to a super-grammar of the parsed word.
- Incompletely developed especially wrt. token separation and comment placement.
- Conceptionally wrong because of the indendential specification method that causes styx sources not be pretty printable themselves. This misconception will be ironed out in one of the next releases.

  [TODO --> Heike]

- Successfully used anyway by the author to convert a language with a lisp like surface grammar (and a hand-written parser) to something proper with infix operators, function names before the parentheses, if constructs and other. Only a little handwork was needed to place the comments right and to adjust the layout in certain situations due to my taste.
- Should be developed so, that it can be used as a source code normalizer in a regular way.

## 9.4 Bits of history and future

- History: Speculate
- Future: Semantics (static, dynamic), Xaron

### Meaning of the name "Styx"

The word "Styx", which is the name of the here-described software has two interpretations intended by us. The first, plain and simple is an abriviation or more precise a ENGLISH("Verballhornung") of the word "syntax" which is obviously closely related to what Styx is for. The second, more opaque and perhaps scaring interpretation originates from the coincidence with the name of a place in greek mythology. It is the name of a very poisonous river that separates the mythological underworld, the hades, from the world on the surface of earth. Well knowing that analogies painfully stress the imagination, we do not go further into it, but leave it to the meditation of the ENGLISH("geneigtem") reader.

## 9.5 '.ant' vs. '.int' C-Interface

- '.ant' provides a very space efficient representation of the derivation tree to the expense that keywords and comments are as well lost as source file references.
- It is a plug-in replacement.
- This format originated as a workaround of some disabilities of Microsoft's memory allocation library. Bill may or may not have fixed his decent product meanwhile, but who cares?

## 9.6 Reentrancy and thread-safeness

- Basically, reentrancy works.
- Thread-safeness should work, but is not tested.

## 9.7 Installation, Availability and License

- Standard installation procedure (configure, make, make install). Use 'configure --help' to get options.
- Styx is available at http://www.speculate.de/Styx.
- The Styx package is released both under GPL and LGPL, while each of the licenses apply to different parts. ...

## 9.8 Further Readings

We give a short summary of advancing lecture here.

- The dragon book
- Ehrig, Maar
- perhaps more

## 9.9 Authors and Credits

- LD & HM
- Styx intentionally an original freeware product, .... Thanks goes to the freeware community to create the environment that finally allows us to present our work to a more wider audience. We hope using Styx will make as much fun as it made us writing it.
- Styx was written by their authors in their spare time as a tool to create another application while working as freelancers for the administration of the "Freie und Hansestadt Hamburg", our home town. Thanks goes to the management of the particular department to give us enough freedom to choose the tools and methods for our job to the benefit all.

## 9.10 Copyright and Trademarks

Styx is copyright (c) 19xx-2002,2003 by Lars Doelle and Heike Manns. Dos and Windows is a trademark of Microsoft. Unix is a trademark of the Santa Cruise Corporation. All other mentioned trademarks are trademarks of their respective owners.

Next Previous Contents