项目:xtext-extras
文件:TerminalRuleInterpreter.java
@Override
public Boolean caseCharacterRange(CharacterRange object) {
boolean result = false;
if (object.getLeft().getValue().length() != 1 || object.getRight().getValue().length() != 1)
throw new IllegalStateException("ranges cannot use strings as left or right,that are longer then 1 character.");
OUTER: do {
if (eof())
break OUTER;
char left = object.getLeft().getValue().charat(0);
char right = object.getRight().getValue().charat(0);
char candidate = input.charat(input.getoffset());
if (left <= candidate && right >= candidate) {
input.incOffset();
result = true;
continue OUTER;
}
break OUTER;
} while(GrammarUtil.isMultipleCardinality(object));
return result || GrammarUtil.isOptionalCardinality(object);
}
@Override
public String caseCharacterRange(CharacterRange object) {
if (!Strings.isEmpty(object.getCardinality()))
result.append('(');
doSwitch(object.getLeft());
result.append("..");
doSwitch(object.getRight());
if (!Strings.isEmpty(object.getCardinality())) {
result.append(')');
result.append(Strings.emptyIfNull(object.getCardinality()));
}
return "";
}
项目:xtext-core
文件:XtextSemanticSequencer.java
/**
* Contexts:
* CharacterRange returns CharacterRange
*
* Constraint:
* (left=CharacterRange_CharacterRange_1_0 right=Keyword)
*/
protected void sequence_CharacterRange(ISerializationContext context,CharacterRange semanticObject) {
if (errorAcceptor != null) {
if (transientValues.isValueTransient(semanticObject,XtextPackage.Literals.CHaraCTER_RANGE__LEFT) == ValueTransient.YES)
errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject,XtextPackage.Literals.CHaraCTER_RANGE__LEFT));
if (transientValues.isValueTransient(semanticObject,XtextPackage.Literals.CHaraCTER_RANGE__RIGHT) == ValueTransient.YES)
errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject,XtextPackage.Literals.CHaraCTER_RANGE__RIGHT));
}
SequenceFeeder Feeder = createSequencerFeeder(context,semanticObject);
Feeder.accept(grammaraccess.getCharacterRangeAccess().getCharacterRangeLeftAction_1_0(),semanticObject.getLeft());
Feeder.accept(grammaraccess.getCharacterRangeAccess().getRightKeywordParserRuleCall_1_2_0(),semanticObject.getRight());
Feeder.finish();
}
@Override
public String caseCharacterRange(CharacterRange object) {
if (!Strings.isEmpty(object.getCardinality()))
result.append('(');
doSwitch(object.getLeft());
result.append("..");
doSwitch(object.getRight());
if (!Strings.isEmpty(object.getCardinality())) {
result.append(')');
result.append(Strings.emptyIfNull(object.getCardinality()));
}
return "";
}
项目:xtext-core
文件:XtextSemanticSequencer.java
/**
* Contexts:
* TerminalAlternatives returns CharacterRange
* TerminalAlternatives.Alternatives_1_0 returns CharacterRange
* TerminalGroup returns CharacterRange
* TerminalGroup.Group_1_0 returns CharacterRange
* TerminalToken returns CharacterRange
* TerminalTokenElement returns CharacterRange
* ParenthesizedTerminalElement returns CharacterRange
*
* Constraint:
* (left=CharacterRange_CharacterRange_1_0 right=Keyword (cardinality='?' | cardinality='*' | cardinality='+')*)
*/
protected void sequence_CharacterRange_TerminalToken(ISerializationContext context,CharacterRange semanticObject) {
genericSequencer.createSequence(context,semanticObject);
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。