Describing the syntax of programming languages using conjunctive and Boolean grammars

12/07/2020
by   Alexander Okhotin, et al.
0

A classical result by Floyd ("On the non-existence of a phrase structure grammar for ALGOL 60", 1962) states that the complete syntax of any sensible programming language cannot be described by the ordinary kind of formal grammars (Chomsky's “context-free”). This paper uses grammars extended with conjunction and negation operators, known as conjunctive grammars and Boolean grammars, to describe the set of well-formed programs in a simple typeless procedural programming language. A complete Boolean grammar, which defines such concepts as declaration of variables and functions before their use, is constructed and explained. Using the Generalized LR parsing algorithm for Boolean grammars, a program can then be parsed in time O(n^4) in its length, while another known algorithm allows subcubic-time parsing. Next, it is shown how to transform this grammar to an unambiguous conjunctive grammar, with square-time parsing. This becomes apparently the first specification of the syntax of a programming language entirely by a computationally feasible formal grammar.

READ FULL TEXT

page 1

page 2

page 3

page 4

research
01/31/2018

Deep Reinforcement Learning for Programming Language Correction

Novice programmers often struggle with the formal syntax of programming ...
research
03/27/2018

Towards Zero-Overhead Disambiguation of Deep Priority Conflicts

**Context** Context-free grammars are widely used for language prototypi...
research
05/24/2022

A Paradigm Change for Formal Syntax: Computational Algorithms in the Grammar of English

Language sciences rely less and less on formal syntax as their base. The...
research
06/06/2018

Studying the Difference Between Natural and Programming Language Corpora

Code corpora, as observed in large software systems, are now known to be...
research
06/20/2017

Alignment Elimination from Adams' Grammars

Adams' extension of parsing expression grammars enables specifying inden...
research
01/21/2021

Commutative Event Sourcing vs. Triple Graph Grammars

This paper proposes Commutative Event Sourcing as a simple and reliable ...

Please sign up or login with your details

Forgot password? Click here to reset