After reading this tutorial the reader will hopefully have a reasonable first impression of how Silver and Copper work together to generate language translators from high-level attribute grammar specifications.

Silver contains many other constructs that are useful in defining extensible and domain-specific languages such as forwarding [5], reference attributes [2], collection attributes [1], parametric poly- morphism, and import and export statements for the modular specification and composition of languages. These are described in more detail in the upcoming guide “Building extensible and domain-specific langauges using Silver and Copper.” The guide assumes no knowledge of Silver or Copper, but does assume the basic understanding of scanners, parsers, and attribute grammars that this tutorial aims to provide.

Readers may also be interested in our papers published on these tools. One might start with our paper “Silver: an Extensible Attribute Grammar System” [4].

In this document we have stated that the scanner produces a sequence of tokens from the input text, implying that it does this without any other input. While this is true for traditional scanners and parsers such as those generated by Lex or Flex, it is not true for Copper which introduced a notion of context-aware scanning. The parser calls the scanner asking for the “next token” as it is needed by the parser. Thus these are computed on demand. Furthermore the scanner uses contextual information provided by the parser to tell it what terminal symbols are valid at that current point in the program. It uses this information to be more discriminating in determining the token to be returned. The paper “Context aware scanning for parsing extensible languages” [6] provides a full description of this process and some examples illustrating where it is useful. Further information about Silver and Copper, links to the papers mentioned above, as well as the most current release of the tools are available at http://melt.cs.umn.edu.

References

  1. J. T. Boyland. Remote attribute grammars. J. ACM, 52(4):627–687, 2005.
  2. G. Hedin. Reference attribute grammars. Informatica, 24(3):301–317, 2000.
  3. D. E. Knuth. Semantics of context-free languages. Mathematical Systems Theory, 2(2):127–145,
  4. Corrections in 5(1971) pp. 95–96.
  5. E. Van Wyk, D. Bodin, J. Gao, and L. Krishnan. Silver: an extensible attribute grammar system. Science of Computer Programming, 75(1–2):39–54, January 2010.
  6. E. Van Wyk, O. de Moor, K. Backhouse, and P. Kwiatkowski. Forwarding in attribute grammars for modular language design. In Proc. 11th Intl. Conf. on Compiler Construction, volume 2304 of LNCS, pages 128–142, 2002.
  7. E. Van Wyk and A. Schwerdfeger. Context-aware scanning for parsing extensible languages. In Intl. Conf. on Generative Programming and Component Engineering, (GPCE). ACM Press, October 2007.
  8. H. Vogt, S. D. Swierstra, and M. F. Kuiper. Higher-order attribute grammars. In ACM Conf. on Programming Language Design and Implementation (PLDI), pages 131–145, 1990.