Skip to main content

Safe Specification of Operator Precedence Rules

  • Conference paper
Software Language Engineering (SLE 2013)

Part of the book series: Lecture Notes in Computer Science ((LNPSE,volume 8225))

Included in the following conference series:

Abstract

In this paper we present an approach to specifying operator precedence based on declarative disambiguation constructs and an implementation mechanism based on grammar rewriting. We identify a problem with existing generalized context-free parsing and disambiguation technology: generating a correct parser for a language such as OCaml using declarative precedence specification is not possible without resorting to some manual grammar transformation. Our approach provides a fully declarative solution to operator precedence specification for context-free grammars, is independent of any parsing technology, and is safe in that it guarantees that the language of the resulting grammar will be the same as the language of the specification grammar. We evaluate our new approach by specifying the precedence rules from the OCaml reference manual against the highly ambiguous reference grammar and validate the output of our generated parser.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Klint, P., Lämmel, R., Verhoef, C.: Toward an engineering discipline for grammarware. ACM Trans. Softw. Eng. Methodol. 14(3), 331–380 (2005)

    Article  Google Scholar 

  2. Earley, J.: An efficient context-free parsing algorithm. Commun. ACM 13(2), 94–102 (1970)

    Article  MATH  Google Scholar 

  3. Tomita, M. (ed.): Generalized LR parsing. Kluwer Academic Publishers (1991)

    Google Scholar 

  4. Rekers, J.: Parser Generation for Interactive Environments. PhD thesis, University of Amsterdam, The Netherlands (1992)

    Google Scholar 

  5. McPeak, S., Necula, G.C.: Elkhound: A fast, practical GLR parser generator. In: Duesterwald, E. (ed.) CC 2004. LNCS, vol. 2985, pp. 73–88. Springer, Heidelberg (2004)

    Chapter  Google Scholar 

  6. Baxter, I.D., Pidgeon, C., Mehlich, M.: DMS®: Program transformations for practical scalable software evolution. In: Proceedings of the 26th International Conference on Software Engineering, ICSE 2004, pp. 625–634. IEEE Computer Society, Washington, DC (2004)

    Chapter  Google Scholar 

  7. Scott, E., Johnstone, A.: GLL parse-tree generation. Science of Computer Programming (2012) (to appear) ISSN:0167-6423

    Google Scholar 

  8. Aho, A.V., Johnson, S.C., Ullman, J.D.: Deterministic parsing of ambiguous grammars. In: Proceedings of the 1st Annual ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages, POPL 1973, pp. 1–21. ACM (1973)

    Google Scholar 

  9. Aho, A.V., Lam, M.S., Sethi, R., Ullman, J.D.: Compilers: Principles, Techniques, and Tools, 2nd edn. Addison-Wesley Longman Publishing Co., Inc., Boston (2006)

    Google Scholar 

  10. Visser, E.: Scannerless generalized-LR parsing. Technical Report P9707, Programming Research Group, University of Amsterdam (July 1997)

    Google Scholar 

  11. Klint, P., van der Storm, T., Vinju, J.: EASY meta-programming with rascal. In: Fernandes, J.M., Lämmel, R., Visser, J., Saraiva, J. (eds.) Generative and Transformational Techniques in Software Engineering III. LNCS, vol. 6491, pp. 222–289. Springer, Heidelberg (2011), http://www.rascal-mpl.org

    Chapter  Google Scholar 

  12. Klint, P., Visser, E.: Using filters for the disambiguation of context-free grammars. In: Pighizzini, G., San Pietro, P. (eds.) Proc. ASMICS Workshop on Parsing Theory, Milano, Italy, Tech. Rep. 126–1994, pp. 1–20. Dipartimento di Scienze dell’Informazione, Università di Milano (1994)

    Google Scholar 

  13. Visser, E.: Syntax Definition for Language Prototyping. PhD thesis, University of Amsterdam (1997)

    Google Scholar 

  14. Aasa, A.: Precedences in specifications and implementations of programming languages. Theor. Comput. Sci. 142(1), 3–26 (1995)

    Article  MathSciNet  MATH  Google Scholar 

  15. Thorup, M.: Disambiguating grammars by exclusion of sub-parse trees. Acta Informatica 33(5), 511–522 (1996)

    Article  MathSciNet  Google Scholar 

  16. Thorup, M.: Controlled grammatic ambiguity. ACM Trans. Program. Lang. Syst. 16(3), 1024–1050 (1994)

    Article  Google Scholar 

  17. Visser, E.: From context-free grammars with priorities to character class grammars. In: van Deursen, A., Brune, M., Heering, J. (eds.) Dat Is Dus Heel Interessant, Liber Amicorum Dedicated to Paul Klint, pp. 217–230. CWI (1997)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2013 Springer International Publishing Switzerland

About this paper

Cite this paper

Afroozeh, A., van den Brand, M., Johnstone, A., Scott, E., Vinju, J. (2013). Safe Specification of Operator Precedence Rules. In: Erwig, M., Paige, R.F., Van Wyk, E. (eds) Software Language Engineering. SLE 2013. Lecture Notes in Computer Science, vol 8225. Springer, Cham. https://doi.org/10.1007/978-3-319-02654-1_8

Download citation

  • DOI: https://doi.org/10.1007/978-3-319-02654-1_8

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-319-02653-4

  • Online ISBN: 978-3-319-02654-1

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics