/*Copyright 2009--2017 Rene Vestergaard
 * 
 * This file is part of CEqEA. 
 * 
 * CEqEA is free software: you can redistribute it and/or modify it under 
 * the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * CEqEA is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public 
 * License along with CEqEA, possibly as <CEqEA-dir>/COPYING.  
 * If not, see <http://www.gnu.org/licenses/>. 
 */
 
//ignored symbols: comments, universal separators
fragment COMMENT_OPEN: '//';
fragment OUTTAKE_OPEN: '/*';
fragment OUTTAKE_CLSE: '*/';
fragment CR: '\r';
fragment NL: '\n';
fragment SPACE: ' ';
fragment TAB: '\t';

IGNORE
  : ( (COMMENT_OPEN .*)? CR? NL
    | OUTTAKE_OPEN .* OUTTAKE_CLSE
    | SPACE
    | TAB
    ) ;


//grouping
SQNC_OPEN: '[';
SQNC_CLSE: ']';
ACTV_OPEN: '{';
ACTV_CLSE: '}';
PAR_OPEN: '(';
PAR_CLSE: ')';
LSS_THN: '<';
GRT_THN: '>';

//regulation connectives
RGLT_INDRCT: '^';
RGLT_STRONG: '!';
RGLT_CNJNCT: '&';
RGLT_DSJNCT: ':';
RGLT_INHBTN: '|--';

MIN: ('min'|'Min'|'MIN');
MAX: ('max'|'Max'|'MAX');

COND: ('c'|'C')'ond'('itional')?;
ENDCOND: ('e'|'E')'nd'('c'|'C')'ond';

//top-level
COMMA: ',';
SNTNC_CLSE: ';';
COL_SEP: '|';

fragment DGRM : ('d'|'D')'grm' | ('d'|'D')'iagram';
fragment FILTER: ('f'|'F')'ltr' | ('f'|'F')'ilter';
DGRM_FILTER: DGRM FILTER | ('p'|'P')'resentation';

//directives/defaults
ASSIGN: '=';

//expressions
EQUAL: '==';
LSS_EQ: '<=';
GRT_EQ: '>=';

//schemas
DOT: '.';
SUBJ_ALT: '%';

//influences
PSTV: '+';
NGTV: '-';

//seeds
QUOTTN: '"';		

//qualifiers and modifiers
MACRO: '@';
RANGE: ('+'|'-')('+'|'-');
SUPPLY: '\\';
SHARP: '#';
ABSTR: '$';
LVLING: '/';


//Directives
WARN_MISS: ('w'|'W')'arn' ('o'|'O')'n' (('s'|'S')'qnc' | ('s'|'S')'equence') (('m'|'M')'is' | ('m'|'M')'ismatch');

EXO_INF: ('e'|'E')'xo''geny'?('i'|'I')'nf''erence'?;

RESIDTN : ('r'|'R')'esiduation';

fragment FIXPOINT: ('f'|'F')('p'|'P') | ('f'|'F')'ixpoint';
LEAST_FP: 'least' FIXPOINT;
GREAT_FP: ('great'|'greatest') FIXPOINT;

CIRCLR: (('c'|'C')'irc' | ('c'|'C')'ircular');

WELLFND: ('w'|'W')('f'|'F') | ('w'|'W')'ell'('-')?('f'|'F')'ounded';

PREINHB: ('p'|'P')'reemptive'('i'|'I')'nhibition';
STT_REPT: ('s'|'S')'tate'('r'|'R')'epeats';


//abstractions
CATGRS: ('c'|'C')'ategories';
FLTR: ('f'|'F')'ilter';


//compartmentation
CHANNEL: (('i'|'I')'n' | ('o'|'O')'ut') ('c'|'C')'hannel' | ('e'|'E') 'ntry' | ('e'|'E') 'xit';


//modalities, defaults + values
TRMNTN: ('t'|'T')'trmntn' | ('t'|'T')'ermination';

APPRX : ('a'|'A')'pprx' | ('a'|'A')'pproximate';
ENDPT : ('e'|'E')'nd'('p'|'P')'t' | ('e'|'E')'nd'('p'|'P')'oint';
CSLSS : ('c'|'C')'slss' | ('c'|'C')'easeless';


CSTN: ('c'|'C')'ausation' | ('c'|'C')'stn';

PUSH: ('p'|'P')'ush';
PULL: ('p'|'P')'ull';
PUSHPULL: PUSH PULL;


MDTN: ('m'|'M')'dtn' | ('m'|'M')'ediation';
 
RESID: ('r'|'R')'esid' | ('r'|'R')'esidual';
STPWS: ('s'|'S')'tpws' | ('s'|'S')'tepwise';

