<commit_before>grammar FML;

options {
    output=AST;
    ASTLabelType=CommonTree; // type of $stat.tree ref etc...
}

@header {
  package org.deegree.feature.persistence.mapping.antlr;
  import java.util.Collections;
  import org.deegree.sqldialect.filter.MappingExpression;
  import org.deegree.sqldialect.filter.DBField;
  import org.deegree.feature.persistence.sql.expressions.Function;
  import org.deegree.feature.persistence.sql.expressions.StringConst;
}

@lexer::header {
  package org.deegree.feature.persistence.mapping.antlr;
}

/*------------------------------------------------------------------
 * PARSER RULES
 *------------------------------------------------------------------*/

expr
    :    mappingExpr;

mappingExpr returns [MappingExpression value]
    :    dbField {$value=$dbField.value;}
    |    function {$value=$function.value;}
    |    stringConst {$value=$stringConst.value;}
    ;
catch [RecognitionException re] {
    throw re;
}

stringConst returns [StringConst value]
    :   Text  {$value=new StringConst($Text.text.substring(1,$Text.text.length()-1));}
    ;

function returns [Function value]
    :    Identifier {$value=new Function($Identifier.text);}
    '(' ((ma=mappingExpr{$value.addArg($ma.value);}) (',' ma2=mappingExpr{$value.addArg($ma2.value);})*)? ')'
    ;
catch [RecognitionException re] {
    throw re;
}

dbField returns [DBField value]
    :    i1=Identifier {$value=new DBField ($i1.text);}
    |    i1=Identifier '.' i2=Identifier {$value=new DBField ($i1.text,$i2.text);}
    |    i1=Identifier '.' i2=Identifier '.' i3=Identifier {$value=new DBField ($i1.text,$i2.text,$i3.text);}
    ;
catch [RecognitionException re] {
    throw re;
}
   
/*------------------------------------------------------------------
 * LEXER RULES
 *------------------------------------------------------------------*/   
   
Identifier
    :    ('a'..'z' | 'A'..'Z' | '0'..'9' | '_' | '-' | '"' )+
    ;<commit_msg>#4178 - allow unicde characters as identifier in feature store configuration<commit_after>grammar FML;

options {
    output=AST;
    ASTLabelType=CommonTree; // type of $stat.tree ref etc...
}

@header {
  package org.deegree.feature.persistence.mapping.antlr;
  import java.util.Collections;
  import org.deegree.sqldialect.filter.MappingExpression;
  import org.deegree.sqldialect.filter.DBField;
  import org.deegree.feature.persistence.sql.expressions.Function;
  import org.deegree.feature.persistence.sql.expressions.StringConst;
}

@lexer::header {
  package org.deegree.feature.persistence.mapping.antlr;
}

/*------------------------------------------------------------------
 * PARSER RULES
 *------------------------------------------------------------------*/

expr
    :    mappingExpr;

mappingExpr returns [MappingExpression value]
    :    dbField {$value=$dbField.value;}
    |    function {$value=$function.value;}
    |    stringConst {$value=$stringConst.value;}
    ;
catch [RecognitionException re] {
    throw re;
}

stringConst returns [StringConst value]
    :   Text  {$value=new StringConst($Text.text.substring(1,$Text.text.length()-1));}
    ;

function returns [Function value]
    :    Identifier {$value=new Function($Identifier.text);}
    '(' ((ma=mappingExpr{$value.addArg($ma.value);}) (',' ma2=mappingExpr{$value.addArg($ma2.value);})*)? ')'
    ;
catch [RecognitionException re] {
    throw re;
}

dbField returns [DBField value]
    :    i1=Identifier {$value=new DBField ($i1.text);}
    |    i1=Identifier '.' i2=Identifier {$value=new DBField ($i1.text,$i2.text);}
    |    i1=Identifier '.' i2=Identifier '.' i3=Identifier {$value=new DBField ($i1.text,$i2.text,$i3.text);}
    ;
catch [RecognitionException re] {
    throw re;
}
   
/*------------------------------------------------------------------
 * LEXER RULES
 *------------------------------------------------------------------*/   
   
Identifier
    :    ('a'..'z' | 'A'..'Z' | '0'..'9' | '_' | '-' | '"' | '\u0080'..'\ufffe' )+
    ;
{'fraction_non_alphanumeric': 0.2781672508763145, 'fraction_numerical': 0.011016524787180772, 'mean_word_length': 2.12109375, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1096156', 'n_tokens_mistral': 1234, 'n_tokens_neox': 1227, 'n_words': 202}