//=============================================================================
// ANTLR Grammar for UNL Document
//=============================================================================

grammar doc;

@header {
from asd import doc
}


//=============================================================================
// Parser Grammar
//=============================================================================

//---------------------------------------------------------
// Document = list of sentence
//---------------------------------------------------------

document returns [out]
  : '[D]' s=sentence '[/D]'               {$out = doc.Document($s.out)}
  ;

sentence returns [out]
  : '[S:R1]' o=orgPart u=unlPart '[/S]'   {$out = doc.Sentence($o.out, $u.out)}
  ;

orgPart returns [out]
  : o=ORG                                 {$out = doc.OrgPart($o.text)}
  ;

unlPart returns [out]
  : u=UNL                                 {$out = doc.UnlPart($u.text)}
  ;


//=============================================================================
// Lexer Grammar
//=============================================================================

// ignore whitespaces
WS              : (' '|'\n'|'\t'|'\r'|'\u000C')+ -> skip ;

// other tokens
ORG             : '{org:en}' (.)* '{/org}' ;
UNL             : '{unl}' (.)* '{/unl}' ;