Concise Concrete Syntax

We introduce a notion of ordered context-free grammars (OCFGs) with datatype tags to concisely specify grammars of programming languages. Our work is an extension of syntax definition formalism (SDF) and concrete datatypes that automate scanning, parsing, and syntax tree construction. But OCFGs also capture associativity and precedence at the level of production rules instead of lexical tokens such that a concrete syntax grammar is succinct enough be an abstract syntax definition. By expanding and re-indexing grammar symbols, OCFGs can be translated to grammars for standard lex and yacc such that existing and efficient parsing infrastructures can be reused. We have implemented a Java 5 compiler frontend with OCFGs. The complete grammar for such a realistic language fits comfortably in two pages of this paper, showing the practicality of our formalism. Comments University of Pennsylvania Department of Computer and Information Science Technical Report No. MSCIS-08-11. This technical report is available at ScholarlyCommons: http://repository.upenn.edu/cis_reports/874 Concise Concrete Syntax Stephen Tse Steve Zdancewic University of Pennsylvania

[1]  Russell W. Quong,et al.  ANTLR: A predicated‐LL(k) parser generator , 1995, Softw. Pract. Exp..

[2]  Corrado Priami,et al.  Comparison of syntactic error handling in LR parsers , 1995, Softw. Pract. Exp..

[3]  Steve Zdancewic,et al.  A Design for a Security-Typed Language with Certificate-Based Declassification , 2005, ESOP.

[4]  Annika Aasa,et al.  Precedences in Specifications and Implementations of Programming Languages , 1991, Theor. Comput. Sci..

[5]  J. Rekers,et al.  Parser Generation for Interactive Environments , 1992 .

[6]  Annika Aasa,et al.  Precedences for conctypes , 1993, FPCA '93.

[7]  Alfred V. Aho,et al.  Deterministic parsing of ambiguous grammars , 1975, Commun. ACM.

[8]  Eelco Visser,et al.  Disambiguation Filters for Scannerless Generalized LR Parsers , 2002, CC.

[9]  Benjamin C. Pierce,et al.  Types and programming languages: the next generation , 2003, 18th Annual IEEE Symposium of Logic in Computer Science, 2003. Proceedings..

[10]  Masaru Tomita,et al.  Efficient parsing for natural language , 1985 .

[11]  Jan A. Bergstra,et al.  A Complete Transformational Toolkit for Compilers , 1996, ESOP.

[12]  Giorgio Satta,et al.  Theory of Parsing , 2010 .

[13]  Alfred V. Aho,et al.  The Theory of Parsing, Translation, and Compiling , 1972 .

[14]  Adrian Johnstone,et al.  Generalised Parsing: Some Costs , 2004, CC.

[15]  Timo Lepistö,et al.  On Ordered Context-Free Grammars , 1973, Inf. Control..

[16]  Stephen R. Adams Modular grammars for programming language prototyping , 1991 .

[17]  Gordon V. Cormack,et al.  Scannerless NSLR(1) parsing of programming languages , 1989, PLDI '89.

[18]  Steve Zdancewic,et al.  Designing a Security-typed Language with Certificate-based Declassification , 2004 .