	{ This grammar defines the langage T of Thot
	  The notation used here is defined in file META.LAN
 
	   ' '  : keyword
	   [ ]  : optional part
	   < >  : optional and repeatable part
	   /    : choice

	  V. Quint	January 1988	}

TransSchema  =  'Translation' TypeIdent ';'
              [ 'LineLength' MaxLineLength ';' ]
	      [ 'LineEnd' LineEndString ';' ]
	      [ 'LineEndInsert' LineEndInsertString ';' ]
              [ 'Buffers' SeqOfBuffer ]
              [ 'Counters' SeqOfCounter ]
              [ 'Const' SeqOfConst ]
              [ 'Var' SeqOfVariable ]
                'Rules' TheRules
              [ 'Attributes' SeqOfAttr ]
              [ 'Presentation' SeqOfPres ]
              < 'TextTranslate' TSeqOfTransl >
              [ 'SymbTranslate' SeqOfTransl ]
              [ 'GraphTranslate' SeqOfTransl ]
                'End' .

MaxLineLength =  NUMBER .
LineEndString =  STRING .
LineEndInsertString =  STRING .

SeqOfConst =     ConstDcl < ConstDcl > .
ConstDcl =       ConstIdent '=' ConstValue ';' .
ConstIdent =     NAME .
ConstValue =     STRING .

SeqOfCounter =   CounterDcl < CounterDcl > .
CounterDcl =     CounterIdent [ ':' CountFunction ] ';' .
CounterIdent =   NAME .
CountFunction =  'Rank' 'of' TypeIdent [ RelAncestorLevel ] [ 'Init' AttrIdent ] /
                 'Rlevel' 'of' TypeIdent /
                 'Set' InitValue 'On' TypeIdent 'Add' IncrValue
                 'On' TypeIdent [ 'Init' AttrIdent ] .
RelAncestorLevel = [ '-' ] AncestorLevel .
AncestorLevel =	 NUMBER .
InitValue =      NUMBER .
IncrValue =      NUMBER .
TypeIdent =      NAME .

SeqOfBuffer =    BufferDcl < BufferDcl > .
BufferDcl =      BufferIdent [ '(' 'Picture' ')' ] ';' .
BufferIdent =    NAME .

SeqOfVariable =  VariableDcl < VariableDcl > .
VariableDcl =    VariableIdent ':' Function < Function > ';' .
VariableIdent =  NAME .
Function =       'Value' '(' CounterIdent [ ':' Length ] [ ',' CounterStyle ] ')' /
		 'FileDir' / 'FileName' / 'Extension' /
		 'DocumentName' / 'DocumentDir' /
		 ConstIdent / CharString / BufferIdent / AttrIdent .
Length =	 NUMBER .
CounterStyle =   'ARABIC' / 'UROMAN' / 'LROMAN' / 'UPPERCASE' / 'LOWERCASE' .

CharString =     STRING .

SeqOfAttr =      TransAttr < TransAttr > .
TransAttr =      AttrIdent [ '(' TypeIdent ')' ] [ AttrRelat ] ':'
                 SeqOfRules .
AttrIdent =      NAME .
AttrRelat =	 '=' AttrValue / '>' [ '-' ] MinVal / '<' [ '-' ] MaxVal /
		 'IN' '[' ['-'] MinInterval '.' '.' ['-'] MaxInterval ']' .
AttrValue =	 [ '-' ] ValEqual / TextEqual / AttrValIdent .
MinVal =	 NUMBER .
MaxVal =	 NUMBER .
MinInterval =	 NUMBER .
MaxInterval =	 NUMBER .
ValEqual =	 NUMBER .
TextEqual =	 STRING .
AttrValIdent =   NAME .

TheRules =       TransType < TransType > .
TransType =      [ FirstSec ] TypeIdent ':' SeqOfRules .
FirstSec =	 'First' / 'Second' .

SeqOfRules =     'Begin' < CondRules > 'End' ';' / CondRules .
CondRules =       Rule1 / Rule2 .

Rule2 =          'If' SeqOfCond SeqOfRules1 .
SeqOfCond =      Condition < 'And' Condition > .

Condition =      [ 'Not' ] [ 'Target' ] Cond .
Cond =		 CondOnSelf / CondAscend .
CondOnSelf =     'Defined' /
                 'FirstRef' / 'LastRef' / 'ExternalRef' /
		 'Alphabet' '=' Alphabet /
		 'FirstAttr' / 'LastAttr' /
		 'ComputedPage' / 'StartPage' / 'UserPage' / 'ReminderPage' /
		 'Empty' .

CondAscend =     [ Ascend ] CondOnAscend .
Ascend =         '*' / 'Parent' / 'Ancestor' LevelOrType .
LevelOrType =    CondRelLevel / TypeIdent [ '(' TypeIdent ')' ] .
CondRelLevel =   NUMBER .
CondOnAscend =   'First' / 'Last' /
                 'Refered' / 'Referred' /
	         [ 'Immediately' ] 'Within' [ ParentLevel ] TypeIdent
                                                      [ '(' TypeIdent ')' ] /
	         'FirstWithin' [ ParentLevel ] TypeIdent
                                                      [ '(' TypeIdent ')' ] /
		 'Attributes' /
		  AttrIdent [ AttrRelat ] /
		  TypeIdent /
                 'Presentation' / PresRule / 'Comment' .

