Skip to Content.
Sympa Menu

k-user - Re: [[K-user] ] Treating equally

k-user AT lists.cs.illinois.edu

Subject: K-user mailing list

List archive

Re: [[K-user] ] Treating equally


Chronological Thread 
  • From: Markus Knecht <markus.knecht85 AT gmail.com>
  • To: "k-user AT lists.cs.illinois.edu" <k-user AT lists.cs.illinois.edu>
  • Subject: Re: [[K-user] ] Treating equally
  • Date: Mon, 01 Jan 2018 18:24:48 +0000
  • Authentication-results: illinois.edu; spf=pass smtp.mailfrom=markus.knecht85 AT gmail.com

I thought I give a more concrete example (simplified, the tree structure is larger in reality).

Originally:
syntax Modifier ::= "A" | "B" | "C"
syntax ModedTExp ::= Modifier TExp | TExp
syntax TExp ::= Id "[" TExps "]"
syntax TExps ::= List{TExp,","}

New:
syntax ModifierA ::= "A" | "B" 
syntax ModedTExpA ::= ModifierA TExpA | TExpA
syntax TExpA ::= Id "[" TExpsA "]"
syntax TExpsA ::= List{TExpA,","}  

syntax ModifierB ::= "A" | "C" 
syntax ModedTExpB ::= ModifierB TExpB | TExpB
syntax TExpB ::= Id "[" TExpsB "]"
syntax TExpsB ::= List{TExpB,","}    

so they only differ in the modifiers they can contain. I would now like to write rules that can work on both of them (in reality they are 3 and potentially more coming in the future) and be treating them as if they were like the original with a combined modifier set. I do not need to distinguish between the two versions on the semantic level just on the parsing level, as the parsing enforces that no wrong modifier sneaks in and thus this has not to be checked at the semantic level.

Is there a way to elegantly do that?

Markus Knecht <markus.knecht85 AT gmail.com> schrieb am Mo., 1. Jan. 2018 um 19:01 Uhr:
I had some Syntax rules which parsed a recursive tree-like structure, which worked fine. Now I had the situation where I needed to parse this at different locations but with minor differences (the allowed modifiers in front of syntactical elements were different). To achieve this I copied the whole tree for each location and made the respective changes. It is the case that the different trees can be treated the same on a semantic level so I introduced a generic Tree and made the corresponding specialised syntax elements part of the generic one. Sadly this did not work, as I know had ambiguities as some constructs can be parsed by all specific trees and the generic tree as well. I removed them with unique klabels as suggested by the compiler, but now my rules that are defined in terms of the generic one do no longer apply if something was parsed by the specific ones. I can solve this by eliminating the generic tree and providing a rule multiple times once for each spezialised tree structure, the copies only differ in the used sorts. This seems highly complicated is their a simpler way of doing this?
If not I will probably write only one tree and check the differences on the semantic level instead of the syntax level, but it would be much nicer if it could be done their.




  • Re: [[K-user] ] Treating equally, Markus Knecht, 01/01/2018

Archive powered by MHonArc 2.6.24.

Top of Page