2 #define P1_COMMENT 1 /* Fortan comment string */
3 #define P1_EOF 2 /* End of file dummy token */
4 #define P1_SET_LINE 3 /* Reset the line counter */
5 #define P1_FILENAME 4 /* Name of current input file */
6 #define P1_NAME_POINTER 5 /* Pointer to hash table entry */
7 #define P1_CONST 6 /* Some constant value */
8 #define P1_EXPR 7 /* Followed by opcode */
10 /* The next two tokens could be grouped together, since they always come
11 from an Addr structure */
13 #define P1_IDENT 8 /* Char string identifier in addrp->user
15 #define P1_EXTERN 9 /* Pointer to external symbol entry */
17 #define P1_HEAD 10 /* Function header info */
18 #define P1_LIST 11 /* A list of data (e.g. arguments) will
19 follow the tag, type, and count */
20 #define P1_LITERAL 12 /* Hold the index into the literal pool */
21 #define P1_LABEL 13 /* label value */
22 #define P1_ASGOTO 14 /* Store the hash table pointer of
23 variable used in assigned goto */
24 #define P1_GOTO 15 /* Store the statement number */
25 #define P1_IF 16 /* store the condition as an expression */
26 #define P1_ELSE 17 /* No data */
27 #define P1_ELIF 18 /* store the condition as an expression */
28 #define P1_ENDIF 19 /* Marks the end of a block IF */
29 #define P1_ENDELSE 20 /* Marks the end of a block ELSE */
30 #define P1_ADDR 21 /* Addr data; used for arrays, common and
31 equiv addressing, NOT for names, idents
33 #define P1_SUBR_RET 22 /* Subroutine return; the return expression
35 #define P1_COMP_GOTO 23 /* Computed goto; has expr, label list */
36 #define P1_FOR 24 /* C FOR loop; three expressions follow */
37 #define P1_ENDFOR 25 /* End of C FOR loop */
38 #define P1_FORTRAN 26 /* original Fortran source */
39 #define P1_CHARP 27 /* user.Charp field -- for long names */
40 #define P1_WHILE1START 28 /* start of DO WHILE */
41 #define P1_WHILE2START 29 /* rest of DO WHILE */
42 #define P1_PROCODE 30 /* invoke procode() -- to adjust params */
44 #define P1_FILENAME_MAX 256 /* max filename length to retain (for -g) */
45 #define P1_STMTBUFSIZE 1400
49 #define COMMENT_BUFFER_SIZE 255 /* max number of chars in each comment */
50 #define CONSTANT_STR_MAX 1000 /* max number of chars in string constant */
52 extern void p1put (/* int */);
53 extern void p1_comment (/* char * */);
54 extern void p1_label (/* int */);
55 extern void p1_line_number (/* int */);
56 extern void p1put_filename();
57 extern void p1_expr (/* expptr */);
58 extern void p1_head (/* int, char * */);
59 extern void p1_if (/* expptr */);
60 extern void p1_else ();
61 extern void p1_elif (/* expptr */);
62 extern void p1_endif ();
63 extern void p1else_end ();
64 extern void p1_subr_ret (/* expptr */);
65 extern void p1_goto(/* long */);
66 extern void p1comp_goto (/* expptr, int, struct Labelblock *[] */);
67 extern void p1_for (/* expptr, expptr, expptr */);
68 extern void p1for_end ();
71 extern void p1puts (/* int, char * */);
73 /* The pass 1 intermediate file has the following format:
75 <ascii-integer-rep> [ : [ <sp> [ <data> ]]] \n
77 e.g. 1: This is a comment
79 This format is destined to change in the future, but for now a readable
80 form is more desirable than a compact form.
82 NOTES ABOUT THE P1 FORMAT
83 ----------------------------------------------------------------------
85 P1_COMMENT: The comment string (in <data>) may be at most
86 COMMENT_BUFFER_SIZE bytes long. It must contain no newlines
87 or null characters. A side effect of the way comments are
88 read in lex.c is that no '\377' chars may be in a
91 P1_SET_LINE: <data> holds the line number in the current source file.
93 P1_INC_LINE: Increment the source line number; <data> is empty.
95 P1_NAME_POINTER: <data> holds the integer representation of a
96 pointer into a hash table entry.
98 P1_CONST: the first field in <data> is a type tag (one of the
99 TYxxxx macros), the next field holds the constant
102 P1_EXPR: <data> holds the opcode number of the expression,
103 followed by the type of the expression (required for
104 OPCONV). Next is the value of vleng.
105 The type of operation represented by the
106 opcode determines how many of the following data items
107 are part of this expression.
109 P1_IDENT: <data> holds the type, then storage, then the
110 char string identifier in the addrp->user field.
112 P1_EXTERN: <data> holds an offset into the external symbol
115 P1_HEAD: the first field in <data> is the procedure class, the
116 second is the name of the procedure
118 P1_LIST: the first field in <data> is the tag, the second the
119 type of the list, the third the number of elements in
122 P1_LITERAL: <data> holds the litnum of a value in the
125 P1_LABEL: <data> holds the statement number of the current
128 P1_ASGOTO: <data> holds the hash table pointer of the variable
130 P1_GOTO: <data> holds the statement number to jump to
132 P1_IF: <data> is empty, the following expression is the IF
135 P1_ELSE: <data> is empty.
137 P1_ELIF: <data> is empty, the following expression is the IF
140 P1_ENDIF: <data> is empty.
142 P1_ENDELSE: <data> is empty.
144 P1_ADDR: <data> holds a direct copy of the structure. The
145 next expression is a copy of vleng, and the next a
148 P1_SUBR_RET: The next token is an expression for the return value.
150 P1_COMP_GOTO: The next token is an integer expression, the
151 following one a list of labels.
153 P1_FOR: The next three expressions are the Init, Test, and
154 Increment expressions of a C FOR loop.
156 P1_ENDFOR: Marks the end of the body of a FOR loop