ppcrslidesannotated
DESCRIPTION
Though yacc-like LR parser generators provide ways to solve shift-reduceconflicts using token precedences, no mechanisms are providedfor the resolution of difficult reduce-reduce conflicts. To solve this kindof conflicts the language designer has to modify the grammar.TRANSCRIPT
![Page 1: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/1.jpg)
Solving Difficult LR Parsing Conflicts byPostponing Them
Luis Garcia-Forte and Casiano Rodriguez-LeonUniversidad de La Laguna
CoRTA2010 September 09-10, 2010
![Page 2: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/2.jpg)
Outline
Introduction
Context Dependent Parsing
Nested Parsing
Conclusions
![Page 3: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/3.jpg)
Outline
Introduction
Context Dependent Parsing
Nested Parsing
Conclusions
![Page 4: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/4.jpg)
Yacc Limitations
� Yacc-like LR parser generators provide ways to solveshift-reduce mechanisms based on token precedence.
� No mechanisms are provided for the resolution ofreduce-reduce conflicts or difficult shift-reduce conflicts.
� To solve such kind of conflicts the language designer hasto modify the grammar.
![Page 5: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/5.jpg)
Yacc Limitations
� Yacc-like LR parser generators provide ways to solveshift-reduce mechanisms based on token precedence.
� No mechanisms are provided for the resolution ofreduce-reduce conflicts or difficult shift-reduce conflicts.
� To solve such kind of conflicts the language designer hasto modify the grammar.
![Page 6: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/6.jpg)
Yacc Limitations
� Yacc-like LR parser generators provide ways to solveshift-reduce mechanisms based on token precedence.
� No mechanisms are provided for the resolution ofreduce-reduce conflicts or difficult shift-reduce conflicts.
� To solve such kind of conflicts the language designer hasto modify the grammar.
![Page 7: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/7.jpg)
Postponed Conflict Resolution Approach
� The strategy presented here extends yacc conflictresolution mechanisms with new ones, supplying ways toresolve conflicts that can not be solved using staticprecedences.
� The algorithm for the generation of the LR tables remainsunchanged, but the programmer can modify the parsingtables during run time.
![Page 8: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/8.jpg)
Postponed Conflict Resolution Approach
� The strategy presented here extends yacc conflictresolution mechanisms with new ones, supplying ways toresolve conflicts that can not be solved using staticprecedences.
� The algorithm for the generation of the LR tables remainsunchanged, but the programmer can modify the parsingtables during run time.
![Page 9: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/9.jpg)
Postponed Conflict Resolution Approach
� The strategy presented here extends yacc conflictresolution mechanisms with new ones, supplying ways toresolve conflicts that can not be solved using staticprecedences.
� The algorithm for the generation of the LR tables remainsunchanged, but the programmer can modify the parsingtables during run time.
![Page 10: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/10.jpg)
PPCR Approach: Identify the Conflict
� Identify the conflict: What LR(0)-items/productions andtokens are involved?.
� Tools must support that stage, as for example via the.output file generated by eyapp.
� Suppose we identify that the participants are the twoLR(0)-items
� A→ α↑and
� B → β↑when the lookahead token is@.
![Page 11: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/11.jpg)
PPCR Approach: Identify the Conflict
� Identify the conflict: What LR(0)-items/productions andtokens are involved?.
� Tools must support that stage, as for example via the.output file generated by eyapp.
� Suppose we identify that the participants are the twoLR(0)-items
� A→ α↑and
� B → β↑when the lookahead token is@.
![Page 12: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/12.jpg)
PPCR Approach: Identify the Conflict
� Identify the conflict: What LR(0)-items/productions andtokens are involved?.
� Tools must support that stage, as for example via the.output file generated by eyapp.
� Suppose we identify that the participants are the twoLR(0)-items
� A→ α↑and
� B → β↑when the lookahead token is@.
![Page 13: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/13.jpg)
PPCR Approach: Identify the Conflict
� Identify the conflict: What LR(0)-items/productions andtokens are involved?.
� Tools must support that stage, as for example via the.output file generated by eyapp.
� Suppose we identify that the participants are the twoLR(0)-items
� A→ α↑and
� B → β↑when the lookahead token is@.
![Page 14: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/14.jpg)
PPCR Approach: Identify the Conflict
� Identify the conflict: What LR(0)-items/productions andtokens are involved?.
� Tools must support that stage, as for example via the.output file generated by eyapp.
� Suppose we identify that the participants are the twoLR(0)-items
� A→ α↑
and� B → β↑
when the lookahead token is@.
![Page 15: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/15.jpg)
PPCR Approach: Identify the Conflict
� Identify the conflict: What LR(0)-items/productions andtokens are involved?.
� Tools must support that stage, as for example via the.output file generated by eyapp.
� Suppose we identify that the participants are the twoLR(0)-items
� A→ α↑and
� B → β↑when the lookahead token is@.
![Page 16: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/16.jpg)
PPCR Approach: Identify the Conflict
� Identify the conflict: What LR(0)-items/productions andtokens are involved?.
� Tools must support that stage, as for example via the.output file generated by eyapp.
� Suppose we identify that the participants are the twoLR(0)-items
� A→ α↑and
� B → β↑
when the lookahead token is@.
![Page 17: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/17.jpg)
PPCR Approach: Identify the Conflict
� Identify the conflict: What LR(0)-items/productions andtokens are involved?.
� Tools must support that stage, as for example via the.output file generated by eyapp.
� Suppose we identify that the participants are the twoLR(0)-items
� A→ α↑and
� B → β↑when the lookahead token is
@.
![Page 18: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/18.jpg)
PPCR Approach: Identify the Conflict
� Identify the conflict: What LR(0)-items/productions andtokens are involved?.
� Tools must support that stage, as for example via the.output file generated by eyapp.
� Suppose we identify that the participants are the twoLR(0)-items
� A→ α↑and
� B → β↑when the lookahead token is@.
![Page 19: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/19.jpg)
PPCR Approach: Identify the Conflict
� The software must allow the use of symbolic labels to referby name to the productions involved in the conflict.
� In Eyapp names and labels can be explicitly given usingthe directive %name, using a syntax similar to this one:
%name :rA A → α
%name :rB B → β
![Page 20: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/20.jpg)
PPCR Approach: Identify the Conflict
� The software must allow the use of symbolic labels to referby name to the productions involved in the conflict.
� In Eyapp names and labels can be explicitly given usingthe directive %name, using a syntax similar to this one:
%name :rA A → α
%name :rB B → β
![Page 21: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/21.jpg)
PPCR Approach: Identify the Conflict
� The software must allow the use of symbolic labels to referby name to the productions involved in the conflict.
� In Eyapp names and labels can be explicitly given usingthe directive %name, using a syntax similar to this one:
%name :rA A → α
%name :rB B → β
![Page 22: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/22.jpg)
PPCR Approach: Identify the Conflict
� Give a symbolic name to the conflict. In this case wechoose isAorB as name of the conflict.
� Inside the body section of the grammar, mark the points ofconflict using the new reserved word %PREC followed bythe conflict name:
%name :rA A → α %PREC IsAorB
%name :rA B → β %PREC IsAorB
![Page 23: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/23.jpg)
PPCR Approach: Identify the Conflict
� Give a symbolic name to the conflict. In this case wechoose isAorB as name of the conflict.
� Inside the body section of the grammar, mark the points ofconflict using the new reserved word %PREC followed bythe conflict name:
%name :rA A → α %PREC IsAorB
%name :rA B → β %PREC IsAorB
![Page 24: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/24.jpg)
PPCR Approach: Identify the Conflict
� Give a symbolic name to the conflict. In this case wechoose isAorB as name of the conflict.
� Inside the body section of the grammar, mark the points ofconflict using the new reserved word %PREC followed bythe conflict name:
%name :rA A → α %PREC IsAorB
%name :rA B → β %PREC IsAorB
![Page 25: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/25.jpg)
Conflict Identification: Shift-Reduce Conflicts
The procedure is similar for shift-reduce conflicts.
� Let us assume we have identified a shift-reduce conflictbetween LR-(0) items
� A→ α↑and
� B → β ↑ γ for some token ’@’.� Again, we must give a symbolic name to A→ α and mark
with the new %PREC directive the places where the conflictoccurs:
%name :rA A → α %PREC IsAorB
B → β %PREC IsAorB γ
![Page 26: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/26.jpg)
Conflict Identification: Shift-Reduce Conflicts
The procedure is similar for shift-reduce conflicts.� Let us assume we have identified a shift-reduce conflict
between LR-(0) items
� A→ α↑and
� B → β ↑ γ for some token ’@’.� Again, we must give a symbolic name to A→ α and mark
with the new %PREC directive the places where the conflictoccurs:
%name :rA A → α %PREC IsAorB
B → β %PREC IsAorB γ
![Page 27: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/27.jpg)
Conflict Identification: Shift-Reduce Conflicts
The procedure is similar for shift-reduce conflicts.� Let us assume we have identified a shift-reduce conflict
between LR-(0) items� A→ α↑
and� B → β ↑ γ for some token ’@’.
� Again, we must give a symbolic name to A→ α and markwith the new %PREC directive the places where the conflictoccurs:
%name :rA A → α %PREC IsAorB
B → β %PREC IsAorB γ
![Page 28: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/28.jpg)
Conflict Identification: Shift-Reduce Conflicts
The procedure is similar for shift-reduce conflicts.� Let us assume we have identified a shift-reduce conflict
between LR-(0) items� A→ α↑
and
� B → β ↑ γ for some token ’@’.� Again, we must give a symbolic name to A→ α and mark
with the new %PREC directive the places where the conflictoccurs:
%name :rA A → α %PREC IsAorB
B → β %PREC IsAorB γ
![Page 29: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/29.jpg)
Conflict Identification: Shift-Reduce Conflicts
The procedure is similar for shift-reduce conflicts.� Let us assume we have identified a shift-reduce conflict
between LR-(0) items� A→ α↑
and� B → β ↑ γ
for some token ’@’.� Again, we must give a symbolic name to A→ α and mark
with the new %PREC directive the places where the conflictoccurs:
%name :rA A → α %PREC IsAorB
B → β %PREC IsAorB γ
![Page 30: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/30.jpg)
Conflict Identification: Shift-Reduce Conflicts
The procedure is similar for shift-reduce conflicts.� Let us assume we have identified a shift-reduce conflict
between LR-(0) items� A→ α↑
and� B → β ↑ γ for some token ’@’.
� Again, we must give a symbolic name to A→ α and markwith the new %PREC directive the places where the conflictoccurs:
%name :rA A → α %PREC IsAorB
B → β %PREC IsAorB γ
![Page 31: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/31.jpg)
Conflict Identification: Shift-Reduce Conflicts
The procedure is similar for shift-reduce conflicts.� Let us assume we have identified a shift-reduce conflict
between LR-(0) items� A→ α↑
and� B → β ↑ γ for some token ’@’.
� Again, we must give a symbolic name to A→ α and markwith the new %PREC directive the places where the conflictoccurs:
%name :rA A → α %PREC IsAorB
B → β %PREC IsAorB γ
![Page 32: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/32.jpg)
PPCR Approach: The Conflict Handler
� Introduce a %conflict directive inside the head sectionof the translation scheme to specify the way the conflict willbe solved.
� The directive is followed by some code - known as theconflict handler - whose mission is to modify the parsingtables.
� This code will be executed each time the associatedconflict state is reached.
![Page 33: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/33.jpg)
PPCR Approach: The Conflict Handler
� Introduce a %conflict directive inside the head sectionof the translation scheme to specify the way the conflict willbe solved.
� The directive is followed by some code - known as theconflict handler - whose mission is to modify the parsingtables.
� This code will be executed each time the associatedconflict state is reached.
![Page 34: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/34.jpg)
PPCR Approach: The Conflict Handler
� Introduce a %conflict directive inside the head sectionof the translation scheme to specify the way the conflict willbe solved.
� The directive is followed by some code - known as theconflict handler - whose mission is to modify the parsingtables.
� This code will be executed each time the associatedconflict state is reached.
![Page 35: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/35.jpg)
PPCR Approach: The Conflict Handler
� Introduce a %conflict directive inside the head sectionof the translation scheme to specify the way the conflict willbe solved.
� The directive is followed by some code - known as theconflict handler - whose mission is to modify the parsingtables.
� This code will be executed each time the associatedconflict state is reached.
![Page 36: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/36.jpg)
PPCR Approach: The Conflict Handler
� This is the usual layout of the conflict handler for areduce-reduce conflict:
%conflict IsAorB {if (is_A) {$self->YYSetReduce(’@’, ’:rA’ );
}else {$self->YYSetReduce(’@’, ’:rB’ );
}}
Inside a conflict code handler the Perl default variable $_refers to the input and $self refers to the parser object.
![Page 37: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/37.jpg)
PPCR Approach: The Conflict Handler
�� This is the usual layout of the conflict handler for areduce-reduce conflict:
%conflict IsAorB {if (is_A) {$self->YYSetReduce(’@’, ’:rA’ );
}else {$self->YYSetReduce(’@’, ’:rB’ );
}}
Inside a conflict code handler the Perl default variable $_refers to the input and $self refers to the parser object.
![Page 38: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/38.jpg)
PPCR Approach: The Conflict Handler
�� This is the usual layout of the conflict handler for areduce-reduce conflict:
%conflict IsAorB {if (is_A) {$self->YYSetReduce(’@’, ’:rA’ );
}else {$self->YYSetReduce(’@’, ’:rB’ );
}}
Inside a conflict code handler the Perl default variable $_refers to the input and $self refers to the parser object.
![Page 39: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/39.jpg)
PPCR Approach: The Conflict Handler
�� This is the usual layout of the conflict handler for ashift-reduce conflict:
%conflict IsAorB {if (is_A) {$self->YYSetReduce(’@’, ’:rA’ );
}else {$self->YYSetShift(’@’);
}}
![Page 40: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/40.jpg)
PPCR Approach: The Conflict Handler
� The method YYSetReduce receives a list of tokens and aproduction label, like :rA. The call
$self->YYSetReduce(’@’, ’:rA’ )
sets the parsing action for the state associated with theconflict IsAorB to reduce by the production :rA when thecurrent lookahead is @.
� The method YYSetShift receives a token (or a referenceto a list of tokens). The call
$self->YYSetShift(’@’)
sets the parsing action for the state associated with theconflict IsAorB to shift when the current lookahead is @.
![Page 41: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/41.jpg)
PPCR Approach: The Conflict Handler
� The method YYSetReduce receives a list of tokens and aproduction label, like :rA. The call
$self->YYSetReduce(’@’, ’:rA’ )
sets the parsing action for the state associated with theconflict IsAorB to reduce by the production :rA when thecurrent lookahead is @.
� The method YYSetShift receives a token (or a referenceto a list of tokens). The call
$self->YYSetShift(’@’)
sets the parsing action for the state associated with theconflict IsAorB to shift when the current lookahead is @.
![Page 42: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/42.jpg)
PPCR Approach: The Conflict Handler
� The method YYSetReduce receives a list of tokens and aproduction label, like :rA. The call
$self->YYSetReduce(’@’, ’:rA’ )
sets the parsing action for the state associated with theconflict IsAorB to reduce by the production :rA when thecurrent lookahead is @.
� The method YYSetShift receives a token (or a referenceto a list of tokens). The call
$self->YYSetShift(’@’)
sets the parsing action for the state associated with theconflict IsAorB to shift when the current lookahead is @.
![Page 43: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/43.jpg)
PPCR Approach: The Conflict Handler
� %conflict IsAorB {if (is_A) { $self->YYSetReduce(’@’, ’:rA’ );}else { $self->YYSetReduce(’@’, ’:rB’ ); }
}
� The call to is_A represents the context-dependentdynamic knowledge that allows us to take the rightdecision.
� It is usually a call to a nested parser to check that A→ αapplies but it can also be any other contextual informationwe have to determine which one is the right production.
![Page 44: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/44.jpg)
PPCR Approach: The Conflict Handler
� %conflict IsAorB {if (is_A) { $self->YYSetReduce(’@’, ’:rA’ );}else { $self->YYSetReduce(’@’, ’:rB’ ); }
}
� The call to is_A represents the context-dependentdynamic knowledge that allows us to take the rightdecision.
� It is usually a call to a nested parser to check that A→ αapplies but it can also be any other contextual informationwe have to determine which one is the right production.
![Page 45: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/45.jpg)
Outline
Introduction
Context Dependent Parsing
Nested Parsing
Conclusions
![Page 46: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/46.jpg)
A Simple Example: Context Dependant Associativity
$ cat input_for_dynamicgrammar.txt2-1-1 # left: 0 = (2-1)-1
RIGHT
2-1-1 # right: 2 = 2-(1-1)
LEFT
3-1-1 # left: 1 = (3-1)-1
RIGHT3-1-1 # right: 3 = 3-(1-1)
![Page 47: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/47.jpg)
A Simple Example: Context Dependant Associativity
$ cat input_for_dynamicgrammar.txt2-1-1 # left: 0 = (2-1)-1
RIGHT
2-1-1 # right: 2 = 2-(1-1)
LEFT
3-1-1 # left: 1 = (3-1)-1
RIGHT3-1-1 # right: 3 = 3-(1-1)
![Page 48: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/48.jpg)
A Simple Example: Context Dependant Associativity
$ cat input_for_dynamicgrammar.txt2-1-1 # left: 0 = (2-1)-1
RIGHT
2-1-1 # right: 2 = 2-(1-1)
LEFT
3-1-1 # left: 1 = (3-1)-1
RIGHT3-1-1 # right: 3 = 3-(1-1)
![Page 49: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/49.jpg)
A Simple Example: Context Dependant Associativity
$ cat input_for_dynamicgrammar.txt2-1-1 # left: 0 = (2-1)-1
RIGHT
2-1-1 # right: 2 = 2-(1-1)
LEFT
3-1-1 # left: 1 = (3-1)-1
RIGHT3-1-1 # right: 3 = 3-(1-1)
![Page 50: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/50.jpg)
A Simple Example: Context Dependant Associativity
$ cat input_for_dynamicgrammar.txt2-1-1 # left: 0 = (2-1)-1
RIGHT
2-1-1 # right: 2 = 2-(1-1)
LEFT
3-1-1 # left: 1 = (3-1)-1
RIGHT3-1-1 # right: 3 = 3-(1-1)
![Page 51: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/51.jpg)
A Simple Example: Context Dependant Associativity
$ cat input_for_dynamicgrammar.txt2-1-1 # left: 0 = (2-1)-1
RIGHT
2-1-1 # right: 2 = 2-(1-1)
LEFT
3-1-1 # left: 1 = (3-1)-1
RIGHT3-1-1 # right: 3 = 3-(1-1)
![Page 52: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/52.jpg)
A Simple Example: Bodyp: c * {};
c: $expr { print "$expr\n" }| RIGHT { $reduce = 0}| LEFT { $reduce = 1}
;
expr: ’(’ $expr ’)’ { $expr }| NUM
| %name :Mexpr.left %PREC leftORright’-’ expr.right %PREC leftORright
{ $left - $right }
;%%
![Page 53: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/53.jpg)
A Simple Example: Bodyp: c * {};
c: $expr { print "$expr\n" }| RIGHT { $reduce = 0}| LEFT { $reduce = 1}
;
expr: ’(’ $expr ’)’ { $expr }| NUM
| %name :Mexpr.left %PREC leftORright’-’ expr.right %PREC leftORright
{ $left - $right }
;%%
![Page 54: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/54.jpg)
A Simple Example: Bodyp: c * {};
c: $expr { print "$expr\n" }| RIGHT { $reduce = 0}| LEFT { $reduce = 1}
;
expr: ’(’ $expr ’)’ { $expr }| NUM
| %name :Mexpr.left %PREC leftORright’-’ expr.right %PREC leftORright
{ $left - $right }
;%%
![Page 55: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/55.jpg)
A Simple Example: Bodyp: c * {};
c: $expr { print "$expr\n" }| RIGHT { $reduce = 0}| LEFT { $reduce = 1}
;
expr: ’(’ $expr ’)’ { $expr }| NUM
| %name :Mexpr.left %PREC leftORright’-’ expr.right %PREC leftORright
{ $left - $right }
;%%
![Page 56: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/56.jpg)
A Simple Example: Bodyp: c * {};
c: $expr { print "$expr\n" }| RIGHT { $reduce = 0}| LEFT { $reduce = 1}
;
expr: ’(’ $expr ’)’ { $expr }| NUM
| %name :Mexpr.left %PREC leftORright’-’ expr.right %PREC leftORright
{ $left - $right }
;%%
![Page 57: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/57.jpg)
A Simple Example: Head Section$ cat dynamicgrammar.eyp
%{my $reduce = 1;%}
%whites /(\s*(?:#.*)?\s*)/%token NUM = /(\d+)/
%conflict leftORright {if ($reduce) { $self->YYSetReduce(’-’, ’:M’) }else { $self->YYSetShift(’-’) }
}
%expect 1
%%
![Page 58: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/58.jpg)
A Simple Example: Head Section$ cat dynamicgrammar.eyp
%{my $reduce = 1;%}
%whites /(\s*(?:#.*)?\s*)/%token NUM = /(\d+)/
%conflict leftORright {if ($reduce) { $self->YYSetReduce(’-’, ’:M’) }else { $self->YYSetShift(’-’) }
}
%expect 1
%%
![Page 59: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/59.jpg)
A Simple Example: Head Section$ cat dynamicgrammar.eyp
%{my $reduce = 1;%}
%whites /(\s*(?:#.*)?\s*)/%token NUM = /(\d+)/
%conflict leftORright {if ($reduce) { $self->YYSetReduce(’-’, ’:M’) }else { $self->YYSetShift(’-’) }
}
%expect 1
%%
![Page 60: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/60.jpg)
A Simple Example: Head Section$ cat dynamicgrammar.eyp
%{my $reduce = 1;%}
%whites /(\s*(?:#.*)?\s*)/%token NUM = /(\d+)/
%conflict leftORright {if ($reduce) { $self->YYSetReduce(’-’, ’:M’) }else { $self->YYSetShift(’-’) }
}
%expect 1
%%
![Page 61: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/61.jpg)
A Simple Example: Head Section$ cat dynamicgrammar.eyp
%{my $reduce = 1;%}
%whites /(\s*(?:#.*)?\s*)/%token NUM = /(\d+)/
%conflict leftORright {if ($reduce) { $self->YYSetReduce(’-’, ’:M’) }else { $self->YYSetShift(’-’) }
}
%expect 1
%%
![Page 62: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/62.jpg)
Outline
Introduction
Context Dependent Parsing
Nested Parsing
Conclusions
![Page 63: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/63.jpg)
Enumerated and Subrange Types in Pascal
� The problem is taken from the Bison manual.
type subrange = lo .. hi;type enum = (a, b, c);
� The Pascal standard allows only numeric literals andconstant identifiers for the subrange bounds (lo and hi),but Extended Pascal and many other implementationsallow arbitrary expressions there.
type subrange = (a) .. b;type enum = (a);
� To aggravate the conflict we have added the C commaoperator to the language
type subrange = (a, b, c) .. (d, e);type enum = (a, b, c);
![Page 64: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/64.jpg)
Enumerated and Subrange Types in Pascal
� The problem is taken from the Bison manual.
type subrange = lo .. hi;type enum = (a, b, c);
� The Pascal standard allows only numeric literals andconstant identifiers for the subrange bounds (lo and hi),but Extended Pascal and many other implementationsallow arbitrary expressions there.
type subrange = (a) .. b;type enum = (a);
� To aggravate the conflict we have added the C commaoperator to the language
type subrange = (a, b, c) .. (d, e);type enum = (a, b, c);
![Page 65: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/65.jpg)
Enumerated and Subrange Types in Pascal
� The problem is taken from the Bison manual.
type subrange = lo .. hi;type enum = (a, b, c);
� The Pascal standard allows only numeric literals andconstant identifiers for the subrange bounds (lo and hi),but Extended Pascal and many other implementationsallow arbitrary expressions there.
type subrange = (a) .. b;type enum = (a);
� To aggravate the conflict we have added the C commaoperator to the language
type subrange = (a, b, c) .. (d, e);type enum = (a, b, c);
![Page 66: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/66.jpg)
Enumerated and Subrange Types in Pascal
� The problem is taken from the Bison manual.
type subrange = lo .. hi;type enum = (a, b, c);
� The Pascal standard allows only numeric literals andconstant identifiers for the subrange bounds (lo and hi),but Extended Pascal and many other implementationsallow arbitrary expressions there.
type subrange = (a) .. b;type enum = (a);
� To aggravate the conflict we have added the C commaoperator to the language
type subrange = (a, b, c) .. (d, e);type enum = (a, b, c);
![Page 67: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/67.jpg)
Enumerated vs Range: Full Grammar%token ID = /([A-Za-z]\w*)/%token NUM = /(\d+)/
%left ’,’%left ’-’ ’+’%left ’*’ ’/’
%%type_decl : ’TYPE’ ID ’=’ type ’;’ ;
type : ’(’ id_list ’)’ | expr ’..’ expr ;
id_list : ID | id_list ’,’ ID ;expr : ID
| NUM | ’(’ expr ’)’| expr ’,’ expr /* new */| expr ’+’ expr | expr ’-’ expr| expr ’*’ expr | expr ’/’ expr
;
![Page 68: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/68.jpg)
Enumerated vs Range: Full Grammar%token ID = /([A-Za-z]\w*)/%token NUM = /(\d+)/
%left ’,’%left ’-’ ’+’%left ’*’ ’/’
%%type_decl : ’TYPE’ ID ’=’ type ’;’ ;
type : ’(’ id_list ’)’ | expr ’..’ expr ;
id_list : ID | id_list ’,’ ID ;expr : ID
| NUM | ’(’ expr ’)’| expr ’,’ expr /* new */| expr ’+’ expr | expr ’-’ expr| expr ’*’ expr | expr ’/’ expr
;
![Page 69: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/69.jpg)
Enumerated vs Range: Full Grammar%token ID = /([A-Za-z]\w*)/%token NUM = /(\d+)/
%left ’,’%left ’-’ ’+’%left ’*’ ’/’
%%type_decl : ’TYPE’ ID ’=’ type ’;’ ;
type : ’(’ id_list ’)’ | expr ’..’ expr ;
id_list : ID | id_list ’,’ ID ;expr : ID
| NUM | ’(’ expr ’)’| expr ’,’ expr /* new */| expr ’+’ expr | expr ’-’ expr| expr ’*’ expr | expr ’/’ expr
;
![Page 70: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/70.jpg)
Enumerated vs Range: Full Grammar%token ID = /([A-Za-z]\w*)/%token NUM = /(\d+)/
%left ’,’%left ’-’ ’+’%left ’*’ ’/’
%%type_decl : ’TYPE’ ID ’=’ type ’;’ ;
type : ’(’ id_list ’)’ | expr ’..’ expr ;
id_list : ID | id_list ’,’ ID ;expr : ID
| NUM | ’(’ expr ’)’| expr ’,’ expr /* new */| expr ’+’ expr | expr ’-’ expr| expr ’*’ expr | expr ’/’ expr
;
![Page 71: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/71.jpg)
Enumerated vs Range: Full Grammar%token ID = /([A-Za-z]\w*)/%token NUM = /(\d+)/
%left ’,’%left ’-’ ’+’%left ’*’ ’/’
%%type_decl : ’TYPE’ ID ’=’ type ’;’ ;
type : ’(’ id_list ’)’ | expr ’..’ expr ;
id_list : ID | id_list ’,’ ID ;expr : ID
| NUM | ’(’ expr ’)’| expr ’,’ expr /* new */| expr ’+’ expr | expr ’-’ expr| expr ’*’ expr | expr ’/’ expr
;
![Page 72: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/72.jpg)
Identifying the Conflict$ eyapp -v pascalenumeratedvsrange.eyp2 reduce/reduce conflicts
State 11:id_list -> ID . (Rule 4)expr -> ID . (Rule 12)
’)’ [reduce using rule 12 (expr)]’)’ reduce using rule 4 (id_list)’,’ [reduce using rule 12 (expr)]’,’ reduce using rule 4 (id_list)
’*’ reduce using rule 12 (expr)’+’ reduce using rule 12 (expr)’-’ reduce using rule 12 (expr)’/’ reduce using rule 12 (expr)
![Page 73: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/73.jpg)
Identifying the Conflict$ eyapp -v pascalenumeratedvsrange.eyp2 reduce/reduce conflicts
State 11:id_list -> ID . (Rule 4)expr -> ID . (Rule 12)
’)’ [reduce using rule 12 (expr)]’)’ reduce using rule 4 (id_list)’,’ [reduce using rule 12 (expr)]’,’ reduce using rule 4 (id_list)
’*’ reduce using rule 12 (expr)’+’ reduce using rule 12 (expr)’-’ reduce using rule 12 (expr)’/’ reduce using rule 12 (expr)
![Page 74: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/74.jpg)
Enumerated vs Range: Body
type_decl : ’type’ ID ’=’ type ’;’ ;
type :%name ENUMLookahead ’(’ id_list ’)’
| %name RANGELookahead expr ’..’ expr
;Lookahead: /* empty */
{ $is_range = $_[0]->YYPreParse(’Range’); };
![Page 75: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/75.jpg)
Enumerated vs Range: Body
type_decl : ’type’ ID ’=’ type ’;’ ;
type :%name ENUMLookahead ’(’ id_list ’)’
| %name RANGELookahead expr ’..’ expr
;
Lookahead: /* empty */{ $is_range = $_[0]->YYPreParse(’Range’); }
;
![Page 76: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/76.jpg)
Enumerated vs Range: Body
type_decl : ’type’ ID ’=’ type ’;’ ;
type :%name ENUMLookahead ’(’ id_list ’)’
| %name RANGELookahead expr ’..’ expr
;Lookahead: /* empty */{ $is_range = $_[0]->YYPreParse(’Range’); }
;
![Page 77: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/77.jpg)
Nested Parsing: Future Work
$ cat Range2.eyp
%from pascalnestedeyapp2 import expr%%range: expr ’..’ expr ’;’;%%
![Page 78: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/78.jpg)
Nested Parsing: Current State$ cat Range.eyp%token ID = /([A-Za-z]\w*)/%token NUM = /(\d+)/
%left ’,’%left ’-’ ’+’%left ’*’ ’/’
%%range: expr ’..’ expr ’;’;
expr : ’(’ expr ’)’| expr ’+’ expr | expr ’-’ expr| expr ’*’ expr | expr ’/’ expr| expr ’,’ expr | ID | NUM
;%%
![Page 79: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/79.jpg)
Enumerated vs Range: Body
id_list :%name ID:ENUMID %PREC rangeORenum
| id_list ’,’ ID;expr : ’(’ expr ’)’ { $_[2] } /* bypass */
| %name ID:RANGEID %PREC rangeORenum
| %name PLUS expr ’+’ expr| %name MINUS expr ’-’ expr| %name TIMES expr ’*’ expr| %name DIV expr ’/’ expr| %name COMMA expr ’,’ expr| %name NUM NUM
;
%%
![Page 80: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/80.jpg)
Enumerated vs Range: Bodyid_list :
%name ID:ENUMID %PREC rangeORenum
| id_list ’,’ ID;
expr : ’(’ expr ’)’ { $_[2] } /* bypass */| %name ID:RANGE
ID %PREC rangeORenum| %name PLUS expr ’+’ expr| %name MINUS expr ’-’ expr| %name TIMES expr ’*’ expr| %name DIV expr ’/’ expr| %name COMMA expr ’,’ expr| %name NUM NUM
;
%%
![Page 81: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/81.jpg)
Enumerated vs Range: Bodyid_list :
%name ID:ENUMID %PREC rangeORenum
| id_list ’,’ ID;expr : ’(’ expr ’)’ { $_[2] } /* bypass */
| %name ID:RANGEID %PREC rangeORenum
| %name PLUS expr ’+’ expr| %name MINUS expr ’-’ expr| %name TIMES expr ’*’ expr| %name DIV expr ’/’ expr| %name COMMA expr ’,’ expr| %name NUM NUM
;
%%
![Page 82: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/82.jpg)
Enumerated vs Range: Header
%{my $is_range = 0;
%}%conflict rangeORenum {if ($is_range){ $self->YYSetReduce([’,’, ’)’], ’ID:RANGE’ ); }else{ $self->YYSetReduce([’,’, ’)’], ’ID:ENUM’ ); }
}
%token ID = /([A-Za-z]\w*)/%token NUM = /(\d+)/
%left ’,’%left ’-’ ’+’%left ’*’ ’/’
%expect-rr 2%%
![Page 83: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/83.jpg)
Enumerated vs Range: Header%{my $is_range = 0;
%}%conflict rangeORenum {if ($is_range){ $self->YYSetReduce([’,’, ’)’], ’ID:RANGE’ ); }else{ $self->YYSetReduce([’,’, ’)’], ’ID:ENUM’ ); }
}
%token ID = /([A-Za-z]\w*)/%token NUM = /(\d+)/
%left ’,’%left ’-’ ’+’%left ’*’ ’/’
%expect-rr 2%%
![Page 84: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/84.jpg)
Enumerated vs Range: Header%{my $is_range = 0;
%}%conflict rangeORenum {if ($is_range){ $self->YYSetReduce([’,’, ’)’], ’ID:RANGE’ ); }else{ $self->YYSetReduce([’,’, ’)’], ’ID:ENUM’ ); }
}
%token ID = /([A-Za-z]\w*)/%token NUM = /(\d+)/
%left ’,’%left ’-’ ’+’%left ’*’ ’/’
%expect-rr 2%%
![Page 85: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/85.jpg)
Enumerated vs Range: Header%{my $is_range = 0;
%}%conflict rangeORenum {if ($is_range){ $self->YYSetReduce([’,’, ’)’], ’ID:RANGE’ ); }else{ $self->YYSetReduce([’,’, ’)’], ’ID:ENUM’ ); }
}
%token ID = /([A-Za-z]\w*)/%token NUM = /(\d+)/
%left ’,’%left ’-’ ’+’%left ’*’ ’/’
%expect-rr 2%%
![Page 86: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/86.jpg)
Enumerated vs Range: Header%{my $is_range = 0;
%}%conflict rangeORenum {if ($is_range){ $self->YYSetReduce([’,’, ’)’], ’ID:RANGE’ ); }else{ $self->YYSetReduce([’,’, ’)’], ’ID:ENUM’ ); }
}
%token ID = /([A-Za-z]\w*)/%token NUM = /(\d+)/
%left ’,’%left ’-’ ’+’%left ’*’ ’/’
%expect-rr 2%%
![Page 87: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/87.jpg)
Enumerated vs Range: Execution
$ eyapp -P Range.eyp
$ eyapp -TC pascalnestedeyapp2.eyp
$ ./pascalnestedeyapp2.pm -t -i -m 1 \-c ’type e = (x, y, z);’
typeDecl_is_type_ID_type(TERMINAL[e],ENUM(idList_is_idList_ID(
idList_is_idList_ID(ID(TERMINAL[x]),TERMINAL[y]),
TERMINAL[z])))
![Page 88: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/88.jpg)
Enumerated vs Range: Execution
$ eyapp -P Range.eyp
$ eyapp -TC pascalnestedeyapp2.eyp
$ ./pascalnestedeyapp2.pm -t -i -m 1 \-c ’type e = (x, y, z);’
typeDecl_is_type_ID_type(TERMINAL[e],ENUM(idList_is_idList_ID(
idList_is_idList_ID(ID(TERMINAL[x]),TERMINAL[y]),
TERMINAL[z])))
![Page 89: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/89.jpg)
Enumerated vs Range: Execution
$ eyapp -P Range.eyp
$ eyapp -TC pascalnestedeyapp2.eyp
$ ./pascalnestedeyapp2.pm -t -i -m 1 \-c ’type e = (x, y, z);’
typeDecl_is_type_ID_type(TERMINAL[e],ENUM(idList_is_idList_ID(
idList_is_idList_ID(ID(TERMINAL[x]),TERMINAL[y]),
TERMINAL[z])))
![Page 90: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/90.jpg)
Enumerated vs Range: Execution
$ eyapp -P Range.eyp
$ eyapp -TC pascalnestedeyapp2.eyp
$ ./pascalnestedeyapp2.pm -t -i -m 1 \-c ’type e = (x, y, z);’
typeDecl_is_type_ID_type(TERMINAL[e],ENUM(idList_is_idList_ID(
idList_is_idList_ID(ID(TERMINAL[x]),TERMINAL[y]),
TERMINAL[z])))
![Page 91: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/91.jpg)
Outline
Introduction
Context Dependent Parsing
Nested Parsing
Conclusions
![Page 92: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/92.jpg)
Conclusions
� The new conflict resolution mechanisms provide ways toresolve conflicts that can not be solved using staticprecedences.
� They also provides finer control over the conflict resolutionprocess than existing alternatives, like GLR andbacktracking LR.
� There are no limitations to PPCR parsing, since the conflicthandler is implemented in a universal language and it thencan resort to any kind of nested parsing algorithm.
� The conflict resolution mechanisms presented here can beintroduced in any LR parsing tools.
� It certainly involves more programmer work than branchingmethods like GLR or backtracking LR.
![Page 93: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/93.jpg)
Conclusions
� The new conflict resolution mechanisms provide ways toresolve conflicts that can not be solved using staticprecedences.
� They also provides finer control over the conflict resolutionprocess than existing alternatives, like GLR andbacktracking LR.
� There are no limitations to PPCR parsing, since the conflicthandler is implemented in a universal language and it thencan resort to any kind of nested parsing algorithm.
� The conflict resolution mechanisms presented here can beintroduced in any LR parsing tools.
� It certainly involves more programmer work than branchingmethods like GLR or backtracking LR.
![Page 94: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/94.jpg)
Conclusions
� The new conflict resolution mechanisms provide ways toresolve conflicts that can not be solved using staticprecedences.
� They also provides finer control over the conflict resolutionprocess than existing alternatives, like GLR andbacktracking LR.
� There are no limitations to PPCR parsing, since the conflicthandler is implemented in a universal language and it thencan resort to any kind of nested parsing algorithm.
� The conflict resolution mechanisms presented here can beintroduced in any LR parsing tools.
� It certainly involves more programmer work than branchingmethods like GLR or backtracking LR.
![Page 95: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/95.jpg)
Conclusions
� The new conflict resolution mechanisms provide ways toresolve conflicts that can not be solved using staticprecedences.
� They also provides finer control over the conflict resolutionprocess than existing alternatives, like GLR andbacktracking LR.
� There are no limitations to PPCR parsing, since the conflicthandler is implemented in a universal language and it thencan resort to any kind of nested parsing algorithm.
� The conflict resolution mechanisms presented here can beintroduced in any LR parsing tools.
� It certainly involves more programmer work than branchingmethods like GLR or backtracking LR.
![Page 96: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/96.jpg)
Conclusions
� The new conflict resolution mechanisms provide ways toresolve conflicts that can not be solved using staticprecedences.
� They also provides finer control over the conflict resolutionprocess than existing alternatives, like GLR andbacktracking LR.
� There are no limitations to PPCR parsing, since the conflicthandler is implemented in a universal language and it thencan resort to any kind of nested parsing algorithm.
� The conflict resolution mechanisms presented here can beintroduced in any LR parsing tools.
� It certainly involves more programmer work than branchingmethods like GLR or backtracking LR.
![Page 97: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/97.jpg)
Conclusions
� The new conflict resolution mechanisms provide ways toresolve conflicts that can not be solved using staticprecedences.
� They also provides finer control over the conflict resolutionprocess than existing alternatives, like GLR andbacktracking LR.
� There are no limitations to PPCR parsing, since the conflicthandler is implemented in a universal language and it thencan resort to any kind of nested parsing algorithm.
� The conflict resolution mechanisms presented here can beintroduced in any LR parsing tools.
� It certainly involves more programmer work than branchingmethods like GLR or backtracking LR.
![Page 98: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/98.jpg)
http://parse-eyapp.googlecode.com/svn/branches/PPCR
Thanks!
![Page 99: Ppcrslidesannotated](https://reader033.vdocuments.net/reader033/viewer/2022051818/5495f439b479596a4d8b4e62/html5/thumbnails/99.jpg)
http://parse-eyapp.googlecode.com/svn/branches/PPCR
Thanks!