Ameba Ownd

アプリで簡単、無料ホームページ作成

Regular expression pdf download

2021.12.19 11:18






















In the text processing area, the IS0 Standard for SGML standard general markup language provides a syntactic metalanguage for the definition of textual markup systems. Such markup systems facilitate the electronic interchange of electronic documents and provide a standard basis for accessing and displaying them.


Regular expressions into jinite automata In the SGML context, the only valid regular expressions are those for which the Glushkov automaton is deterministic. The languages recognized by deterministic regular expressions have been characterized [6]. Here we show that for a deterministic expression a deterministic finite automaton can be constructed in linear time. This implies that LL l parsing tables of linear size can be generated for the context-free grammars SGML uses to describe document types.


When transforming language descriptions from one type to another, e. Indeed, this was the motivation for Book et al. They showed that a regular expression E is unambiguous if and only if ME is unambiguous. An s-NFA M is unambiguous if for each work w, there is at most one path through the state diagram of M that spells out w [2]. A regular expression E is unambiguous if, for each word w, there is at most one path through E that matches w [5]. Thus, in unambiguous s-NFAs, semantic procedures can be attached to transitions, and in unambiguous regular expressions, they can be attached to occur- rences of symbols.


We call the kind of ambiguity for regular expressions as defined above weak, as opposed to another definition given by Sippu and Soisalon-Soininen [15]. Their strong unambiguity allows semantic procedures to be attached not only to the symbols but also to the operators in a regular expression.


Thus, any symbol in a word can be matched by exactly one position in the expression. The two notions of unambiguity are related via our notion of star normal form. In Theorem 4. Finally, we turn to the decision problem for weak unambiguity. Unambiguity of E-NFAs can be reduced in linear time to the LR 0 property for context-free gram- mars, which has quadratic-time complexity [15].


Thus, there is a quadratic-time algorithm to decide whether an expression is strongly unambiguous. On the other hand, weak unambiguity can as well be reduced to unambiguity of NFAs via the Glushkov construction, but because the reduction is quadratic in time and size, this yields a biquadratic decision algorithm for weak unambiguity.


Alternatively, Book et al. Evans, given, for example, in the textbook of Hennie [ll]. This algorithm boils down to testing, for any two different states p and 4 of MB that can be reached from the initial state by means of a common word w, whether there is a state I and transitions from p to r and q to r on a common symbol a. Essentially, ME and, hence, E is weakly unambiguous if no such pair of states can be found.


A straightforward implementation of this algorithm is biquadratic in the size of E, too. This transformation preserves weak unambiguity and, for expres- sions in star-normal form, weak and strong unambiguity are essentially the same.


Thus, we provide the first algorithm for deciding weak unambiguity in quadratic time Theorem 4. A straightforward implementation of the construction runs in time cubic in the size of E. We show that the implementation can be modified to run in quadratic time, provided that E is in star normal form.


In the next section, we show that a regular expression can be transformed into star normal form, in linear time, while leaving the Glushkov automaton intact. Together, this implies that the Glushkov automaton can be constructed from an expression in quadratic time. Let C be a finite alphabet of symbols. Uppercase letters such as E, F, and G denote regular expressions and Y E denotes the language specified by a regular expression E. To indicate different positions or occurrences of the same symbol in an expression, we mark symbols with subscripts.


With this approach the subscripted symbols ai and bj are called positions and the set of subscripted symbols in an expression E written in this form is denoted by pas E. We use x, y, z as variables for positions and a, b, c for elements of C. Finally, for a position x, let x x be the corresponding symbol of Z.


The size of an NFA is the number of its transitions. Three functions capture the notion of a position in a regular expression matching a symbol in a word. These functions are:jrst E , the set of positions that match the first symbol of some word in L! Definition 2. The function jXow E,. Berry and Sethi have shown that ME is a natural representation of E [4].


The inductive definition suggests a computation ofjrst, last, and follow that is cubic in the size of E. First, we describe this canonical method. Then we refine the method to achieve quadratic time complexity. Let n be the size of E. We begin by converting E into a syntax tree. Since the regular expressions are generated by an LL 1 grammar, this can be done in time O n [ Each node v of the syntax tree corresponds to a subexpression E, of E.


At each node v of the syntax tree we provide variables. The variable nullabZe v indicates whether the subexpression E, corresponding to v contains the empty word, jrst v and last v hold the first and last positions of E,, and follow x holds the positions of E following x in E.


We perform a postorder traversal of the syntax tree and at each node v, the variables for v are computed. More precisely, at each node v the following code is executed. Lemma 2. If sets are represented as ordered lists, then the union of two sets can be implemented in time linear in the size of the sets. Such expressions are in star normal form. Then we show that our algorithm runs in time O size M, for expressions E in star normal form.


Finally, in the next section, we show why the restriction to star normal form is justified. Let E be a regular expression in star normal form. Let E be in star normal form. Furthermore, Y and Z will never again be referred to by the program. Thus, we can represent sets as unordered lists and we can implement the union in constant time as list concatenation without copying, possibly destroying the binding of Y and Z to its values in the process.


In these cases, Z is referred to several times in a for-loop and, thus, must be preserved. Hence, we implement the union as copying the elements of Z one by one to the end of Y. The run time is proportional to the size of Z.


Finally, we have to estimate the run time of the algorithm against the size of ME. The crucial observation is that for any subexpression F of a subexpression G of E and for any xepos F , we have. Regular expressions into finite automata Theorem 3. Lemma 3. Claims 5 and 6 are Proof. The first four claims are straightforward proved by induction of E. We only show the induction step for concatenation. The other cases follow from the induction hypothesis.


This case follows directly from the induction hypothesis. Claims 7 and 8 follow directly from 5 and 6. Claims 4 and 5 imply the first part of Theorem 3. The proof is by induction on the size of E.


The interesting case is the star in the induction step. By induction of E. We show the induction step for the star. This completes the proof of Theorem 3. By induction on E. According to Theorem 3. For such expressions, the Glushkov automaton can be constructed in linear time. Definition 3. Regular expressions into jnite automata Hence, we can assume that E is in star normal form. At this point, only time linear in the size of E has been spent. If no such situation occurs, the entire Glushkov automaton of E is constructed.


In this case, E is deterministic and the size of ME is linear in the size of E. Thus, the time spent in constructing ME is linear in the size of E, too. Two types of unambiguity of regular expressions have been defined in the literature. An expression E is weakly unambiguous [5] if each word of E can be traced uniquely with a path through E, whereas E is strongly unambiguous [15] if each word of E can be uniquely decomposed into subwords according to the syntactic structure of E.


The relationship between the two concepts of unambiguity has not been investigated so far. When processing text files, the awk language is ideal for handling data extraction, reporting, and data-reformatting jobs. This book is useful for novices and awk experts alike. In this thoroughly revised 5th edition, JavaScript RegExp. The book heavily leans on examples to present features of regular expressions one by one. It is recommended that you manually type each example and experiment with them.


You should have a good understanding of basic-level programming concepts and prior experience working with JavaScript. Published by bMBS. Developed by bMBS. Approximate size Age rating For all ages. This app can Use your location Access your Internet connection and act as a server.


Permissions info. Installation Get this app while signed in to your Microsoft account and install on up to ten Windows 10 devices. Language supported English United States.


Additional terms Terms of transaction. Seizure warnings Photosensitive seizure warning. Report this product Report this app to Microsoft Thanks for reporting your concern. Our team will review it and, if necessary, take action.