use of org.drools.compiler.lang.api.DescrBuilder in project drools by kiegroup.
the class DRL6StrictParser method breakingNamedConsequence.
/**
* breakingNamedConsequence := BREAK LEFT_SQUARE ID RIGHT_SQUARE
*/
private BaseDescr breakingNamedConsequence(CEDescrBuilder<?, ?> ce, NamedConsequenceDescrBuilder<?> namedConsequence) throws RecognitionException {
if (namedConsequence == null) {
namedConsequence = helper.start((DescrBuilder<?, ?>) ce, NamedConsequenceDescrBuilder.class, null);
}
try {
match(input, DRL6Lexer.ID, DroolsSoftKeywords.BREAK, null, DroolsEditorType.KEYWORD);
if (state.failed)
return null;
match(input, DRL6Lexer.LEFT_SQUARE, null, null, DroolsEditorType.SYMBOL);
if (state.failed)
return null;
Token label = match(input, DRL6Lexer.ID, null, null, DroolsEditorType.SYMBOL);
if (state.failed)
return null;
namedConsequence.name(label.getText());
namedConsequence.breaking(true);
match(input, DRL6Lexer.RIGHT_SQUARE, null, null, DroolsEditorType.SYMBOL);
if (state.failed)
return null;
} finally {
helper.end(NamedConsequenceDescrBuilder.class, namedConsequence);
}
return namedConsequence.getDescr();
}
use of org.drools.compiler.lang.api.DescrBuilder in project drools by kiegroup.
the class DRL6StrictParser method stringListAttribute.
/**
* stringListAttribute := attributeKey STRING (COMMA STRING)*
* @param key
* @throws org.antlr.runtime.RecognitionException
*/
private AttributeDescr stringListAttribute(AttributeSupportBuilder<?> as, String[] key) throws RecognitionException {
AttributeDescrBuilder<?> attribute = null;
try {
StringBuilder builder = new StringBuilder();
for (String k : key) {
if ("-".equals(k)) {
match(input, DRL6Lexer.MINUS, k, null, // part of the keyword
DroolsEditorType.KEYWORD);
if (state.failed)
return null;
} else {
match(input, DRL6Lexer.ID, k, null, DroolsEditorType.KEYWORD);
if (state.failed)
return null;
}
builder.append(k);
}
if (state.backtracking == 0) {
attribute = helper.start((DescrBuilder<?, ?>) as, AttributeDescrBuilder.class, builder.toString());
}
builder = new StringBuilder();
builder.append("[ ");
Token value = match(input, DRL6Lexer.STRING, null, null, DroolsEditorType.STRING_CONST);
if (state.failed)
return null;
builder.append(value.getText());
while (input.LA(1) == DRL6Lexer.COMMA) {
match(input, DRL6Lexer.COMMA, null, null, DroolsEditorType.SYMBOL);
if (state.failed)
return null;
builder.append(", ");
value = match(input, DRL6Lexer.STRING, null, null, DroolsEditorType.STRING_CONST);
if (state.failed)
return null;
builder.append(value.getText());
}
builder.append(" ]");
if (state.backtracking == 0) {
attribute.value(builder.toString());
attribute.type(AttributeDescr.Type.LIST);
}
} finally {
if (attribute != null) {
helper.end(AttributeDescrBuilder.class, attribute);
}
}
return attribute != null ? attribute.getDescr() : null;
}
use of org.drools.compiler.lang.api.DescrBuilder in project drools by kiegroup.
the class DRL5Parser method stringListAttribute.
/**
* stringListAttribute := attributeKey STRING (COMMA STRING)*
* @param key
* @throws RecognitionException
*/
private AttributeDescr stringListAttribute(AttributeSupportBuilder<?> as, String[] key) throws RecognitionException {
AttributeDescrBuilder<?> attribute = null;
try {
StringBuilder builder = new StringBuilder();
for (String k : key) {
if ("-".equals(k)) {
match(input, DRL5Lexer.MINUS, k, null, // part of the keyword
DroolsEditorType.KEYWORD);
if (state.failed)
return null;
} else {
match(input, DRL5Lexer.ID, k, null, DroolsEditorType.KEYWORD);
if (state.failed)
return null;
}
builder.append(k);
}
if (state.backtracking == 0) {
attribute = helper.start((DescrBuilder<?, ?>) as, AttributeDescrBuilder.class, builder.toString());
}
builder = new StringBuilder();
builder.append("[ ");
Token value = match(input, DRL5Lexer.STRING, null, null, DroolsEditorType.STRING_CONST);
if (state.failed)
return null;
builder.append(value.getText());
while (input.LA(1) == DRL5Lexer.COMMA) {
match(input, DRL5Lexer.COMMA, null, null, DroolsEditorType.SYMBOL);
if (state.failed)
return null;
builder.append(", ");
value = match(input, DRL5Lexer.STRING, null, null, DroolsEditorType.STRING_CONST);
if (state.failed)
return null;
builder.append(value.getText());
}
builder.append(" ]");
if (state.backtracking == 0) {
attribute.value(builder.toString());
attribute.type(AttributeDescr.Type.LIST);
}
} finally {
if (attribute != null) {
helper.end(AttributeDescrBuilder.class, attribute);
}
}
return attribute != null ? attribute.getDescr() : null;
}
use of org.drools.compiler.lang.api.DescrBuilder in project drools by kiegroup.
the class DRL5Parser method booleanAttribute.
/**
* booleanAttribute := attributeKey (BOOLEAN)?
* @param key
* @throws RecognitionException
*/
private AttributeDescr booleanAttribute(AttributeSupportBuilder<?> as, String[] key) throws RecognitionException {
AttributeDescrBuilder<?> attribute = null;
try {
StringBuilder builder = new StringBuilder();
for (String k : key) {
if ("-".equals(k)) {
match(input, DRL5Lexer.MINUS, k, null, // part of the keyword
DroolsEditorType.KEYWORD);
if (state.failed)
return null;
} else {
match(input, DRL5Lexer.ID, k, null, DroolsEditorType.KEYWORD);
if (state.failed)
return null;
}
builder.append(k);
}
if (state.backtracking == 0) {
attribute = helper.start((DescrBuilder<?, ?>) as, AttributeDescrBuilder.class, builder.toString());
}
String value = "true";
if (input.LA(1) == DRL5Lexer.BOOL) {
Token bool = match(input, DRL5Lexer.BOOL, null, null, DroolsEditorType.KEYWORD);
if (state.failed)
return null;
value = bool.getText();
}
if (state.backtracking == 0) {
attribute.value(value);
attribute.type(AttributeDescr.Type.BOOLEAN);
}
} finally {
if (attribute != null) {
helper.end(AttributeDescrBuilder.class, attribute);
}
}
return attribute != null ? attribute.getDescr() : null;
}
use of org.drools.compiler.lang.api.DescrBuilder in project drools by kiegroup.
the class DRL6Parser method stringAttribute.
/**
* stringAttribute := attributeKey STRING
* @param key
* @throws org.antlr.runtime.RecognitionException
*/
private AttributeDescr stringAttribute(AttributeSupportBuilder<?> as, String[] key) throws RecognitionException {
AttributeDescrBuilder<?> attribute = null;
try {
StringBuilder builder = new StringBuilder();
for (String k : key) {
if ("-".equals(k)) {
match(input, DRL6Lexer.MINUS, k, null, // part of the keyword
DroolsEditorType.KEYWORD);
if (state.failed)
return null;
} else {
match(input, DRL6Lexer.ID, k, null, DroolsEditorType.KEYWORD);
if (state.failed)
return null;
}
builder.append(k);
}
if (state.backtracking == 0) {
attribute = helper.start((DescrBuilder<?, ?>) as, AttributeDescrBuilder.class, builder.toString());
}
Token value = match(input, DRL6Lexer.STRING, null, null, DroolsEditorType.STRING_CONST);
if (state.failed)
return null;
if (state.backtracking == 0) {
attribute.value(StringUtils.unescapeJava(safeStripStringDelimiters(value.getText())));
attribute.type(AttributeDescr.Type.STRING);
}
} finally {
if (attribute != null) {
helper.end(AttributeDescrBuilder.class, attribute);
}
}
return attribute != null ? attribute.getDescr() : null;
}
Aggregations