2009/3/31 john skaller <skal...@users.sourceforge.net> > > On 31/03/2009, at 6:40 PM, Emmanuel Onzon wrote: > > >> Having priorities allows this because you can insert one between >> two others, Hmm. Note this required deleting a priority and adding two >> more if they're not transitive .. hmmm ... >> >> Adding new priorities is not a problem, but deleting them >> is currently not possible (except when going out of scope). >> Could you give me an example where you need to delete >> a priority to insert a new operator in the grammar ? >> >> > > > Ooops, bad language .. I meant "priority relations". >
Deleting priority relations is not possible either. (but adding them is possible) > > Suppose you have + < ^ (addition less than > exponentiation) and you want to add multiplication: > > + < * > * < ^ > > then since Dypgen relations are not transitive you have to *remove* the > relation > > + < ^ > > to build a strict chain. No you don't have to remove it. Making a relations transitive is not mandatory but it is not forbidden either. You can even introduce the transitive closure of the relation for a list of priorities with: Relation [["p1";"p2";"p3";"p4"]] If you remove + < ^ then you lose the precedence of ^ over + and the expression: a ^ b + c become ambiguous. > Felix doesn't need a strict chain usually. However there's > a nasty case which should use one: > > e ^ - 2 > > Say this shouldn't be allowed even though it unambiguously means > > e ^ ( -2 ) > Here you argue that taking the opposite of a number should not take precedence over the exponentiation. Because: > > because > > - e ^ 2 > > actually means > > - (e ^ 2) > > and not > > (-e) ^ 2 > But this doesn't make the difference between the precedence on the left and on the right, which dypgen allows to do: p_plus<p_times<p_exp<p_opp<p_nb expr: | expr(>p_exp) "^" expr(>=p_opp) { } p_exp | "-" expr(>=p_nb) { } p_opp | expr(>=p_times) "*" expr(>p_times) { } p_times | expr(>=p_plus) "+" expr(>p_plus) { } p_plus | number { } p_nb > Felix actually allows e ^ -2, but the grammar is quite confusing, it allows > this too: > > e ^ sin x > > which could mean > > (e ^ sin) x > > if you didn't know better. I've been caught by this myself. Anyhow, an > example where > one wants to *use* the non-transitivity, which requires removing a > previously > existing relation (but not the priority itself). > why? and between which priorities?
------------------------------------------------------------------------------
_______________________________________________ Felix-language mailing list Felix-language@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/felix-language