Morbig: A Static Parser for POSIX Shell

Yann Régis-Gianas 1, 2 Nicolas Jeannerod 1, 3 Ralf Treinen 1
2 PI.R2 - Design, study and implementation of languages for proofs and programs
Inria de Paris, CNRS - Centre National de la Recherche Scientifique, UPD7 - Université Paris Diderot - Paris 7, PPS - Preuves, Programmes et Systèmes
Abstract : The POSIX shell language defies conventional wisdom of compiler construction on several levels: The shell language was not designed for static parsing, but with an intertwining of syntactic analysis and execution by expansion in mind. Token recognition cannot be specified by regular expressions, lexical analysis depends on the parsing context and the evaluation context, and the shell grammar given in the specification is ambiguous. Besides, the unorthodox design choices of the shell language fit badly in the usual specification languages used to describe other programming languages. This makes the standard usage of Lex and Yacc as a pipeline inadequate for the implementation of a parser for POSIX shell. The existing implementations of shell parsers are complex and use low-level character-level parsing code which is difficult to relate to the POSIX specification. We find it hard to trust such parsers, especially when using them for writing automatic verification tools for shell scripts. This paper offers an overview of the technical difficulties related to the syntactic analysis of the POSIX shell language. It also describes how we have resolved these difficulties using advanced parsing techniques (namely speculative parsing, parser state introspection, context-dependent lexical analysis and longest-prefix parsing) while keeping the implementation at a sufficiently high level of abstraction so that experts can check that the POSIX standard is respected. The resulting tool, called Morbig, is an open-source static parser for a well-defined and realistic subset of the POSIX shell language.
Type de document :
Communication dans un congrès
SLE 2018 - ACM SIGPLAN International Conference on Software Language Engineering, Nov 2018, Boston, United States. 〈10.1145/3276604.3276615〉
Liste complète des métadonnées

https://hal.archives-ouvertes.fr/hal-01890044
Contributeur : Nicolas Jeannerod <>
Soumis le : lundi 8 octobre 2018 - 12:03:34
Dernière modification le : jeudi 7 février 2019 - 16:54:06
Document(s) archivé(s) le : mercredi 9 janvier 2019 - 13:59:12

Fichier

main.pdf
Fichiers produits par l'(les) auteur(s)

Identifiants

Collections

Citation

Yann Régis-Gianas, Nicolas Jeannerod, Ralf Treinen. Morbig: A Static Parser for POSIX Shell. SLE 2018 - ACM SIGPLAN International Conference on Software Language Engineering, Nov 2018, Boston, United States. 〈10.1145/3276604.3276615〉. 〈hal-01890044〉

Partager

Métriques

Consultations de la notice

568

Téléchargements de fichiers

314