Search in sources :

Example 6 with NamedConsequenceDescrBuilder

use of org.drools.compiler.lang.api.NamedConsequenceDescrBuilder in project drools by kiegroup.

the class DRL5Parser method namedConsequence.

/**
 * namedConsequence := DO LEFT_SQUARE ID RIGHT_SQUARE BREAK?
 */
private BaseDescr namedConsequence(CEDescrBuilder<?, ?> ce, NamedConsequenceDescrBuilder<?> namedConsequence) throws RecognitionException {
    if (namedConsequence == null) {
        namedConsequence = helper.start((DescrBuilder<?, ?>) ce, NamedConsequenceDescrBuilder.class, null);
    }
    try {
        match(input, DRL5Lexer.ID, DroolsSoftKeywords.DO, null, DroolsEditorType.KEYWORD);
        if (state.failed)
            return null;
        match(input, DRL5Lexer.LEFT_SQUARE, null, null, DroolsEditorType.SYMBOL);
        if (state.failed)
            return null;
        Token label = match(input, DRL5Lexer.ID, null, null, DroolsEditorType.SYMBOL);
        if (state.failed)
            return null;
        namedConsequence.name(label.getText());
        match(input, DRL5Lexer.RIGHT_SQUARE, null, null, DroolsEditorType.SYMBOL);
        if (state.failed)
            return null;
    } finally {
        helper.end(NamedConsequenceDescrBuilder.class, namedConsequence);
    }
    return namedConsequence.getDescr();
}
Also used : Token(org.antlr.runtime.Token) CommonToken(org.antlr.runtime.CommonToken) DescrBuilder(org.drools.compiler.lang.api.DescrBuilder) AccumulateDescrBuilder(org.drools.compiler.lang.api.AccumulateDescrBuilder) EnumDeclarationDescrBuilder(org.drools.compiler.lang.api.EnumDeclarationDescrBuilder) PatternContainerDescrBuilder(org.drools.compiler.lang.api.PatternContainerDescrBuilder) WindowDeclarationDescrBuilder(org.drools.compiler.lang.api.WindowDeclarationDescrBuilder) ForallDescrBuilder(org.drools.compiler.lang.api.ForallDescrBuilder) TypeDeclarationDescrBuilder(org.drools.compiler.lang.api.TypeDeclarationDescrBuilder) PackageDescrBuilder(org.drools.compiler.lang.api.PackageDescrBuilder) CEDescrBuilder(org.drools.compiler.lang.api.CEDescrBuilder) DeclareDescrBuilder(org.drools.compiler.lang.api.DeclareDescrBuilder) FunctionDescrBuilder(org.drools.compiler.lang.api.FunctionDescrBuilder) RuleDescrBuilder(org.drools.compiler.lang.api.RuleDescrBuilder) EntryPointDeclarationDescrBuilder(org.drools.compiler.lang.api.EntryPointDeclarationDescrBuilder) EnumLiteralDescrBuilder(org.drools.compiler.lang.api.EnumLiteralDescrBuilder) QueryDescrBuilder(org.drools.compiler.lang.api.QueryDescrBuilder) AnnotatedDescrBuilder(org.drools.compiler.lang.api.AnnotatedDescrBuilder) PatternDescrBuilder(org.drools.compiler.lang.api.PatternDescrBuilder) AnnotationDescrBuilder(org.drools.compiler.lang.api.AnnotationDescrBuilder) ImportDescrBuilder(org.drools.compiler.lang.api.ImportDescrBuilder) CollectDescrBuilder(org.drools.compiler.lang.api.CollectDescrBuilder) AttributeDescrBuilder(org.drools.compiler.lang.api.AttributeDescrBuilder) EvalDescrBuilder(org.drools.compiler.lang.api.EvalDescrBuilder) ConditionalBranchDescrBuilder(org.drools.compiler.lang.api.ConditionalBranchDescrBuilder) NamedConsequenceDescrBuilder(org.drools.compiler.lang.api.NamedConsequenceDescrBuilder) FieldDescrBuilder(org.drools.compiler.lang.api.FieldDescrBuilder) BehaviorDescrBuilder(org.drools.compiler.lang.api.BehaviorDescrBuilder) GlobalDescrBuilder(org.drools.compiler.lang.api.GlobalDescrBuilder) NamedConsequenceDescrBuilder(org.drools.compiler.lang.api.NamedConsequenceDescrBuilder)

Example 7 with NamedConsequenceDescrBuilder

use of org.drools.compiler.lang.api.NamedConsequenceDescrBuilder in project drools by kiegroup.

