1 /*
2  * Copyright (c) 2017, NVIDIA CORPORATION.  All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 /** \file   scan.h
19     \brief  data declarations for those items which are set by
20             the scanner for use by the parser or semantic analyzer.
21 */
22 
23 typedef struct {
24   int stmtyp;
25   int currlab;
26   INT labno;
27   LOGICAL end_program_unit; /* end of program unit seen */
28   LOGICAL is_hpf;           /* true if current statement began with the
29                              * '!hpf$' prefix.
30                              */
31   LOGICAL multiple_stmts;   /* stmts separated by ';' */
32   char *directive;          /* malloc'd area containing a directive string
33                              * to be passed thru as a comment string.  The
34                              * string includes the the necessary prefix.
35                              */
36   char *options;            /* malloc'd area containing the string after
37                              * 'options' in the options statement.
38                              */
39   struct {
40     char *name;
41     int avl;
42     int size;
43   } id;
44 } SCN;
45 
46 /* File Records:
47  *
48  * Each record in the ast source file (astb.astfil) begins with a
49  * 4-byte type field.  In most cases, the remaining portion of the
50  * field is textual information in the form of a line (terminated by
51  * '\n'.
52  */
53 typedef enum {
54   FR_SRC = -1,
55   FR_B_INCL = -2,
56   FR_E_INCL = -3,
57   FR_END = -4,
58   FR_LINENO = -5,
59   FR_PRAGMA = -6,
60   FR_STMT = -7,
61   FR_B_HDR = -8,
62   FR_E_HDR = -9,
63   FR_LABEL = -98,
64   FR_TOKEN = -99
65 } FR_TYPE;
66 
67 extern SCN scn;
68 
69 void scan_init(FILE *);
70 void scan_reset(void);
71 void scan_fini(void);
72 int get_token(INT *);
73 void scan_include(char *);
74 void scan_opt_restore(void);
75 int get_named_stmtyp(void);
76 int getCurrColumn(void);
77 void scan_options(void);
78 void fe_save_state(void);
79 void fe_init(void);
80 void fe_restart(void);
81 char * get_src_line(int line, char **src_file, int col, int *srcCol,
82                     int *contNo);
83 
84 LOGICAL is_executable(int); /* parser.c */
85 void parser(void);          /* parser.c */
86