[
Info
|
Downloads
|
User Manual
| Publications
| Bugzilla site
|
License
]
Copper: a generator for integrated LR
parsers and context-aware scanners.
Copper is a parser and scanner generator that
generates integrated LR parsers and context-aware scanners from
language specifications based on context-free
grammars and regular expressions.
The unique feature in Copper is that the generated parser provides
contextual information to the scanner in the form of the current LR
parse state when the scanner is called to return the next token. The
scanner uses this information to ensure that it only returns tokens
that are valid for the current state, that is, those for terminals
whose entry in the parse table for the current state is
shift, reduce,
or accept (but not error).
Context-aware scanners are more
discriminating than those that lack context and allow the
specification of simpler grammars that are more likely to be in the
desired LALR(1) grammar class.
One language for which this approach is useful is AspectJ, an extension bringing aspect constructs to Java. Previously AspectJ has only been parsed by hand-coding a scanner (sacrificing declarativeness) or using a GLR-based parsing tool (sacrificing determinism). We have adapted a declarative AspectJ grammar that can be parsed deterministically in Copper; the source code of this grammar is linked from the downloads page.
Our GPCE 2007 paper
"Context-aware scanning for parsing extensible
languages" provides a detailed discussion of parser-based
context-aware scanning.
Copper can also subject a language extension to a test guaranteeing that all extensions that pass the test can be composed together without any parse-table conflicts. This test is documented in our PLDI 2009 paper and its accompanying technical report.
Copper is written in Java and generates parsers and scanner written
in Java. It is used by
Silver, our attribute
grammar system. It is also available
as a stand-alone package.
On the download page are links
to the Copper JAR files for using Copper as a stand-alone tool, as
well as a tarball containing a set of demonstrative examples.
To use Copper in conjunction with Silver, see the Silver web pages.
|