old_contents:
grammar WorkflowCatalogQueryLanguage;

@header {
   package org.ow2.proactive.workflow_catalog.rest.query;
}

clause: ATTRIBUTE OPERATOR VALUE ;
clauses: clause ( CONJUNCTION clause )* ;
statement: '(' clauses ')' | clauses ;

ATTRIBUTE: ([a-z] | [A-Z])+ ([_.]+ ([a-z] | [A-Z] | [0-9])*)* ;
CONJUNCTION: 'AND' | 'OR' ;
OPERATOR: '!=' | '=' ;
VALUE: '"' (~[\t\n])* '"' ;

WHITESPACE: [ \t\r\n]+ -> skip ; // skip spaces, tabs, newlines

new_contents:
grammar WorkflowCatalogQueryLanguage;

@header {
   package org.ow2.proactive.workflow_catalog.rest.query;
}

// PARSER

expression
    : and_expression
    ;

and_expression
    : or_expression (AND or_expression)*
    ;

or_expression
    : clause (OR clause)*
    ;

clause
    : (AttributeLiteral COMPARE_OPERATOR StringLiteral)
    | LPAREN and_expression RPAREN
    ;

// LEXER

AND                 : 'AND' | '&&' ;
OR                  : 'OR' | '||' ;
COMPARE_OPERATOR    : '!=' | '=' ;
LPAREN              : '(' ;
RPAREN              : ')' ;

