|
| From: | anonymous |
| Subject: | [Octave-bug-tracker] [bug #54698] Precedence of call/indexing operator over transpose operator |
| Date: | Tue, 25 Sep 2018 09:12:57 -0400 (EDT) |
| User-agent: | Mozilla/5.0 (Windows NT 5.1; rv:51.0) Gecko/20100101 Firefox/51.0 |
Follow-up Comment #18, bug #54698 (project octave):
I used The package CafeOBJ <https://cafeobj.org/> * for the verification of
the precedence rules. It allows to define postfix operators and to assign
different levels of precedence to them.
I defined two postfix operators @ and ' that @ has higher precedence:
module PREC-TEST {
[S]
op _@ : S -> S { prec: 31 }
op _' : S -> S { prec: 33 }
var X : S
}
Then I used its parser to parse different expressions X''' and X@@@ and X@' :
open PREC-TEST .
parse X ' ' ' .
parse X @ @ @ .
parse X @ ' .
That produced the following results:
(((X ') ') '):S
(((X @) @) @):S
((X @) '):S
But parsing X'@ generated a syntax error:
parse X ' @ .
[Error]: no successful parse
(parsed:[ (X ') ], rest:[ (@) ]):SyntaxErr
It means that:
- A postfix operator cannot be followed by a postfix operator of lower
precedence.
- The expression A'(X) cannot be reordered to A(X)'
- Consecutive number of postfix operators that have different levels of
precedence don't necessarily work from inside to outside.
What can be done?
1. Generate syntax error and rewrite A'(X) as (A')(X) that is not acceptable.
2. Introducing three compound operators as explained in comment13
<https://savannah.gnu.org/bugs/index.php?54698#comment13>.
* CafeOBJ is a language for writing formal (i.e. mathematical) specifications
of models for wide varieties of software and systems, and verifying properties
of them.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?54698>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
| [Prev in Thread] | Current Thread | [Next in Thread] |