|
{ |
|
"paper_id": "1991", |
|
"header": { |
|
"generated_with": "S2ORC 1.0.0", |
|
"date_generated": "2023-01-19T07:35:36.458791Z" |
|
}, |
|
"title": "INCREMENTAL LL(l) PARSING IN LANGUAGE-BASED EDITORS", |
|
"authors": [ |
|
{ |
|
"first": "John", |
|
"middle": [ |
|
"J" |
|
], |
|
"last": "Shilling", |
|
"suffix": "", |
|
"affiliation": { |
|
"laboratory": "", |
|
"institution": "Georgia Institute of Technology Atlanta", |
|
"location": { |
|
"postCode": "30332-0280", |
|
"country": "Georgia" |
|
} |
|
}, |
|
"email": "shilling@cc.gatech.edu" |
|
} |
|
], |
|
"year": "", |
|
"venue": null, |
|
"identifiers": {}, |
|
"abstract": "This paper introduces an efficient incremental LL(l) parsing algorithm for use in language-based editors that use the structure recognition approach. It fe atures very fine grained analysis and a unique approach to parse control and error recovery. It also presents incomplete LL(l) grammars as a way of dealing with the complex ity of fu ll language grammars and as a mechanism for providing structured editor support for task languages that are only partially structured. The semantics of in complete grammars are presented and it is shown how incomplete LL(l) grammars can be transformed into complete LL(l) grammars. The algorithms presented have been implemented in the fred language-based edi tor (Shi86] John J. Shilling. Automated Reference Li brarians fo r Program Libraries and Th eir In teraction with Language Based Editors. PhD thesis, Department of Computer Science,", |
|
"pdf_parse": { |
|
"paper_id": "1991", |
|
"_pdf_hash": "", |
|
"abstract": [ |
|
{ |
|
"text": "This paper introduces an efficient incremental LL(l) parsing algorithm for use in language-based editors that use the structure recognition approach. It fe atures very fine grained analysis and a unique approach to parse control and error recovery. It also presents incomplete LL(l) grammars as a way of dealing with the complex ity of fu ll language grammars and as a mechanism for providing structured editor support for task languages that are only partially structured. The semantics of in complete grammars are presented and it is shown how incomplete LL(l) grammars can be transformed into complete LL(l) grammars. The algorithms presented have been implemented in the fred language-based edi tor (Shi86] John J. Shilling. Automated Reference Li brarians fo r Program Libraries and Th eir In teraction with Language Based Editors. PhD thesis, Department of Computer Science,", |
|
"cite_spans": [], |
|
"ref_spans": [], |
|
"eq_spans": [], |
|
"section": "Abstract", |
|
"sec_num": null |
|
} |
|
], |
|
"body_text": [ |
|
{ |
|
"text": "<user change> <retokenization> <preparation of Parse Tree (Sweep)> <incremental parse> _ <semantic updat e>", |
|
"cite_spans": [], |
|
"ref_spans": [], |
|
"eq_spans": [], |
|
"section": "The parsing method described in this paper is more fine grained than previous methods. The goal is to re structure the editing buffer after each text-modifying keystroke of a user. The challenge is that it is often not possible to achieve a complete, correct structuralization because the user is in the process of making a change that is not yet complete. On the other hand, the user while (TRUE)", |
|
"sec_num": null |
|
}, |
|
{ |
|
"text": "tokenization. ", |
|
"cite_spans": [], |
|
"ref_spans": [], |
|
"eq_spans": [], |
|
"section": "42", |
|
"sec_num": null |
|
}, |
|
{ |
|
"text": "We now enter the actual incremental parsing algo rithm. The idea of the algorithm is similar to straight forward LL(l) parsing with several major differences. The incremental algorithm must decide how to handle the situations when it advances to a satisfied token ele ment but has a non-empty parsing queue and conversely when it empties the parsing \u2022 queue but has unsatisfied productions in the parse tree. The second situation is handled in follow-the-cursor parsing by essentially doing nothing. We do not want to remove any fu rther tokens fr om the parse tree so the algorithm simply leaves unsat isfied productions in the tree and displays them to the user as soft templates. In the first situation the algo rithm needs to open up space in the parse tree to accom modate the elements of the parsing queue. This is done by invoking a conflict resolution algorithm described be low. Following the description of the conflict resolution algorithm we will present two algorithms that together accomplish the incremental parsing desired. The first is the inner parsing algorithm that does most of the work and the second is the outer parsing algorithm that provides high level control.", |
|
"cite_spans": [], |
|
"ref_spans": [], |
|
"eq_spans": [], |
|
"section": "INCREMENTAL PARSING", |
|
"sec_num": null |
|
}, |
|
{ |
|
"text": "In our parsing algorithm we will need to resolve a con flict if the element at the front of the parse queue cannot be parsed at the current parse position. The conflict can exist because there is already a token at The goal is to parse the elements of the parse\u2022 queue by disrupting as small a region of the parse tree as possible. There is a conflict here because we want to parse the tokens in the parsing queue but we would like to keep the tokens that are on the tree intact if possible. Our solution to this is to give priority to the parsing of tokens before the cursor. This may mean dislocating tokens on the parse tree. If tokens are displaced, they are grafted to the tree as error nodes rather than moving them to the parsing queue.", |
|
"cite_spans": [], |
|
"ref_spans": [], |
|
"eq_spans": [], |
|
"section": "CONFLICT RESOLUTION", |
|
"sec_num": null |
|
}, |
|
{ |
|
"text": "We first present some definitions. resumption of the unstructured non-terminal then the follow set should be anything that does not cause con flict with the preferred production. Thus if p E Pu , y = left-hand-side{p ) , ", |
|
"cite_spans": [], |
|
"ref_spans": [ |
|
{ |
|
"start": 35, |
|
"end": 221, |
|
"text": "resumption of the unstructured non-terminal then the follow set should be anything that does not cause con flict with the preferred production. Thus if p E Pu , y = left-hand-side{p )", |
|
"ref_id": null |
|
} |
|
], |
|
"eq_spans": [], |
|
"section": "43", |
|
"sec_num": null |
|
}, |
|
{ |
|
"text": "A a C B b C C Unstructured", |
|
"cite_spans": [], |
|
"ref_spans": [], |
|
"eq_spans": [], |
|
"section": "Consider, for example, the grammar:", |
|
"sec_num": null |
|
} |
|
], |
|
"back_matter": [ |
|
{ |
|
"text": "For parse table calculations each unstructured non terminal is recognized as a separate production but is treated s,9inewhat differently when checking LL(l) grammar restrictions. Although they are technically different elements, unstructured elements must satisfy some restrictions as if they were the same terminal.", |
|
"cite_spans": [], |
|
"ref_spans": [], |
|
"eq_spans": [], |
|
"section": "The above example illustrates the spirit of the trans formation method on a very simple grammar. The re mainder of this section will show that the method can be applied to any incomplete grammar of the form de scribed by Orailoglu [Ora83]", |
|
"sec_num": null |
|
}, |
|
{ |
|
"text": "\u2022 The current parse queue element is a token that is not in the select set of the current non-terminal.", |
|
"cite_spans": [], |
|
"ref_spans": [], |
|
"eq_spans": [], |
|
"section": "An unstructured element may be legally derived at run-time if all of the following conditions apply: \u2022 The current parsing position is a non-terminal that can derive the unstructured element in the gram mar", |
|
"sec_num": null |
|
}, |
|
{ |
|
"text": "3This slight variation from Orailoglu's implementation is in troduced to give a more consistent treatment of W1Structured elements. ", |
|
"cite_spans": [], |
|
"ref_spans": [], |
|
"eq_spans": [], |
|
"section": "The transformation approach will be to replace each unstructured element U by a non-terminal Ut which is the left-hand-side of a production rule of the _ form", |
|
"sec_num": null |
|
}, |
|
{ |
|
"text": "where w and x may each be empty and where n # 1.", |
|
"cite_spans": [], |
|
"ref_spans": [], |
|
"eq_spans": [], |
|
"section": "A wUx rhs2", |
|
"sec_num": null |
|
}, |
|
{ |
|
"text": "\u2022 A preferred production cannot start or end with an unstructured element. ", |
|
"cite_spans": [], |
|
"ref_spans": [], |
|
"eq_spans": [], |
|
"section": "The last point to establish is the validity of the gram mar model in which the incomplete element was intro duced. The model is valid because only \u2022 one unstruc tured element needs to be concentrated oii at a time. This is true because \u2022 A non-terminal cannot have two separate unstructured elements in its first set. \u2022 \u2022 \u2022 \u2022 An unstructured element cannot have an unstruc tured element in its follow set.", |
|
"sec_num": null |
|
} |
|
], |
|
"bib_entries": { |
|
"BIBREF0": { |
|
"ref_id": "b0", |
|
"title": "Fred: A program devel opment tool", |
|
"authors": [ |
|
{ |
|
"first": "John", |
|
"middle": [ |
|
"J" |
|
], |
|
"last": "Shilling", |
|
"suffix": "" |
|
} |
|
], |
|
"year": 1951, |
|
"venue": "Proceedings of SOFTFA IR II (S an Fra ncisco", |
|
"volume": "", |
|
"issue": "", |
|
"pages": "", |
|
"other_ids": {}, |
|
"num": null, |
|
"urls": [], |
|
"raw_text": "John J. Shilling. Fred: A program devel opment tool. In Proceedings of SOFTFA IR II (S an Fra ncisco, California, December 3-5 1", |
|
"links": null |
|
} |
|
}, |
|
"ref_entries": { |
|
"FIGREF0": { |
|
"text": "We will ignore non-significant nodes such as error nodes and (usually) white space in this presentation Sweep(LexLeftBound, LexRightBound): CommonAncestor = CommonAncestor(LexLeftBound , LexRightBound) ; Royallode = Royallode(LexLeftBound) ; CleanRegion(LexLeftBound , LexRightBound , CommonAncestor) ; if (Royallode in subtree of CommonAnceator) DeleteSubtree(Royallode); Sweep as far as it can until it hits a token. The first non terminal to the right of that token becomes the location of the current parsing position.", |
|
"uris": null, |
|
"num": null, |
|
"type_str": "figure" |
|
}, |
|
"FIGREF1": { |
|
"text": "Parse Position as described above or it can exist simply because the Queue Element does not fit into the terminal or non terminal symbol at the Parse Position. The general al-gorithm would have grafted such an element as an error. That is not satisfactory here for two reasons. The first is that there are now non-terminal rooted subtrees on the Parse Queue as well as tokens. A subtree may not be parsable at this point but the tokens along its frontier may be. The second reason is that the algorithm does . not have the guarantee that the subtree rooted at _Parse . Position is properly prepared to be parsed because it may not have deleted the entire subtree rooted at Royal Node in the Sweep algorithm.", |
|
"uris": null, |
|
"num": null, |
|
"type_str": "figure" |
|
}, |
|
"FIGREF2": { |
|
"text": "Node is defined to be the highest node in the tree that has Parse Position as the first leaf of its frontier. If no such node exists then Royal Node is defined to be the node at Parse Position. \u2022 Decision Node is defined to be the lowest node on the path from Parse Position to Royal Node that has the element at the front of the Parse Queue in its first set. If no such node exists then Decision Node is defined to be NULL. \u2022 List Node is defined to be a node on the path from \u2022 the Decision Node to the Royal Node (inclusive) that is a list structured production. If no such node exists then List Node is defined to be NULL. \u2022 Nullable Node is defined to be a node along the path from the Parse Position to the Royal Node that is nullable and has the element at the front of the Parse Queue in its follow set. If no such node exists then Nullable Node is defined to be NULL. The Royal Node is the highest point in the parse tree where the token at Parse Position (or the token that previously was the first token of Parse Position) caused a decision to be made. The Decision Node, if it exists , is the lowest production along the path from Parse Po sition to Royal Node that the fr ont of the Parse Queue can belong to. If the Decision Node exists then we can try to find a List Node. List Node is a place in the parse tree where a list production can be found. This makes it a place where we can wedge in a new produc tion without tearing down any existing parse tree. At most one list node can be found because if there were two or more _ then there would be an ambiguous parse. Finally, Nullable Node is a node that can be nulled while still allowing the element at the front of the Parse Queue to be correctly parsed. It first finds the four nodes described \u2022 above. If List Node exists then the list production is expanded by an additional element using the GraftNewList subrou tine. In the StealProduction subroutine the tokens in the subtree rooted at the node of the first parameter are grafted to the right as error nodes. The (tokenless) subtree rooted at the node is then deleted leaving an open non-terminal that is either nullable or has the el ement at the fr ont of the parse queue in its first set . The final chance to avoid grafting an error token is if there is a non-terminal subtree at the front of the parse queue. In this case the nonterminal is removed and replaced with its children in the Reduce subroutine. This process continues until the algorithm has freed up a non-terminal in the parse tree or has emptied the parse queue. shows the inner parsing algorithm. This al gorithm iterates through its parsing decisions until it runs out of tokens and/or runs out of open parse tree. If the front of the parse queue and the predicted parse tree element at the current parsing position agree then the queue element is simply grafted onto the tree at the current position. The parse queue is then popped and the parse position advanced. It may be that there is not an exact match but that the queue element is in the select set of Parse Position. In that case the production", |
|
"uris": null, |
|
"num": null, |
|
"type_str": "figure" |
|
}, |
|
"FIGREF3": { |
|
"text": "Outer Parse for Follow-the-Cursor Parsing indicated is instantiated (there can be only one by LL(l) restrictions) and the Parse Position is advanced to the first element of the new production. If neither of the above cases hold then the element at the front of the parse queue does not fit at the current position. The algorithm checks to see if there is a non terminal subtree at the front of the parse queue that can be reduced. If this is not the case then it checks to see if Parse Position is nullable with Queue Element as a correct follow. If this is the case then the non terminal at Parse Position is nulled and Parse Position advances. If none of the above cases holds then the conflict resolution algorithm is invoked. OUTER PARSING ALGORITHM The outer parsing algorithm provides high level con trol over the inner parsing algorithm. It resolves con flicts when Parse Position is advanced to a token and Parse Queue is not empty or Parse Queue is empty but Parse Position is a non-satisfied production element. The former case is handled by the conflict resolution algorithm. The latter case is allowed as a legal state in follow-the-cursor parsing because tokens to the right of the cursor are not taken to satisfy the parse position. At the end of the normal parsing loop an error recov ery algorithm is called. The Error Recovery algorithm is the only algorithm that is allowed to parse past the cursor. In follow-the-cursor parsing it is sometimes nec essary to invoke the Steal Production process that grafts tokens as errors to the right of the current parse posi tion. It is also possible that a token has been inserted which will resolve an error in the syntax of the user buffer if they were included in the parse. The idea of the Error Recovery algorithm is to probe into the error tokens directly past the cursor to see if these tokens can be parsed correctly. An outline of the error recovery algorithm is presented ResolveConfilct(ParsePosition) while ((IDT Empty(ParaeQueue )) AID IsToken(ParsePosition) ) do Royallode = FindRoyal (ParsePosition) ; Deciaionlode = FindDecision (ParsePosition , Royallode , QueueElement ) Listlode = FindList(Decisionlode , Royallode); lullablelode = Findlullable(ParsePosition , Royallode , QueueElement ); if (Liatlode != IULL) then ParsePosition = GraftlevList(Listlode , ParsePosition) ; elseif (Decisionlode != IULL ) then ParsePosition = StealProduction(Decisionlode , ParsePosition) ; elseif (lullablelode != IULL ) then ParsePosition = StealProduction(lullablelode, ParsePosition) ; elaeif (Islonterm(QueueElement )) then Reduce(ParseQueue); else GraftError(ParsePoaition) ; endif endwhile", |
|
"uris": null, |
|
"num": null, |
|
"type_str": "figure" |
|
}, |
|
"FIGREF4": { |
|
"text": "Conflict Resolution AlgorithmInner Parse(ParsePosition, ParseQueue) while ((IDT Empty(ParseQueue)) AID (IDT Satisfied(ParsePosition) )) do QueueElement = Front (ParseQueue); if (QueueElement matches ParsePosition) then Graft(QueueElement , ParsePosition) ; Pop(ParseQueue); Advance(ParaePoaition) ; elaeif (Select [ParsePoaition, QueueElement] != ERROR) then Instantiate(ParaePosition , Select [ParsePosition, QueueElement] ); Advance(ParsePosition) ; elseit (QueueElement not a terminal) then Reduce(ParseQueue); elseif (lullable(ParsePosition) AID (Follows (ParsePosition, QueueElement )) then lullProduction(ParsePosition) ; Advance(ParsePosition) ; else ResolveConflict (ParsePosition , ParseQueue); endif endwhile Inner Parsing Algorithm Error Recovery < Set Consistent Parse > while (we have an error token) do it (token is parsable) then else", |
|
"uris": null, |
|
"num": null, |
|
"type_str": "figure" |
|
}, |
|
"FIGREF5": { |
|
"text": "start symbol of G, S E N. T is a finite set of terminal symbols. 2Qrailoglu refers to this non-tenninal class as Un known,.46 N is a finite set of non-terminal symbols. P is a set of production rules.An incomplete LL(l) grammar is described as a tupleG = (S, T, N, U, P,.Pu)where S, T, N, and P have their conventional meaning and U is a distinguished set of non-terminal symbols de noted unstn1ctured, U e N.", |
|
"uris": null, |
|
"num": null, |
|
"type_str": "figure" |
|
}, |
|
"FIGREF6": { |
|
"text": "of the grammar is {a, b, c, ERROR} . The intent of the grammar writer is clearly that a lead ing token of a will invoke the first right-hand-side, a leading token of b will invoke the second right-hand-side, and any other token will invoke the third right-hand-side because of the unstructured element. Thus the first set of the unstructured element is effectively {c, ERROR} and as a result the first set of non-terminalA is the entire token set. Now consider the grammar: The token set of this grammar is {b, c, d, ERROR} . The intent of the unstructured element in the grammar varies with the shape of the parse tree. If the current non-terminal is B then any token in the set { c, ERROR} will derive the unstructured element in D but if the non terminal is C then any token in the set {b, ERROR} will derive the unstructured element. The thing to note is that this can be predicted at the time that the grammar is analyzed. The above grammar can be transformed into the grammar: the same token set as the previous grammar. The only difference is that three new produc-\u2022 tions are introduced to represent the structure of the incomplete element. The first production gives the con ceptual structure of the incomplete element.", |
|
"uris": null, |
|
"num": null, |
|
"type_str": "figure" |
|
} |
|
} |
|
} |
|
} |