eclipse / xsemantics

Xsemantics is a DSL (implemented in Xtext itself) for writing type systems, reduction rules, interpreters (and in general relation rules) for languages implemented in Xtext. It then generates Java code that can be used in your language implemented in Xtext for scoping and validation (it can also generate a validator in Java).
Eclipse Public License 1.0
32 stars 19 forks source link

Use boolean judgments in rules #2

Closed JensN4 closed 10 years ago

JensN4 commented 10 years ago

At the moment, it is not possible to use a boolean judgment (relation) inside another rule. E.g., given

judgments { func |- EObject obj : output EObject
rel |– EObject left <: EObject right }

if is not possible to write a rule like

rule funcX G |- X obj: output EObject out from { if ( G |- X <: X.feature ) { ... } else { ... } }

Well, in the example one might rephrase the statement and use an "or" expression. But in other cases that's not possible.

LorenzoBettini commented 10 years ago

It is now possible to use rule invocations corresponding to predicate judgments, i.e., judgments without output parameters, in contexts where a boolean expression is expected, e.g., inside lambdas and as expressions of if:

mytypes.exists[ G |- it <: otherType ]

if ( { G |- it <: otherType } ) { ... }

Note that, since a rule invocation is NOT an expression, when used in an if, needs to be put inside a block.

Fixed in https://github.com/LorenzoBettini/xsemantics/commit/5f5e252eeeb52e438f4affeeec46e904e949b381