grammar Tack;

// ---------------- syntactic ----------------
program returns [AstNode v] :	
     f=funDefList EOF {$v = new Program(new Location($ctx), $f.v);};

funDef returns [FunDef v] :
    n=funId EQ FUN
    {$v=new FunDef(new Location($ctx), $n.v);};

 funDefList returns [FunDefListHead v] :	
    f=funDef t=funDefListTail {$v=new FunDefListHead(
    	                        new Location($ctx), $f.v, $t.v);};
 funDefListTail returns [FunDefListTail v] :
    f=funDef t=funDefListTail {$v=new FunDefListTail(
    	     new Location($ctx), $f.v, $t.v);}
  | /*empty*/ {$v=new FunDefListTail(new Location($ctx));};

funId returns [FunId v] :
    ID {$v=new FunId(new Location($ctx), $ID.text);};

// ---------------- lexical ----------------

EQ : '=' ;
FUN : 'fun' ;

ID : [a-zA-Z] [a-zA-Z0-9]* ;

WS : ( [ \r\t\n] | NEWLINE | COMMENT )+ -> skip ;

NEWLINE : '\r' '\n' | '\r' | '\n';
COMMENT : '#' ~[\r\n]* '\r'?  (NEWLINE | EOF) -> skip ;

