This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes General Computing and the fly likes Can you mix left-associative and right-associative operators on the same line in a grammar? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » General Computing
Bookmark "Can you mix left-associative and right-associative operators on the same line in a grammar?" Watch "Can you mix left-associative and right-associative operators on the same line in a grammar?" New topic
Author

Can you mix left-associative and right-associative operators on the same line in a grammar?

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38033
    
  22
I have a grammar to write, which includes the operations for range restriction and subtraction, and domain restriction and subtraction, which I shall call RROp, RSOp, DROp and DSOp. The operators for restriction are little triangles, which have 25b7 and 25c1 as their Unicode numbers, and the subtraction operators are similar with a - superimposed, and I am blowed if I can find them in Unicode at all

Now, I think I can get away with a BNF grammar like this
restrictedSet ::= relationSet | relationSet RROp flatSet | relationSet RSOP flatSet | flatSet DROp relationSet | flatSet DSOp relationSet
Where A and B are each homogeneous sets, and a flat set is one described by [member of]P(A), and a relation set is one described by [member of] P(A x B) where the large P is as near as I can get to "powerset." A flat set is homogeneous, containing only members of one type, no included sets, and the relation set is also homogeneous, containing only ordered pairs (or mappings) of one or two consistent types. That example would work for domain restriction; for range restriction you would swap the A and B around.

Now that means, I think, that the two operators have the same precedence, and DROp associates to the right, and RROp associates to the left.

Has anybody got any idea whether I am correct there, or mistaken? If I am mistaken, I shall change the grammar so DROp associates to the right, and has a higher precedence than RROp, which still associates to the left.

This little bit of code shows the operators, or as near as I can get to it:I can't get the triangles and - superimposed. Maybe somebody else can. The operators show nicely on my Linux shell, but will probably appear as boxes on a DOS/Windows command window.
 
 
subject: Can you mix left-associative and right-associative operators on the same line in a grammar?
 
Similar Threads
Doubt on Self Test Question
Operators qstn
what is the value of 8 | 9 & 10 ^ 11 ?
Summarization required
Does anybody know how to print \u2064 and \u2065?