Skip to main content

Detecting Ambiguity in Programming Language Grammars

  • Conference paper
Book cover 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

Ambiguous Context Free Grammars (CFGs) are problematic for programming languages, as they allow inputs to be parsed in more than one way. In this paper, we introduce a simple non-deterministic search-based approach to ambiguity detection which non-exhaustively explores a grammar in breadth for ambiguity. We also introduce two new techniques for generating random grammars – Boltzmann sampling and grammar mutation – allowing us to test ambiguity detection tools on much larger corpuses than previously possible. Our experiments show that our breadth-based approach to ambiguity detection performs as well as, and generally better, than extant tools.

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. Cantor, D.G.: On the ambiguity problem of backus systems. Journal of the ACM 9(4), 477–479 (1962)

    Article  MathSciNet  MATH  Google Scholar 

  2. Tratt, L.: Parsing: The solved problem that isn’t. Hacker Monthly, 37–42 (June 2011)

    Google Scholar 

  3. Schröer, F.W.: Amber, an ambiguity checker for context-free grammars. Technical report (2001), http://accent.compilertools.net/Amber.html

  4. Brabrand, C., Giegerich, R., Møller, A.: Analyzing ambiguity of context-free grammars. Science of Computer Programming 75(3), 176–191 (2010)

    Article  MathSciNet  MATH  Google Scholar 

  5. Basten, H.J.S., Vinju, J.J.: Faster ambiguity detection by grammar filtering. In: Proc. LDTA, pp. 5:1–5:9 (2010)

    Google Scholar 

  6. Axelsson, R., Heljanko, K., Lange, M.: Analyzing context-free grammars using an incremental SAT solver. In: Aceto, L., Damgård, I., Goldberg, L.A., Halldórsson, M.M., Ingólfsdóttir, A., Walukiewicz, I. (eds.) ICALP 2008, Part II. LNCS, vol. 5126, pp. 410–422. Springer, Heidelberg (2008)

    Chapter  Google Scholar 

  7. Cheung, B.S.N., Uzgalis, R.C.: Ambiguity in context-free grammars. In: Proc. SAC, pp. 272–276. ACM (1995)

    Google Scholar 

  8. Basten, H.J.S.: Ambiguity detection methods for context-free grammars. Master’s thesis, Universiteit van Amsterdam (August 2007)

    Google Scholar 

  9. Vasudevan, N., Tratt, L.: Search-based ambiguity detection in context-free grammars. In: Proc. ICCSW, pp. 142–148 (September 2012)

    Google Scholar 

  10. Harman, M.: The current state and future of search based software engineering. In: FOSE, pp. 342–357 (2007)

    Google Scholar 

  11. Schröer, F.W.: Accent, a compiler compiler for the entire class of context-free grammars. Technical report (2000), http://accent.compilertools.net/Accent.html

  12. Canou, B., Darrasse, A.: Fast and sound random generation for automated testing and benchmarking in objective caml. In: Proc. Workshop on ML, pp. 61–70 (2009)

    Google Scholar 

  13. Mougenot, A., Darrasse, A., Blanc, X., Soria, M.: Uniform random generation of huge metamodel instances. In: Paige, R.F., Hartman, A., Rensink, A. (eds.) ECMDA-FA 2009. LNCS, vol. 5562, pp. 130–145. Springer, Heidelberg (2009)

    Chapter  Google Scholar 

  14. Basten, H.J.S., van der Storm, T.: Ambidexter: Practical ambiguity detection. In: Proc. SCAM 2010, pp. 101–102 (2010)

    Google Scholar 

  15. Tomita, M.: An efficient context-free parsing algorithm for natural languages. In: Proc. IJCAI, pp. 756–764 (1985)

    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

Vasudevan, N., Tratt, L. (2013). Detecting Ambiguity in Programming Language Grammars. 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_9

Download citation

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

  • 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