Reputation: 1971
I need to provide and IDE with a syntax checker and validator for a very simple DSL.
The DSL's interpreter already exists so there is no need for another one. The DSL is suitable for xtext & xtend except
that it allows one to escape to javascript, which I have heard is quite a messy language.
Is XText suitable for this scenario? I have heard that it is extremely difficult to adapt xtext to javascript and I haven't seen an open source xtext javascript project that I could easily link to or extend.
Thanks!
EDIT: The dsl I am working with is the nools rule language. It looks like this:
rule "rule report to user" {
when{
$ctr: Counter $ctr.count % 1000 == 0 {count: $count}
}
then{
console.log("Progressing...");
modify($ctr, function(){this.count = $count + 1;});
}
}
JavaScript appears in the pattern in each statement in the when clause. In this example the pattern is "$ctr.count % 1000 == 0"). There are a limited number of non-javascript substitutions in the patterns e.g. to support a regex operator '=~'.
The entirety of the then clause is JavaScript, except that aliases defined in the when appear as variables in the then clause. In this example $ctr is such an alias.
Upvotes: 0
Views: 87
Reputation: 457
If
then you could create an Xtext grammar that parses the Javascript parts verbatim.
I can't give much more specific advice without seeing the DSL and knowing its use cases.
Upvotes: 1