home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / compcomp / syntex / grammtp3.grm next >
Text File  |  1994-07-13  |  4KB  |  95 lines

  1. @ SYNTEX v2.0                                  @
  2. @ TPascal version 3 style example grammar      @
  3.  
  4. ';'= Semicolon.
  5. ','= Coma.
  6. '.'= Point.
  7. ':'= Colon.
  8. '..'= PointPoint.
  9. '^'= Hat.
  10.  
  11. '+'= Plus.
  12. '-'= Minus.
  13. '*'= Time.
  14. '/'= Divide.
  15.  
  16. '='= Equal.
  17. '<>'= Different.
  18. '<'= Inferior.
  19. '<='= InferiorOrEqual.
  20. '>'= Superior.
  21. '>='= SuperiorOrEqual.
  22.  
  23. '['= OpenBracket.
  24. ']'= CloseBracket.
  25. '('= OpenParenthesis.
  26. ')'= CloseParenthesis.
  27.  
  28. ':='= Becomes.
  29.  
  30. START= PROGRAM NAME ';' bloc '.'.
  31.   bloc=declarations compound_instruction.
  32.     declarations= constants_definition typse_definition vars_declaration
  33.                   procedures_or_functions_declaration.
  34.       compound_instruction= BEGIN instruction {';' instruction} END.
  35.         instruction= {instruction_simple | instruction_structured}.
  36.           instruction_simple= affectation | procedure_call.
  37.             affectation= access_variable ':=' expression | NAME ':=' expression.
  38.               access_variable= NAME | compound_variable | '^' variable_pointed.
  39.                 compound_variable= access_table | access_record.
  40.                   access_table= access_variable '[' expression { ',' expression} ']'.
  41.                   access_record= NAME '.' NAME | NAME.
  42.                 variable_pointed= access_variable.
  43.             procedure_call= NAME ['('parameter_actual {',' parameter_actual} ')'].
  44.               parameter_actual= access_variable | expression.
  45.           instruction_structured= instruction_composed | test | repetition | with.
  46.             suite_instruction= instruction {';' instruction}.
  47.             test= if | case.
  48.               if= IF expression THEN instruction [ELSE instruction].
  49.               case= CASE expression OF element_case {';' element_case}
  50.                     [ELSE suite_instruction] END.
  51.                 element_case= NOM ':' instruction.
  52.             repetition= while | repeat | for.
  53.               while= WHILE expression DO instruction.
  54.               repeat= REPEAT suite_instruction UNTIL expression.
  55.               for= FOR expression to_down_to expression DO instruction.
  56.                 to_down_to= TO | DOWNTO.
  57.             with= WITH access_variable {',' access_variable } DO instruction.
  58.  
  59.   expression= expression_simple [comparison expression_simple].
  60.     expression_simple= ['+'|'-'] term {'+' term | '-' term | OR term}.
  61.       term= factor {'*' factor | '/' factor | DIV factor | MOD factor | AND factor}.
  62.         factor= access_variable | NOT factor '(' expression ')' | factor_set.
  63.           factor_set= '[' [ element_set {',' element_set}] ']'.
  64.             element_set= expression ['..' expression].
  65.     comparison= '=' | '<>' | '<' | '>'.
  66.  
  67. constants_definition= [CONST constant_definition ';' {constant_definition ';'} ].
  68.   constant_definition= NAMM '=' CONSTANT.
  69.  
  70. types_definition= [TYPE type_definition ';' {type_definition ';'}].
  71.   type_definition= TYPE '=' type.
  72.     type= NAME | construction_of_type.
  73. construction_of_type= NAME | enumerated_interval | type_structured | type_pointer.
  74.   enumerated_interval= type_enumerated | type_interval.
  75.     type_enumerated= '(' list_of_names ')'.
  76.     type_interval= CONSTANT '..' CONSTANT.
  77.     type_structured= type_table | type_rec | type_set | type_file.
  78.       type_table= ARRAY '[' type_interval {',' type_interval }']' OF type.
  79.       type_rec= RECORD list_of_zones END.
  80.         list_of_zones= zones_common [';' zones_variable].
  81.           zones_common= zone {';' zone}.
  82.             zone= list_of_names '=' type.
  83.               list_of_names= NAME {',' NAME}.
  84.           zones_variable= NAME.
  85.       type_set= SET OF NAME.
  86.       type_file= FILE OF type.
  87.       type_pointer= '^' NAME.
  88.  
  89. vars_declaration= [VAR var_declaration_variable ';' {declaration_variable ';'}].
  90.   declaration_variable= list_of_names ':' type.
  91.  
  92. procedures_or_fonctions_declaration= {declaration_procedure ';'}.
  93.   declaration_procedure= PROCEDURE NAME [list_of_parameters_formal] bloc.
  94.     list_of_parameters_formal= '(' parameters_formal {';' parameters_formal} ')'.
  95.       parameters_formal= [VAR] list_of_names ':' NOM.