I am attempting the specification of VS COBOL II using Rascal. There are many constructs in COBOL that have so called permutation phrases which are handled in SDF directly with the permutation phrase syntax <<..>>. I have not been able to find how this is done using Rascal. I am certainly a newbie but I could not find an answer to this.
Asked
Active
Viewed 58 times
0
-
Nice idea. I hope you might share the grammar when you're done! Keep in contact because the priority mechanism in Rascal is different from SDF2, and we are planning to add an automated disambiguation for the dangling constructs. For now it's still best to use the `!>>` mechanism to get a longest match. – Jurgen Vinju Jun 11 '14 at 08:00
1 Answers
0
I don't think it exists like it existed in SDF2. That must be a very old version of SDF2 though, because I remember removing the feature about 8 years ago :-)
Anyway, we could simulate it using a couple of parameterized non-terminals in Rascal like so:
syntax Perm2[&T, &U]
= &T &U
| &U &T
;
syntax Perm3[&T, &U, &V]
= &T &U &V
| &T &V &U
| &U &T &V
| &U &V &T
| &V &T &U
| &V &U &T
;
Would be a nice feature request! or a pull request ;-)

Jurgen Vinju
- 6,393
- 1
- 15
- 26
-
Almost perfect. This together with the permutations() function allowed me to generate these types...up to Perm6 (720 choices). At 7 with over 5000 choices it choked the system :-(. However given my scenario that is just parsing for analysis/transformation it would seem fine to just avoid this altogether and use (choice1 | choice2 | ...choicen)* since I am not trying to flag duplicate usages of a given choice... – user3727131 Jun 11 '14 at 19:15
-
Indeed usually a syntactic over aproximation is good enough in such cases, also they do allow for somewhat nicer error messages :-) you might write an "action" function to trigger after parsing to test for duplicates and throw a meaningfull exception. – Jurgen Vinju Jun 12 '14 at 21:06