ParentLevel =	 [ GreaterLess ] RelLevel .
GreaterLess =	 '>' / '<' .
RelLevel =	 NUMBER .
TrSchema =       NAME .

SeqOfRules1 =    'Begin' < Rule1 > 'End' ';' / Rule1 .

Rule1 =		 RuleA / RuleB .
RuleA =          'Create' [ 'IN' VariableIdent ] Token [ Position ] ';' /
                 'Get' [ RelPosition ] TypeIdent [ '(' TypeIdent ')' ]
                       [ Position ] ';' /
		 'Copy' [ RelPosition ] TypeIdent [ '(' TypeIdent ')' ]
	                [ Position ] ';' /
                 'Use' TrSchema [ 'For' TypeIdent ] ';' /
                 'Remove' ';' /
	         'Write' Token [ Position ] ';' /
                 'Read' BufferIdent [ Position ] ';' /
                 'Include' File [ Position ] ';' /
		 'NoTranslation' ';' /
                 'NoLineBreak' ';' .
RuleB =		 'ChangeMainFile' VariableIdent [ Position ] ';' /
		 'Set' CounterIdent InitValue [ Position ] ';' /
		 'Add' CounterIdent IncrValue [ Position ] ';' /
                 'Indent' [ 'IN' VariableIdent ] [ IndentSign ] IndentVal
                          [ Position ] ';' /
		 'RemoveFile' VariableIdent [ Position ] ';' .

IndentSign =     '+' / '-' .
IndentVal =	 NUMBER .

Token =		 ConstIdent / VariableIdent /
		 'Refered' VarOrType [ '(' TypeIdent ')' ] /
		 'Referred' VarOrType [ '(' TypeIdent ')' ] /
                 CharString /
                 BufferIdent / '(' Function < Function > ')' /
                 AttrIdent / 'Value' / 'Content' / 'Comment' /
		 'FileDir' / 'FileName' / 'Extension' /
		 'DocumentName' / 'DocumentDir' /
                 'Attributes' / 'Presentation' / 'RefId' / 'PairId' .
VarOrType =	 'DocumentName' / 'DocumentDir' / 'RefId' /
		 VariableIdent / TypeIdent .
Position =       'After' / 'Before' .
RelPosition =    'Included' / 'Refered' / 'Referred' .

File =           FileName / BufferIdent .

TSeqOfTransl =   [ Alphabet ] SeqOfTransl .
Alphabet =       NAME .
SeqOfTransl =    'Begin' < Translation > 'End' ';' /
                 Translation .
Translation =    Source [ '-' '>' Target ] ';' .
Source =         STRING .
Target =         STRING .
FileName =       STRING .

SeqOfPres =      TransPres < TransPres > .
TransPres =      PresRule ':' SeqOfRules .
PresRule =       'Size' [ PresRelat ] /
                 'Indent' [ PresRelat ] /
                 'LineSpacing' [ PresRelat ] /
                 'Adjust' [ '=' AdjustVal ] /
	         'Justify' [ '=' BooleanVal ] /
	         'Hyphenate' [ '=' BooleanVal ] /
                 'Style' [ '=' StyleVal ] /
                 'Font' [ '=' FontVal ] /
                 'UnderLine' [ '=' UnderLineVal ] /
	          'Thickness' [ '=' UnderLStyleVal ] /
		 'LineStyle' [ '=' LineStyleVal ] /
		 'LineWeight' [ PresRelat ] /
		 'FillPattern' [ '=' Pattern ] /
		 'Background' [ '=' Color ] /
		 'Foreground' [ '=' Color ] .
PresRelat =      '=' PresValue /
                 '>' [ '-' ] MinimumPres /
                 '<' [ '-' ] MaximumPres /
                 'IN' '[' [ '-' ] MinIntervalPres '.' '.'
                          [ '-' ] MaxIntervalPres ']' .
AdjustVal =      'Left' / 'Right' / 'VMiddle' / 'LeftWithDots' .
BooleanVal =     'Yes' / 'No' .
StyleVal =       'Bold' / 'Italics' / 'Roman' / 'BoldItalics' /
                 'Oblique' / 'BoldOblique' .
FontVal =        'Times' / 'Helvetica' / 'Courier' .
UnderLineVal =   'NoUnderline' / 'Underlined' / 'Overlined' / 'CrossedOut' /
		 { the following values are obsolete }
                 'No' / 'UnderLine' / 'OverLine' / 'StrikeOut' .
UnderLStyleVal = 'Thick' / 'Thin' .

LineStyleVal =   'Solid' / 'Dashed' / 'Dotted' .
Pattern =        NAME .
Color =          NAME .

MinimumPres =    NUMBER .
MaximumPres =    NUMBER .
MinIntervalPres= NUMBER .
MaxIntervalPres= NUMBER .
PresValue =      [ '-' ] PresVal .
PresVal =        NUMBER .

END