StringLiteral
    : '"' (~["\\\r\n] | '\\' (. | EOF))* '"'
    ;

AttributeLiteral
    : LETTER (LETTER | DIGIT | '_' | '.')*
    ;

WS
    : [ \t\r\n]+ -> skip
    ;

fragment DIGIT: [0-9];
fragment LETTER: LOWERCASE | UPPERCASE;
fragment LOWERCASE: [a-z];
fragment UPPERCASE: [A-Z];

subject: Update grammar for our Workflow Catalog Query Language (WCQL)


old_contents:
grammar InvestmentSize;

import Tokens;

@header {
    import com.github.robozonky.strategy.natural.*;
}

investmentSizeExpression returns [Collection<InvestmentSize> result]:
 { Collection<InvestmentSize> result = new LinkedHashSet<>(); }
 (i=investmentSizeRatingExpression { result.add($i.result); })+
 { $result = result; }
;

investmentSizeRatingExpression returns [InvestmentSize result] :
    'Do úvěrů v ratingu ' r=ratingExpression ' investovat' i=investmentSizeRatingSubExpression {
        $result = new InvestmentSize($r.result, $i.result);
    }
;

new_contents:
grammar InvestmentSize;

import Tokens;

@header {
    import com.github.robozonky.strategy.natural.*;
}

investmentSizeExpression returns [Collection<InvestmentSize> result]:
 { Collection<InvestmentSize> result = new LinkedHashSet<>(); }
 (i=investmentSizeRatingExpression { result.add($i.result); })*
 { $result = result; }
;

investmentSizeRatingExpression returns [InvestmentSize result] :
    'Do úvěrů v ratingu ' r=ratingExpression ' investovat' i=investmentSizeRatingSubExpression {
        $result = new InvestmentSize($r.result, $i.result);
    }
;

subject: Make investment size spec optional

message: Make investment size spec optional


old_contents:
grammar Relational;

relationalExpression : unionExpression ;

unionExpression : 'union' '(' datasetExpression (',' datasetExpression )* ')' ;

datasetExpression : 'datasetExpr' NUM+;

NUM : '0'..'9' ;
WS          : [ \t\n\t] -> skip ;

new_contents:
grammar Relational;

relationalExpression : unionExpression | joinExpression ;

unionExpression : 'union' '(' datasetExpression (',' datasetExpression )* ')' ;

datasetExpression : 'datasetExpr' NUM+;

joinExpression : '[' (INNER | OUTER | CROSS ) datasetExpression (',' datasetExpression )* ']' joinClause (',' joinClause)* ;
joinClause : joinCalc
           | joinFilter
           | joinKeep
           | joinRename ;
           // | joinDrop
           // | joinUnfold
           // | joinFold ;

joinCalc   : 'TODO' ;
joinFilter : 'TODO' ;
joinKeep   : 'TODO' ;
joinRename : 'TODO' ;

INNER : 'inner' ;
OUTER : 'outer' ;
CROSS : 'cross' ;

NUM : '0'..'9' ;

WS          : [ \t\n\t] -> skip ;

subject: Add joinExpression to the relationalExpression


old_contents:
grammar Type;

CT : [A-Z][a-z]+ ;
VT : [a-z]+ ;
WS : [ \t\r\n]+ -> skip ;

type : functionType | compoundType; // function type
functionType : compoundType ('->' type)+ ;
compoundType : concreteType | tupleType | listType | parenType ;

tupleType : '(' type (',' type)+ ')' ; // tuple type, k>=2
listType : '[' type ']' ;              // list type
parenType : '(' type ')' ;             // parenthesised constructor

concreteType : constantType | variableType ;

constantType : CT ;
variableType : VT ;

new_contents:
grammar Type;

CT : [A-Z][a-z]+ ;
VT : [a-z]+ ;
WS : [ \t\r\n]+ -> skip ;

type : functionType | compoundType ; // function type
functionType : compoundType '->' type ;
compoundType : constantType | variableType | tupleType | listType | parenType ;

tupleType : '(' type (',' type)+ ')' ; // tuple type, k>=2
listType : '[' type ']' ;              // list type
parenType : '(' type ')' ;             // type with parentheses

constantType : CT ;
variableType : VT ;

subject: Change antler grammar to support new type API

license: mit


old_contents:
grammar Expression;

expression : sign = ('-' | '+') expression
			| subExpresion
			| left = expression op = POW right = expression
			| left = expression op = ( MULT | DIV ) right = expression
			| left = expression op = ( ADD | SUB ) right = expression
			| function
			| value = ( IDENT  | CONST )
			;

subExpresion : LPAREN expression RPAREN ;

function : name = IDENT LPAREN  paramFirst = expression ( ',' paramRest += expression )* RPAREN ;

CONST	: INTEGER | DECIMAL;

INTEGER : [0-9]+;

DECIMAL : [0-9]+'.'[0-9]+;

IDENT : [_A-Za-z#][_.A-Za-z#]*;

LPAREN : '(';
RPAREN : ')';

MULT : '*';
DIV  : '/';
ADD  : '+';
SUB  : '-';
POW  : '^';

WS : [ \r\t\u000C\n]+ -> skip ;

new_contents:
grammar Expression;

expression : sign = ('-' | '+') expression
			| subExpresion
			| left = expression op = POW right = expression
			| left = expression op = ( MULT | DIV ) right = expression
			| left = expression op = ( ADD | SUB ) right = expression
			| function
			| value = ( IDENT  | CONST )
			;

subExpresion : LPAREN expression RPAREN ;

function : name = IDENT LPAREN  paramFirst = expression ( ',' paramRest += expression )* RPAREN ;

CONST	: INTEGER | DECIMAL;

INTEGER : [0-9]+;

DECIMAL : [0-9]+'.'[0-9]+;

IDENT : [_#A-Za-z][_#.A-Za-z0-9]*;

LPAREN : '(';
RPAREN : ')';

MULT : '*';
DIV  : '/';
ADD  : '+';
SUB  : '-';
POW  : '^';

WS : [ \r\t\u000C\n]+ -> skip ;

subject: Allow numeric digits also in the identifier names.


new_contents:
/*-
 * #%L
 * Java VTL
 * %%
 * Copyright (C) 2016 Hadrien Kohl
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */
grammar VTL;

import Atoms, Clauses, Conditional, Relational;

start : statement+ EOF;

/* Assignment */
statement : variableRef ':=' datasetExpression;

exprMember : datasetExpression ('#' componentID)? ;

/* Expressions */
datasetExpression : <assoc=right>datasetExpression clauseExpression #withClause
           | relationalExpression                                   #withRelational
           | getExpression                                          #withGet
           | putExpression                                          #withPut
           | exprAtom                                               #withAtom
           ;

componentID : IDENTIFIER;

getExpression : 'get' '(' datasetId ')';
putExpression : 'put(todo)';

datasetId : STRING_CONSTANT ;

WS : [ \n\r\t\u000C] -> skip ;
COMMENT : '/*' .*? '*/' -> skip;

subject: Add comment to the parser grammar

message: Add comment to the parser grammar


old_contents:
grammar Type;

CT : [A-Z][a-z]+ ;
VT : [a-z]+ ;
WS : [ \t\r\n]+ -> skip ;

type : typeClasses ? innerType ;
innerType : functionType | compoundType ; // function type
functionType : compoundType '->' innerType ;
compoundType : constantType | variableType | tupleType | listType | parenType ;

tupleType : '(' innerType (',' innerType)+ ')' ; // tuple type, k>=2
listType : '[' innerType ']' ;              // list type
parenType : '(' innerType ')' ;             // type with parentheses

constantType : typeConstructor (WS* innerType)* ;
typeConstructor : CT ;
variableType : VT ;

typeClasses : '(' typeWithClass (',' typeWithClass)* ')' '=>' | typeWithClass '=>' ;
typeWithClass : typeClass WS* classedType ;
classedType : VT ;
typeClass : CT ;

new_contents:
grammar Type;

CT : [A-Z][A-Za-z]+ ;
VT : [a-z]+ ;
WS : [ \t\r\n]+ -> skip ;

type : (typeClasses '=>')? innerType ;
innerType : functionType | compoundType ; // function type
functionType : compoundType '->' innerType ;
compoundType : constantType | variableType | tupleType | listType | parenType ;

tupleType : '(' innerType (',' innerType)+ ')' ; // tuple type, k>=2
listType : '[' innerType ']' ;              // list type
parenType : '(' innerType ')' ;             // type with parentheses

constantType : typeConstructor (innerType)* ;
typeConstructor : CT ;
variableType : VT ;

typeClasses : '(' typeWithClass (',' typeWithClass)* ')' | typeWithClass ;
typeWithClass : typeClass classedType ;
classedType : VT ;
typeClass : CT ;

subject: Fix issue with lexing type classes with an uppercase character after the first position


old_contents:
grammar WorkflowCatalogQueryLanguage;

@header {
   package org.ow2.proactive.workflow_catalog.rest.query.parser;
}

// PARSER

expression
    : and_expression
    ;

and_expression
    : or_expression (AND or_expression)*
    ;

or_expression
    : clause (OR clause)*
    ;

clause
    : (AttributeLiteral COMPARE_OPERATOR StringLiteral)
    | LPAREN and_expression RPAREN
    ;

// LEXER

AND                 : 'AND' | '&&' ;
OR                  : 'OR' | '||' ;
COMPARE_OPERATOR    : '!=' | '=' ;
LPAREN              : '(' ;
RPAREN              : ')' ;

StringLiteral
    : '"' (~["\\\r\n] | '\\' (. | EOF))* '"'
    ;

AttributeLiteral
    : LETTER (LETTER | DIGIT | '_' | '.')*
    ;

WS
    : [ \t\r\n]+ -> skip
    ;

fragment DIGIT: [0-9];
fragment LETTER: LOWERCASE | UPPERCASE;
fragment LOWERCASE: [a-z];
fragment UPPERCASE: [A-Z];

new_contents:
grammar WorkflowCatalogQueryLanguage;

@header {
   package org.ow2.proactive.workflow_catalog.rest.query.parser;
}

// PARSER

expression
    : and_expression
    ;

and_expression
    : or_expression (AND or_expression)*
    ;

or_expression
    : clause (OR clause)*
    ;

clause
    : (AttributeLiteral COMPARE_OPERATOR StringLiteral) #finalClause
    | LPAREN and_expression RPAREN #parenthesedClause
    ;

// LEXER

AND                 : 'AND' | '&&' ;
OR                  : 'OR' | '||' ;
COMPARE_OPERATOR    : '!=' | '=' ;
LPAREN              : '(' ;
RPAREN              : ')' ;

StringLiteral
    : '"' (~["\\\r\n] | '\\' (. | EOF))* '"'
    ;

AttributeLiteral
    : LETTER (LETTER | DIGIT | '_' | '.')*
    ;

WS
    : [ \t\r\n]+ -> skip
    ;

fragment DIGIT: [0-9];
fragment LETTER: LOWERCASE | UPPERCASE;
fragment LOWERCASE: [a-z];
fragment UPPERCASE: [A-Z];

subject: Add aliases to clauses subterms

message: Add aliases to clauses subterms


old_contents:
lexer grammar CcsLexer;

TERM: ';';

NIL: '0';
COMMA: ',';
DIV : '/' ;
DEF: '=';
PAR: '|';
PREFIX: '.';
CHOICE: '+';
TAU: 'tau';
LBRACE : '{' ;
RBRACE : '}' ;
MUL : '*' ;
SETDEF  : 'set ' ;
LPAREN : '(' ;
RPAREN : ')' ;
LBRACK : '[' ;
RBRACK : ']' ;
T__1 : '\\' ;

COACTION: '\''[a-z][A-Za-z0-9]*;
ACTION: [a-z][A-Za-z0-9]*;

fragment InputCharacter: ~[\r\n\u0085\u2028\u2029];
COMMENT
    : MUL InputCharacter+
    | MUL
    ;

IDENTIFIER
    : [A-Z][A-Za-z0-9]*
    ;

//RENAMINGS   : RENAMING ',' RENAMINGS;
//RENAMING    : ACTION  ACTION;

// ignore whitespace
WHITESPACE  : [ \r\n\t] + -> channel (HIDDEN);

new_contents:
lexer grammar CcsLexer;

TERM: ';';

NIL: '0';
COMMA: ',';
DIV : '/' ;
DEF: '=';
PAR: '|';
PREFIX: '.';
CHOICE: '+';
TAU: 'tau';
LBRACE : '{' ;
RBRACE : '}' ;
MUL : '*' ;
SETDEF  : 'set ' ;
LPAREN : '(' ;
RPAREN : ')' ;
LBRACK : '[' ;
RBRACK : ']' ;
T__1 : '\\' ;

COACTION: '\''[a-z][A-Za-z0-9]*;
ACTION: [a-z][A-Za-z0-9]*;

fragment InputCharacter: ~[\r\n\u0085\u2028\u2029];
COMMENT
    : MUL InputCharacter+
    | MUL
    ;

IDENTIFIER
    : [A-Z][A-Za-z0-9]*
    ;

// ignore whitespace
WHITESPACE  : [ \r\n\t] + -> channel (HIDDEN);

subject: Remove useless stuff from lever grammar

message: Remove useless stuff from lever grammar


old_contents:
grammar Type;

CT : [A-Z][a-z]+ ;
VT : [a-z]+ ;
WS : [ \t\r\n]+ -> skip ;

baseType : typeClasses ? type ;
type : functionType | compoundType ; // function type
functionType : compoundType '->' type ;
compoundType : constantType | variableType | tupleType | listType | parenType ;

tupleType : '(' type (',' type)+ ')' ; // tuple type, k>=2
listType : '[' type ']' ;              // list type
parenType : '(' type ')' ;             // type with parentheses

constantType : typeConstructor (WS* type)* ;
typeConstructor : CT ;
variableType : VT ;

typeClasses : '(' typeWithClass (',' typeWithClass)* ')' '=>' ;
typeWithClass : typeClass WS* classedType ;
classedType : VT ;
typeClass : CT ;

new_contents:
grammar Type;

CT : [A-Z][a-z]+ ;
VT : [a-z]+ ;
WS : [ \t\r\n]+ -> skip ;

type : typeClasses ? innerType ;
innerType : functionType | compoundType ; // function type
functionType : compoundType '->' innerType ;
compoundType : constantType | variableType | tupleType | listType | parenType ;

tupleType : '(' innerType (',' innerType)+ ')' ; // tuple type, k>=2
listType : '[' innerType ']' ;              // list type
parenType : '(' innerType ')' ;             // type with parentheses

constantType : typeConstructor (WS* innerType)* ;
typeConstructor : CT ;
variableType : VT ;

typeClasses : '(' typeWithClass (',' typeWithClass)* ')' '=>' ;
typeWithClass : typeClass WS* classedType ;
classedType : VT ;
typeClass : CT ;

subject: Fix bug in Antlr grammar

message: Fix bug in Antlr grammar


new_contents:
grammar PTP;

@header {

package pt.up.fe.iart.proj1.parser;

}

map : stmt+ ;

stmt : node_stmt #node
     | edge_stmt #edge
     ;

edge_stmt : 'Edge' '(' from=node_stmt ',' to=node_stmt ',' weight=(INT|REAL) ')';

node_stmt : 'GasStation' '(' position ')'                   #GasStation
          | 'GenericLocation' '(' position ')'              #GenericLocation
          | 'PatientLocation' '(' position ')'              #PatientLocation
          | 'Filiation' '(' position ',' bool ')'           #Filiation
          ;

position : '(' x=INT ',' y=INT ')' ;
bool : 'true' | 'false' ;

INT: [0-9]+ ;
REAL: [0-9]+ '.' [0-9]* ;

WS : [ \t\r\n]+ -> skip;
COMMENT         :   '/*' .*? '*/'       -> skip ;
LINE_COMMENT    :   '//' .*? '\r'? '\n' -> skip ;

subject: Add comments to input grammar.

message: Add comments to input grammar.


old_contents:
grammar Type;

CT : [A-Z][a-z]+ ;
VT : [a-z]+ ;
WS : [ \t\r\n]+ -> skip ;

type : typeClasses ? innerType ;
innerType : functionType | compoundType ; // function type
functionType : compoundType '->' innerType ;
compoundType : constantType | variableType | tupleType | listType | parenType ;

tupleType : '(' innerType (',' innerType)+ ')' ; // tuple type, k>=2
listType : '[' innerType ']' ;              // list type
parenType : '(' innerType ')' ;             // type with parentheses

constantType : typeConstructor (WS* innerType)* ;
typeConstructor : CT ;
variableType : VT ;

typeClasses : '(' typeWithClass (',' typeWithClass)* ')' '=>' ;
typeWithClass : typeClass WS* classedType ;
classedType : VT ;
typeClass : CT ;

new_contents:
grammar Type;

CT : [A-Z][a-z]+ ;
VT : [a-z]+ ;
WS : [ \t\r\n]+ -> skip ;

type : typeClasses ? innerType ;
innerType : functionType | compoundType ; // function type
functionType : compoundType '->' innerType ;
compoundType : constantType | variableType | tupleType | listType | parenType ;

tupleType : '(' innerType (',' innerType)+ ')' ; // tuple type, k>=2
listType : '[' innerType ']' ;              // list type
parenType : '(' innerType ')' ;             // type with parentheses

constantType : typeConstructor (WS* innerType)* ;
typeConstructor : CT ;
variableType : VT ;

typeClasses : '(' typeWithClass (',' typeWithClass)* ')' '=>' | typeWithClass '=>' ;
typeWithClass : typeClass WS* classedType ;
classedType : VT ;
typeClass : CT ;

subject: Add single type class notation to type parser


new_contents:
grammar Track;

track: track_decl decl* ;

track_decl: 'track' '{' IDENT+ '}' ;

decl: block_decl | channel_decl ;

block_decl: IDENT '::' 'block' '{' block_body '}' ;
block_body: (note)+ ;
note: NOTENAME OCTAVE? LENGTH? ;

channel_decl: IDENT '::' 'channel' WAVE '{' channel_body '}' ;
channel_body: (block_name)+ ;
block_name: IDENT ;

NOTENAME: 'Ab'
        | 'A'
        | 'A#'
        | 'Bb'
        | 'B'
        | 'C'
        | 'C#'
        | 'Db'
        | 'D'
        | 'D#'
        | 'Eb'
        | 'E'
        | 'F'
        | 'F#'
        | 'Gb'
        | 'G'
        | 'G#'
        | 'R'
        ;

OCTAVE: [0-9] | '10' ;
LENGTH: [-+.]+ ;

WAVE: 'triangle' | 'square' | 'sawtooth' | 'noise' ;

IDENT: [a-zA-Z][a-zA-Z0-9_]+ ;
WS: [\t\r\n ]+ -> skip ;

subject: Add first attempt at track grammar

message: Add first attempt at track grammar

repos: hdgarrood/klasma


new_contents:
grammar PTP;

@header {

package pt.up.fe.iart.proj1.parser;

}

map : stmt+ ;

stmt : node_stmt #node
     | edge_stmt #edge
     ;

edge_stmt : 'Edge' '(' from=node_stmt ',' to=node_stmt ',' weight=(INT|REAL) ')';

node_stmt : 'GasStation' '(' position ')'                   #GasStation
          | 'GenericLocation' '(' position ')'              #GenericLocation
          | 'PatientLocation' '(' position ')'              #PatientLocation
          | 'Filiation' '(' position ',' bool ')'           #Filiation
          ;

position : '(' x=INT ',' y=INT ')' ;
bool : 'true' | 'false' ;

INT: [0-9]+ ;
REAL: [0-9]+ '.' [0-9]* ;

WS : [ \t\r\n]+ -> skip;

subject: Create prolog/scala based ANTLR 4 grammar to use to parse input files.


new_contents:
grammar Viper;

tokens { NAME
       , NEWLINE
       , INDENT
       , DEDENT
       , NUMBER
       , STRING
       }

func_def: 'def' func_name parameters '->' func_type ':' suite ;
func_name: NAME ;
func_type: type_expr ;

parameters: '(' params_list? ')' ;
params_list: argless_parameter parameter* ;
parameter: arg_label? argless_parameter ;
argless_parameter: param_name ':' param_type ;
arg_label: NAME ;
param_name: NAME ;
param_type: type_expr ;

type_expr: NAME ;

suite: ( simple_stmt
       | NEWLINE INDENT stmt+ DEDENT
       ) ;

stmt: ( simple_stmt
      | compound_stmt
      ) ;

simple_stmt: expr_stmt NEWLINE ;
expr_stmt: ( expr_list
           | 'pass'
           | 'return' expr_list?
           ) ;

expr_list: expr (',' expr)* ;

expr: atom_expr ;
atom_expr: atom trailer* ;
atom: ( '(' expr_list? ')'
      | NAME
      | NUMBER
      | STRING
      | '...'
      | 'Zilch'
      | 'True'
      | 'False'
      ) ;
trailer: ( '(' arg_list? ')'
         | '.' NAME
         ) ;

compound_stmt: ( func_def
               | object_def
               | data_def
               ) ;

object_def: ( class_def
            | interface_def
            | implementation_def
            ) ;

class_def: 'class' common_def ;
interface_def: 'interface' common_def ;
implementation_def: NAME common_def ;
data_def: 'data' common_def ;
common_def: NAME ('(' arg_list? ')')? ':' suite ;
arg_list: argument (',' argument)* ;
argument: expr ;

subject: Add grammar in ANTLR 4 format

message: Add grammar in ANTLR 4 format

repos: pdarragh/Viper