Article ID Journal Published Year Pages File Type
433781 Science of Computer Programming 2014 16 Pages PDF
Abstract

Most scripting languages nowadays use regex pattern-matching libraries. These regex libraries borrow the syntax of regular expressions, but have an informal semantics that is different from the semantics of regular expressions, removing the commutativity of alternation and adding ad-hoc extensions that cannot be expressed by formalisms for efficient recognition of regular languages, such as deterministic finite automata.Parsing expression grammars are a formalism that can describe all deterministic context-free languages and have a simple computational model. In this paper, we present a formalization of regexes via transformation to parsing expression grammars. The proposed transformation easily accommodates several common regex extensions, giving a formal meaning to them. It also provides a clear computational model that helps to estimate the efficiency of regex-based matchers, and a basis for specifying provably correct optimizations for them.

► We present a simple, structure-preserving translation from regexes to PEGs. ► We formally prove the correctness of our transformation. ► We show how to use a performance model of PEGs to optimize some classes of regexes. ► We show how our transformation can accommodate some ad-hoc extensions to regexes.

Related Topics
Physical Sciences and Engineering Computer Science Computational Theory and Mathematics
Authors
, , ,