congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
FEELParser
Code IndexAdd Tabnine to your IDE (free)

How to use
FEELParser
in
org.kie.dmn.feel.parser.feel11

Best Java code snippets using org.kie.dmn.feel.parser.feel11.FEELParser (Showing top 14 results out of 315)

origin: org.kie/kie-dmn-feel

public static boolean isVariableNameValid( String source ) {
  return checkVariableName( source ).isEmpty();
}
origin: org.kie/kie-dmn-feel

/**
 * Either namePart is a string of digits, or it must be a valid name itself 
 */
public static boolean isVariableNamePartValid( String namePart, Scope scope ) {
  if ( DIGITS_PATTERN.matcher(namePart).matches() ) {
    return true;
  }
  if ( REUSABLE_KEYWORDS.contains(namePart) ) {
    return scope.followUp(namePart, true);
  }
  return isVariableNameValid(namePart);
}
origin: org.kie/kie-dmn-feel

public boolean followUp(Token t, boolean isPredict) {
  boolean dynamicResolutionResult = isDynamicResolution() && FEELParser.isVariableNamePartValid( t.getText(), currentScope );
  boolean follow = dynamicResolutionResult || this.currentScope.followUp( t.getText(), isPredict );
  // in case isPredict == false, will need to followUp in the currentScope, so that the TokenTree currentNode is updated as per expectations,
  // this is because the `follow` variable above, in the case of short-circuited on `dynamicResolutionResult`,
  // would skip performing any necessary update in the second part of the || predicate
  if (dynamicResolutionResult && !isPredict) {
    this.currentScope.followUp(t.getText(), isPredict);
  }
  return follow;
}
origin: org.kie/kie-dmn-feel

@Test
public void testVariableNameCantStartWithKeyword() {
  String var = "for keyword is an invalid start for a variable name";
  assertThat( FEELParser.isVariableNameValid( var ), is( false ) );
  assertThat( FEELParser.checkVariableName( var ).get( 0 ).getMessage(), is( Msg.createMessage(Msg.INVALID_VARIABLE_NAME_START, "keyword", "for") ) );
}
origin: org.kie/kie-dmn-feel

private BaseNode parse(String input, Map<String, Type> inputTypes) {
  FEEL_1_1Parser parser = FEELParser.parse(null, input, inputTypes, Collections.emptyMap(), Collections.emptyList(), Collections.emptyList());
  ParseTree tree = parser.expression();
  ASTBuilderVisitor v = new ASTBuilderVisitor(inputTypes);
  BaseNode expr = v.visit( tree );
  return expr;
}
origin: org.kie/kie-dmn-feel

public static FEEL_1_1Parser parse(FEELEventListenersManager eventsManager, String source, Map<String, Type> inputVariableTypes, Map<String, Object> inputVariables, Collection<FEELFunction> additionalFunctions, List<FEELProfile> profiles) {
  ANTLRInputStream input = new ANTLRInputStream(source);
  FEEL_1_1Lexer lexer = new FEEL_1_1Lexer( input );
  CommonTokenStream tokens = new CommonTokenStream( lexer );
  FEEL_1_1Parser parser = new FEEL_1_1Parser( tokens );
  ParserHelper parserHelper = new ParserHelper(eventsManager);
  additionalFunctions.forEach(f -> parserHelper.getSymbolTable().getBuiltInScope().define(f.getSymbol()));
  profiles.stream().filter(FEELv12Profile.class::isInstance).forEach(dc -> {
    parserHelper.setFeatDMN12EnhancedForLoopEnabled(true);
    parserHelper.setFeatDMN12weekday(true);
  });
  parser.setHelper(parserHelper);
  parser.setErrorHandler( new FEELErrorHandler() );
  parser.removeErrorListeners(); // removes the error listener that prints to the console
  parser.addErrorListener( new FEELParserErrorListener( eventsManager ) );
  // pre-loads the parser with symbols
  defineVariables( inputVariableTypes, inputVariables, parser );
  
  return parser;
}

origin: org.kie/kie-dmn-feel

@Test
public void testVariableNameWithInvalidCharacterPercent() {
  String var = "?_873./-'%+*valid";
  assertThat( FEELParser.isVariableNameValid( var ), is( false ) );
  assertThat( FEELParser.checkVariableName( var ).get( 0 ).getMessage(), is( Msg.createMessage(Msg.INVALID_VARIABLE_NAME, "character", "%") ) );
}
origin: org.kie/kie-dmn-feel

