home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
pascal
/
compcomp
/
syntex
/
grammtp3.grm
next >
Wrap
Text File
|
1994-07-13
|
4KB
|
95 lines
@ SYNTEX v2.0 @
@ TPascal version 3 style example grammar @
';'= Semicolon.
','= Coma.
'.'= Point.
':'= Colon.
'..'= PointPoint.
'^'= Hat.
'+'= Plus.
'-'= Minus.
'*'= Time.
'/'= Divide.
'='= Equal.
'<>'= Different.
'<'= Inferior.
'<='= InferiorOrEqual.
'>'= Superior.
'>='= SuperiorOrEqual.
'['= OpenBracket.
']'= CloseBracket.
'('= OpenParenthesis.
')'= CloseParenthesis.
':='= Becomes.
START= PROGRAM NAME ';' bloc '.'.
bloc=declarations compound_instruction.
declarations= constants_definition typse_definition vars_declaration
procedures_or_functions_declaration.
compound_instruction= BEGIN instruction {';' instruction} END.
instruction= {instruction_simple | instruction_structured}.
instruction_simple= affectation | procedure_call.
affectation= access_variable ':=' expression | NAME ':=' expression.
access_variable= NAME | compound_variable | '^' variable_pointed.
compound_variable= access_table | access_record.
access_table= access_variable '[' expression { ',' expression} ']'.
access_record= NAME '.' NAME | NAME.
variable_pointed= access_variable.
procedure_call= NAME ['('parameter_actual {',' parameter_actual} ')'].
parameter_actual= access_variable | expression.
instruction_structured= instruction_composed | test | repetition | with.
suite_instruction= instruction {';' instruction}.
test= if | case.
if= IF expression THEN instruction [ELSE instruction].
case= CASE expression OF element_case {';' element_case}
[ELSE suite_instruction] END.
element_case= NOM ':' instruction.
repetition= while | repeat | for.
while= WHILE expression DO instruction.
repeat= REPEAT suite_instruction UNTIL expression.
for= FOR expression to_down_to expression DO instruction.
to_down_to= TO | DOWNTO.
with= WITH access_variable {',' access_variable } DO instruction.
expression= expression_simple [comparison expression_simple].
expression_simple= ['+'|'-'] term {'+' term | '-' term | OR term}.
term= factor {'*' factor | '/' factor | DIV factor | MOD factor | AND factor}.
factor= access_variable | NOT factor '(' expression ')' | factor_set.
factor_set= '[' [ element_set {',' element_set}] ']'.
element_set= expression ['..' expression].
comparison= '=' | '<>' | '<' | '>'.
constants_definition= [CONST constant_definition ';' {constant_definition ';'} ].
constant_definition= NAMM '=' CONSTANT.
types_definition= [TYPE type_definition ';' {type_definition ';'}].
type_definition= TYPE '=' type.
type= NAME | construction_of_type.
construction_of_type= NAME | enumerated_interval | type_structured | type_pointer.
enumerated_interval= type_enumerated | type_interval.
type_enumerated= '(' list_of_names ')'.
type_interval= CONSTANT '..' CONSTANT.
type_structured= type_table | type_rec | type_set | type_file.
type_table= ARRAY '[' type_interval {',' type_interval }']' OF type.
type_rec= RECORD list_of_zones END.
list_of_zones= zones_common [';' zones_variable].
zones_common= zone {';' zone}.
zone= list_of_names '=' type.
list_of_names= NAME {',' NAME}.
zones_variable= NAME.
type_set= SET OF NAME.
type_file= FILE OF type.
type_pointer= '^' NAME.
vars_declaration= [VAR var_declaration_variable ';' {declaration_variable ';'}].
declaration_variable= list_of_names ':' type.
procedures_or_fonctions_declaration= {declaration_procedure ';'}.
declaration_procedure= PROCEDURE NAME [list_of_parameters_formal] bloc.
list_of_parameters_formal= '(' parameters_formal {';' parameters_formal} ')'.
parameters_formal= [VAR] list_of_names ':' NOM.