the class DRL5Parser 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, DRL5Lexer.ID, DroolsSoftKeywords.BREAK, null, DroolsEditorType.KEYWORD);
        if (state.failed)
            return null;
        match(input, DRL5Lexer.LEFT_SQUARE, null, null, DroolsEditorType.SYMBOL);
        if (state.failed)
            return null;
        Token label = match(input, DRL5Lexer.ID, null, null, DroolsEditorType.SYMBOL);
        if (state.failed)
            return null;
        namedConsequence.name(label.getText());
        namedConsequence.breaking(true);
        match(input, DRL5Lexer.RIGHT_SQUARE, null, null, DroolsEditorType.SYMBOL);
        if (state.failed)
            return null;
    } finally {
        helper.end(NamedConsequenceDescrBuilder.class, namedConsequence);
    }
    return namedConsequence.getDescr();
}
Also used : Token(org.antlr.runtime.Token) CommonToken(org.antlr.runtime.CommonToken) DescrBuilder(org.drools.compiler.lang.api.DescrBuilder) AccumulateDescrBuilder(org.drools.compiler.lang.api.AccumulateDescrBuilder) EnumDeclarationDescrBuilder(org.drools.compiler.lang.api.EnumDeclarationDescrBuilder) PatternContainerDescrBuilder(org.drools.compiler.lang.api.PatternContainerDescrBuilder) WindowDeclarationDescrBuilder(org.drools.compiler.lang.api.WindowDeclarationDescrBuilder) ForallDescrBuilder(org.drools.compiler.lang.api.ForallDescrBuilder) TypeDeclarationDescrBuilder(org.drools.compiler.lang.api.TypeDeclarationDescrBuilder) PackageDescrBuilder(org.drools.compiler.lang.api.PackageDescrBuilder) CEDescrBuilder(org.drools.compiler.lang.api.CEDescrBuilder) DeclareDescrBuilder(org.drools.compiler.lang.api.DeclareDescrBuilder) FunctionDescrBuilder(org.drools.compiler.lang.api.FunctionDescrBuilder) RuleDescrBuilder(org.drools.compiler.lang.api.RuleDescrBuilder) EntryPointDeclarationDescrBuilder(org.drools.compiler.lang.api.EntryPointDeclarationDescrBuilder) EnumLiteralDescrBuilder(org.drools.compiler.lang.api.EnumLiteralDescrBuilder) QueryDescrBuilder(org.drools.compiler.lang.api.QueryDescrBuilder) AnnotatedDescrBuilder(org.drools.compiler.lang.api.AnnotatedDescrBuilder) PatternDescrBuilder(org.drools.compiler.lang.api.PatternDescrBuilder) AnnotationDescrBuilder(org.drools.compiler.lang.api.AnnotationDescrBuilder) ImportDescrBuilder(org.drools.compiler.lang.api.ImportDescrBuilder) CollectDescrBuilder(org.drools.compiler.lang.api.CollectDescrBuilder) AttributeDescrBuilder(org.drools.compiler.lang.api.AttributeDescrBuilder) EvalDescrBuilder(org.drools.compiler.lang.api.EvalDescrBuilder) ConditionalBranchDescrBuilder(org.drools.compiler.lang.api.ConditionalBranchDescrBuilder) NamedConsequenceDescrBuilder(org.drools.compiler.lang.api.NamedConsequenceDescrBuilder) FieldDescrBuilder(org.drools.compiler.lang.api.FieldDescrBuilder) BehaviorDescrBuilder(org.drools.compiler.lang.api.BehaviorDescrBuilder) GlobalDescrBuilder(org.drools.compiler.lang.api.GlobalDescrBuilder) NamedConsequenceDescrBuilder(org.drools.compiler.lang.api.NamedConsequenceDescrBuilder)

Aggregations

AccumulateDescrBuilder (org.drools.compiler.lang.api.AccumulateDescrBuilder)7 AttributeDescrBuilder (org.drools.compiler.lang.api.AttributeDescrBuilder)7 CEDescrBuilder (org.drools.compiler.lang.api.CEDescrBuilder)7 DeclareDescrBuilder (org.drools.compiler.lang.api.DeclareDescrBuilder)7 EntryPointDeclarationDescrBuilder (org.drools.compiler.lang.api.EntryPointDeclarationDescrBuilder)7 EnumDeclarationDescrBuilder (org.drools.compiler.lang.api.EnumDeclarationDescrBuilder)7 EnumLiteralDescrBuilder (org.drools.compiler.lang.api.EnumLiteralDescrBuilder)7 FieldDescrBuilder (org.drools.compiler.lang.api.FieldDescrBuilder)7 ForallDescrBuilder (org.drools.compiler.lang.api.ForallDescrBuilder)7 FunctionDescrBuilder (org.drools.compiler.lang.api.FunctionDescrBuilder)7 GlobalDescrBuilder (org.drools.compiler.lang.api.GlobalDescrBuilder)7 ImportDescrBuilder (org.drools.compiler.lang.api.ImportDescrBuilder)7 NamedConsequenceDescrBuilder (org.drools.compiler.lang.api.NamedConsequenceDescrBuilder)7 PackageDescrBuilder (org.drools.compiler.lang.api.PackageDescrBuilder)7 PatternDescrBuilder (org.drools.compiler.lang.api.PatternDescrBuilder)7 QueryDescrBuilder (org.drools.compiler.lang.api.QueryDescrBuilder)7 RuleDescrBuilder (org.drools.compiler.lang.api.RuleDescrBuilder)7 TypeDeclarationDescrBuilder (org.drools.compiler.lang.api.TypeDeclarationDescrBuilder)7 WindowDeclarationDescrBuilder (org.drools.compiler.lang.api.WindowDeclarationDescrBuilder)7 CommonToken (org.antlr.runtime.CommonToken)6