org.eclipse.xtext.CharacterRange Java Examples

The following examples show how to use org.eclipse.xtext.CharacterRange. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TerminalRuleInterpreter.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
@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);
}
 
Example #2
Source File: TerminalRuleToLexerBody.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@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 "";
}
 
Example #3
Source File: XtextSemanticSequencer.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * 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();
}
 
Example #4
Source File: TerminalRuleToLexerBody.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@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 "";
}
 
Example #5
Source File: XtextLabelProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
String text(CharacterRange object) {
	return object.getLeft().getValue() + " .. " + object.getRight().getValue();
}
 
Example #6
Source File: SLCommentPrefixCalculator.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public Boolean caseCharacterRange(CharacterRange object) {
	return false;
}
 
Example #7
Source File: XtextSemanticSequencer.java    From xtext-core with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * 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);
}