program.g 780 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* The grammar of ISO-Pascal as given by the specification, BS6192: 1982. */
  2. {
  3. #include <alloc.h>
  4. #include <em_arith.h>
  5. #include <em_label.h>
  6. #include "LLlex.h"
  7. #include "def.h"
  8. #include "main.h"
  9. #include "node.h"
  10. #include "scope.h"
  11. }
  12. %lexical LLlex;
  13. %start LLparse, Program;
  14. /* ISO section 6.10, p. 137 */
  15. Program
  16. {
  17. struct def *df;
  18. }:
  19. ProgramHeading(&df) ';' Block(df) '.'
  20. ;
  21. ProgramHeading(register struct def **df;):
  22. PROGRAM IDENT
  23. { program = *df = new_def();
  24. (*df)->df_idf = dot.TOK_IDF;
  25. (*df)->df_kind = D_PROGRAM;
  26. open_scope();
  27. GlobalScope = CurrentScope;
  28. (*df)->prc_vis = CurrVis;
  29. }
  30. [
  31. '('
  32. ProgramParameters
  33. ')'
  34. ]?
  35. ;
  36. ProgramParameters
  37. {
  38. struct node *Proglist;
  39. }:
  40. IdentifierList(&Proglist)
  41. { EnterProgList(Proglist); }
  42. ;