I'm defining a grammar for an existing language.
For several reasons (one is to limit my grammar to my interest in the input), I want to ignore part of the input, and assign it as a string to a property wthin a rule, e.g.:
Example:
trial TestSection {
// here's a lot of stuff that I don't need
Type field <field properties>;
OtherType otherfield;
YetAnotherType yetanotherfield <default=[22/#7 + @3]>;
}
should result into an EObject like:
TrialDeclaration {
name = "TestSection";
trialContent = "// here's a lot.... @3]>;"
}
Using a terminal rule like
terminal ignoreText : '{' -> '}';
is not working while it will also apply this terminal rule to other parts that should be parsed, like class XX { ...};
So I need a solution that limits to the context of the rule.
I'm trying to define rules in a pattern like
TrialDeclaration:
'trial' name = ID '{'
tryContent=InputAsText
'}';
but all my attempts to define 'InputAsText' do not have the desired result. It feels like I'm overlooking something trivial...
Is there a general applicable solution to do this kind of 'partial' syntax parsing?
I'd prefer to have the input in a property, so it could later perhaps be fed into another language interpreter.