EXPLCT: ('e'|'E')'xpl' | ('e'|'E')'xplicit';
DNMC: ('d'|'D')'yn' | ('d'|'D')'ynamic';
IMPLCT: ('i'|'I')'mpl' | ('i'|'I')'mplicit';


INSTNTTN : ('i'|'I')'nstnttn' | ('i'|'I')'nstantiation';

CHRNT : ('c'|'C')'hrnt' | ('c'|'C')'oherent';
MIXED : ('m'|'M')'ix' | ('m'|'M')'ixed';


SLTN: ('s'|'S')'ltn' | ('s'|'S')'olution';

fragment OK: 'OK';
EMPTY: ('e'|'E')'mpty';
FIXED: ('f'|'F')'ixed';
APPEAR: ('a'|'A')'ppear';
APPEAR_OK: APPEAR OK;
VANISH: ('v'|'V')'anish';
VANISH_OK: VANISH OK;
CHANGE: ('c'|'C')'hange';
CHANGE_OK: CHANGE OK;


RGLTN: ('r'|'R')'gltn' | ('r'|'R')'egulation';

CHMSTRY: ('c'|'C')'hmstry' | ('c'|'C')'hemistry';

EXTRINSIC: ('e'|'E')'xtrnsc' | ('e'|'E')'xtrinsic';
INTRINSIC: ('i'|'I')'intrnsc' | ('i'|'I')'ntrinsic';
INCIDENTL: ('i'|'I')'ncdntl' | ('i'|'I')'ncidental';



//defaults qualifiers
SCHM: ('s'|'S')'chm' | ('s'|'S')'chema';
INFL: ('i'|'I')'nfl' | ('i'|'I')'nfluence';
SEED: ('s'|'S')'eed';

//schemas qualifiers
DFLT: ('d'|'D')'flt' | ('d'|'D')'efault';

//generic qualifiers
MDTR: ('m'|'M')'dtr' | ('m'|'M')'ediator';
INHB: ('i'|'I')'nh'('b')? | ('i'|'I')'nhibitor';
RGLT: ('r'|'R')'glt'('r')? | ('r'|'R')'egulator';
SUBJ: ('s'|'S')'ubj' | ('s'|'S')'ubject';

DRCT: ('d'|'D')'rct' | ('d'|'D')'irect';
INDRCT: ('i'|'I')'ndrct' | ('i'|'I')'ndirect';

SITU: ('s'|'S')'itu';

RCTN: ('r'|'R')'ctn' | ('r'|'R')'eaction';
SLVNT: ('s'|'S')'lvnt' | ('s'|'S')'olvent';

SRCE: ('s'|'S')'rce' | ('s'|'S')'ource';
SINK: ('s'|'S')'ink';

//schema-specific classifiers
fragment NONE: ('N'|'n')'o'('t' | ('n'('e')?)?);

SPPRSS : 'SPPRSS' | 'SUPPRESS';
EXOGENIC: ('e'|'E')'xo''genic'? | ('c'|'C')'onst''ant'?;
ENDOGENIC: ('e'|'E')'ndo''genic'? | ('v'|'V')'ar''iable'?;
NON_RGLT: NONE RGLT;
NON_SUBJ: NONE SUBJ;


//seeds-specific keywords
CONNECT: ('c'|'C')'onnect' | ('c'|'C')'onnectable';

EXCL: ('e'|'E')'xcl' | ('e'|'E')'xclude';
MUTEXCL: ('m'|'M')'ut''ual'? EXCL;

INCOM: ('i'|'I')'n' | ('i'|'I')'ncoming';
OUTGO: ('o'|'O')'ut' | ('o'|'O')'utgoing';

NO_INCOM: NONE INCOM;
NO_OUTGO: NONE OUTGO;

SILENCE: ('s'|'S')'ilence';
EXPIRE: ('e'|'E')'xpire';

//general issues
NMBR: ('0' | ('1'..'9') ('0'..'9')*); 

NAME: NAME_char+;  

fragment NAME_char: 
  ~( '$'
   | OUTTAKE_OPEN
   | OUTTAKE_CLSE
   | CR
   | NL
   | SPACE
   | TAB
   | COMMA
   | SNTNC_CLSE
   | DOT
   | COL_SEP
   | SHARP
   | MACRO
   | ABSTR
   | LVLING
   | QUOTTN
   | SQNC_OPEN
   | SQNC_CLSE
   | ACTV_OPEN
   | ACTV_CLSE
   | PAR_OPEN
   | PAR_CLSE
   | LSS_THN
   | GRT_THN
   | SUPPLY
   | SUBJ_ALT
   | RGLT_STRONG
   | RGLT_CNJNCT
   | RGLT_DSJNCT
   | RGLT_INDRCT
   | PSTV
   | NGTV
   | ASSIGN
   | EQUAL
   | GRT_EQ
   | LSS_EQ
   ) ;