1988-10-26 15:21:11 +00:00
|
|
|
/* The grammar of ISO-Pascal as given by the specification, BS6192: 1982. */
|
|
|
|
|
|
|
|
{
|
2013-05-14 19:47:04 +00:00
|
|
|
#include "parameters.h"
|
1988-10-26 15:21:11 +00:00
|
|
|
#include <alloc.h>
|
|
|
|
#include <em_arith.h>
|
|
|
|
#include <em_label.h>
|
1990-12-11 13:52:08 +00:00
|
|
|
#include <em_code.h>
|
|
|
|
#include <stb.h>
|
1988-10-26 15:21:11 +00:00
|
|
|
|
|
|
|
#include "LLlex.h"
|
|
|
|
#include "def.h"
|
1989-05-03 10:30:22 +00:00
|
|
|
#include "f_info.h"
|
|
|
|
#include "idf.h"
|
1988-10-26 15:21:11 +00:00
|
|
|
#include "main.h"
|
|
|
|
#include "node.h"
|
|
|
|
#include "scope.h"
|
2019-02-23 16:44:50 +00:00
|
|
|
#include "enter.h"
|
|
|
|
#include "progs.h"
|
|
|
|
#ifdef DBSYMTAB
|
|
|
|
#include "stab.h"
|
|
|
|
#endif
|
1988-10-26 15:21:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
%lexical LLlex;
|
|
|
|
|
|
|
|
%start LLparse, Program;
|
|
|
|
|
|
|
|
/* ISO section 6.10, p. 137 */
|
|
|
|
Program
|
|
|
|
{
|
|
|
|
struct def *df;
|
1989-05-03 10:30:22 +00:00
|
|
|
arith dummy;
|
1988-10-26 15:21:11 +00:00
|
|
|
}:
|
1990-12-11 13:52:08 +00:00
|
|
|
ProgramHeading(&df)
|
|
|
|
';' Block(df) '.'
|
1991-02-15 18:00:26 +00:00
|
|
|
{
|
|
|
|
#ifdef DBSYMTAB
|
|
|
|
if (options['g']) {
|
1990-12-11 13:52:08 +00:00
|
|
|
C_ms_stb_cst(df->df_idf->id_text, N_MAIN, 0, (arith) 0);
|
|
|
|
stb_string(df, D_END);
|
|
|
|
}
|
1991-02-15 18:00:26 +00:00
|
|
|
#endif /* DBSYMTAB */
|
1990-12-11 13:52:08 +00:00
|
|
|
}
|
1989-05-03 10:30:22 +00:00
|
|
|
| { df = new_def();
|
|
|
|
df->df_idf = str2idf(FileName, 1);
|
|
|
|
df->df_kind = D_MODULE;
|
|
|
|
open_scope();
|
|
|
|
GlobalScope = CurrentScope;
|
|
|
|
df->prc_vis = CurrVis;
|
|
|
|
}
|
|
|
|
|
|
|
|
Module(df, &dummy)
|
1988-10-26 15:21:11 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
ProgramHeading(register struct def **df;):
|
|
|
|
PROGRAM IDENT
|
|
|
|
{ program = *df = new_def();
|
|
|
|
(*df)->df_idf = dot.TOK_IDF;
|
|
|
|
(*df)->df_kind = D_PROGRAM;
|
|
|
|
open_scope();
|
|
|
|
GlobalScope = CurrentScope;
|
|
|
|
(*df)->prc_vis = CurrVis;
|
1991-02-15 18:00:26 +00:00
|
|
|
#ifdef DBSYMTAB
|
1990-12-11 13:52:08 +00:00
|
|
|
if (options['g']) stb_string(*df, D_MODULE);
|
1991-02-15 18:00:26 +00:00
|
|
|
#endif /* DBSYMTAB */
|
1988-10-26 15:21:11 +00:00
|
|
|
}
|
|
|
|
[
|
|
|
|
'('
|
|
|
|
ProgramParameters
|
|
|
|
')'
|
1989-05-03 10:30:22 +00:00
|
|
|
{ make_extfl(); }
|
1988-10-26 15:21:11 +00:00
|
|
|
]?
|
|
|
|
;
|
|
|
|
|
|
|
|
ProgramParameters
|
|
|
|
{
|
|
|
|
struct node *Proglist;
|
|
|
|
}:
|
|
|
|
IdentifierList(&Proglist)
|
|
|
|
{ EnterProgList(Proglist); }
|
|
|
|
;
|