private CompiledFEELExpression parse(String input, Map<String, Type> inputTypes) {
  FEEL_1_1Parser parser = FEELParser.parse(null, input, inputTypes, Collections.emptyMap(), Collections.emptyList(), Collections.emptyList());
  ParseTree tree = parser.compilation_unit();
  ASTBuilderVisitor v = new ASTBuilderVisitor(inputTypes);
  BaseNode node = v.visit(tree);
  DirectCompilerResult directResult = node.accept(new ASTCompilerVisitor());
  
  Expression expr = directResult.getExpression();
  CompiledFEELExpression cu = new CompilerBytecodeLoader().makeFromJPExpression(input, expr, directResult.getFieldDeclarations());
  return cu;
}

origin: org.kie/kie-dmn-feel

private static void defineVariables(Map<String, Type> inputVariableTypes, Map<String, Object> inputVariables, FEEL_1_1Parser parser) {
  inputVariableTypes.forEach( (name, type) -> {
    parser.getHelper().defineVariable( name, type );
    if (type.getName() != null) {
      parser.getHelper().getSymbolTable().getGlobalScope().define(new BuiltInTypeSymbol(type.getName(), type));
    }
  } );
  
  inputVariables.forEach( (name, value) -> {
    parser.getHelper().defineVariable( name );
    if( value instanceof Map ) {
      try {
        parser.getHelper().pushName( name );
        parser.getHelper().pushScope();
        defineVariables( Collections.EMPTY_MAP, (Map<String, Object>) value, parser );
      } finally {
        parser.getHelper().popScope();
        parser.getHelper().popName();
      }
    }
  } );
}
origin: org.kie/kie-dmn-feel

@Test
public void testVariableNameInvalidStartCharacter() {
  String var = "5variable can't start with a number";
  assertThat( FEELParser.isVariableNameValid( var ), is( false ) );
  assertThat( FEELParser.checkVariableName( var ).get( 0 ).getMessage(), is( Msg.createMessage(Msg.INVALID_VARIABLE_NAME_START, "character", "5") ) );
}
origin: org.kie/kie-dmn-feel

ProcessedFEELUnit(String expression,
         CompilerContext ctx,
         List<FEELProfile> profiles) {
  this.expression = expression;
  this.packageName = generateRandomPackage();
  FEELEventListenersManager eventsManager =
      new FEELEventListenersManager();
  eventsManager.addListeners(ctx.getListeners());
  eventsManager.addListener(errorListener);
  this.parser = FEELParser.parse(
      eventsManager,
      expression,
      ctx.getInputVariableTypes(),
      ctx.getInputVariables(),
      ctx.getFEELFunctions(),
      profiles);
}
origin: org.kie/kie-dmn-feel

@Test
public void testVariableNameWithValidCharacters() {
  String var = "?_873./-'+*valid";
  assertThat( FEELParser.isVariableNameValid( var ), is( true ) );
}
origin: org.kie/kie-dmn-feel

private CompiledFEELUnaryTests parse(String input, Map<String, Type> inputTypes, FEELEventListenersManager mgr, CompiledFEELSupport.SyntaxErrorListener listener) {
  FEEL_1_1Parser parser = FEELParser.parse(mgr, input, inputTypes, Collections.emptyMap(), Collections.emptyList(), Collections.emptyList());
  ParseTree tree = parser.unaryTestsRoot();
  DirectCompilerResult directResult;
  if (listener.isError()) {
    directResult = CompiledFEELSupport.compiledErrorUnaryTest(listener.event().getMessage());
  } else {
    ASTBuilderVisitor v = new ASTBuilderVisitor(inputTypes);
    BaseNode node = v.visit(tree);
    BaseNode transformed = node.accept(new ASTUnaryTestTransform()).node();
    directResult = transformed.accept(new ASTCompilerVisitor());
  }
  Expression expr = directResult.getExpression();
  CompiledFEELUnaryTests cu = new CompilerBytecodeLoader().makeFromJPUnaryTestsExpression(input, expr, directResult.getFieldDeclarations());
  return cu;
}

origin: org.kie/kie-dmn-feel

@Test
public void testVariableName() {
  String var = "valid variable name";
  assertThat( FEELParser.isVariableNameValid( var ), is( true ) );
}
org.kie.dmn.feel.parser.feel11FEELParser

Most used methods

  • checkVariableName
  • isVariableNameValid
  • parse
  • defineVariables
  • isVariableNamePartValid
    Either namePart is a string of digits, or it must be a valid name itself

Popular in Java

  • Running tasks concurrently on multiple threads
  • scheduleAtFixedRate (ScheduledExecutorService)
  • getSupportFragmentManager (FragmentActivity)
  • requestLocationUpdates (LocationManager)
  • OutputStream (java.io)
    A writable sink for bytes.Most clients will use output streams that write data to the file system (
  • Permission (java.security)
    Legacy security code; do not use.
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • Cipher (javax.crypto)
    This class provides access to implementations of cryptographic ciphers for encryption and decryption
  • BoxLayout (javax.swing)
  • PhpStorm for WordPress
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now