PIPS
|
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <ctype.h>
#include "genC.h"
#include "linear.h"
#include "ri.h"
#include "ri-util.h"
#include "misc.h"
#include "c_syntax.h"
#include "cyacc.h"
#include <unistd.h>
Go to the source code of this file.
Data Structures | |
struct | yy_buffer_state |
struct | yy_trans_info |
This struct is not used in this scanner, but its presence is necessary. More... | |
Macros | |
#define | YY_INT_ALIGNED short int |
#define | yy_create_buffer c__create_buffer |
A lexical scanner generated by flex. More... | |
#define | yy_delete_buffer c__delete_buffer |
#define | yy_scan_buffer c__scan_buffer |
#define | yy_scan_string c__scan_string |
#define | yy_scan_bytes c__scan_bytes |
#define | yy_init_buffer c__init_buffer |
#define | yy_flush_buffer c__flush_buffer |
#define | yy_load_buffer_state c__load_buffer_state |
#define | yy_switch_to_buffer c__switch_to_buffer |
#define | yypush_buffer_state c_push_buffer_state |
#define | yypop_buffer_state c_pop_buffer_state |
#define | yyensure_buffer_stack c_ensure_buffer_stack |
#define | yy_flex_debug c__flex_debug |
#define | yyin c_in |
#define | yyleng c_leng |
#define | yylex c_lex |
#define | yylineno c_lineno |
#define | yyout c_out |
#define | yyrestart c_restart |
#define | yytext c_text |
#define | yywrap(void) c_wrap |
Macros after this point can all be overridden by user definitions in section 1. More... | |
#define | yyalloc c_alloc |
#define | yyrealloc c_realloc |
#define | yyfree c_free |
#define | FLEX_SCANNER |
#define | YY_FLEX_MAJOR_VERSION 2 |
#define | YY_FLEX_MINOR_VERSION 6 |
#define | YY_FLEX_SUBMINOR_VERSION 4 |
#define | FLEX_BETA |
#define | c__create_buffer_ALREADY_DEFINED |
#define | c__delete_buffer_ALREADY_DEFINED |
#define | c__scan_buffer_ALREADY_DEFINED |
#define | c__scan_string_ALREADY_DEFINED |
#define | c__scan_bytes_ALREADY_DEFINED |
#define | c__init_buffer_ALREADY_DEFINED |
#define | c__flush_buffer_ALREADY_DEFINED |
#define | c__load_buffer_state_ALREADY_DEFINED |
#define | c__switch_to_buffer_ALREADY_DEFINED |
#define | c_push_buffer_state_ALREADY_DEFINED |
#define | c_pop_buffer_state_ALREADY_DEFINED |
#define | c_ensure_buffer_stack_ALREADY_DEFINED |
#define | c_lex_ALREADY_DEFINED |
#define | c_restart_ALREADY_DEFINED |
#define | yylex_init c_lex_init |
#define | yylex_init_extra c_lex_init_extra |
#define | yylex_destroy(void) c_lex_destroy |
Accessor methods to globals. More... | |
#define | yyget_debug c_get_debug |
#define | yyset_debug c_set_debug |
#define | yyget_extra c_get_extra |
#define | yyset_extra c_set_extra |
#define | yyget_in c_get_in |
#define | yyset_in c_set_in |
#define | yyget_out c_get_out |
#define | yyset_out c_set_out |
#define | yyget_leng c_get_leng |
#define | yyget_text c_get_text |
#define | yyget_lineno c_get_lineno |
#define | yyset_lineno c_set_lineno |
#define | c_wrap_ALREADY_DEFINED |
#define | c_alloc_ALREADY_DEFINED |
#define | c_realloc_ALREADY_DEFINED |
#define | c_free_ALREADY_DEFINED |
#define | c_text_ALREADY_DEFINED |
#define | c_leng_ALREADY_DEFINED |
#define | c_in_ALREADY_DEFINED |
#define | c_out_ALREADY_DEFINED |
#define | c__flex_debug_ALREADY_DEFINED |
#define | c_lineno_ALREADY_DEFINED |
#define | FLEXINT_H |
First, we deal with platform-specific or compiler-specific issues. More... | |
#define | INT8_MIN (-128) |
Limits of integral types. More... | |
#define | INT16_MIN (-32767-1) |
#define | INT32_MIN (-2147483647-1) |
#define | INT8_MAX (127) |
#define | INT16_MAX (32767) |
#define | INT32_MAX (2147483647) |
#define | UINT8_MAX (255U) |
#define | UINT16_MAX (65535U) |
#define | UINT32_MAX (4294967295U) |
#define | SIZE_MAX (~(size_t)0) |
#define | yyconst const |
! C99 More... | |
#define | yynoreturn |
#define | YY_NULL 0 |
Returned upon end-of-file. More... | |
#define | YY_SC_TO_UI(c) ((YY_CHAR) (c)) |
Promotes a possibly negative, possibly signed char to an integer in range [0..255] for use as an array index. More... | |
#define | BEGIN (yy_start) = 1 + 2 * |
Enter a start condition. More... | |
#define | YY_START (((yy_start) - 1) / 2) |
Translate the current start state into a value that can be later handed to BEGIN to return to the state. More... | |
#define | YYSTATE YY_START |
#define | YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) |
Action number for EOF rule of a given start state. More... | |
#define | YY_NEW_FILE yyrestart( yyin ) |
Special action meaning "start processing a new file". More... | |
#define | YY_END_OF_BUFFER_CHAR 0 |
#define | YY_BUF_SIZE 16384 |
Size of default input buffer. More... | |
#define | YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) |
ia64 More... | |
#define | YY_TYPEDEF_YY_BUFFER_STATE |
#define | YY_TYPEDEF_YY_SIZE_T |
#define | EOB_ACT_CONTINUE_SCAN 0 |
#define | EOB_ACT_END_OF_FILE 1 |
#define | EOB_ACT_LAST_MATCH 2 |
#define | YY_LESS_LINENO(n) |
Note: We specifically omit the test for yy_rule_can_match_eol because it requires access to the local variable yy_act. More... | |
#define | YY_LINENO_REWIND_TO(dst) |
#define | yyless(n) |
Return all but the first "n" matched characters back to the input stream. More... | |
#define | unput(c) yyunput( c, (yytext_ptr) ) |
#define | YY_STRUCT_YY_BUFFER_STATE |
#define | YY_BUFFER_NEW 0 |
#define | YY_BUFFER_NORMAL 1 |
#define | YY_BUFFER_EOF_PENDING 2 |
When an EOF's been seen but there's still some text to process then we mark the buffer as YY_EOF_PENDING, to indicate that we shouldn't try reading from the input source any more. More... | |
#define | YY_CURRENT_BUFFER |
We provide macros for accessing buffer states in case in the future we want to put the buffer states in a more general "scanner state". More... | |
#define | YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] |
Same as previous macro, but useful when we know that the buffer stack is not NULL or when we need an lvalue. More... | |
#define | YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER ) |
#define | yy_new_buffer yy_create_buffer |
#define | yy_set_interactive(is_interactive) |
#define | yy_set_bol(at_bol) |
#define | YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) |
#define | yytext_ptr yytext |
#define | YY_DO_BEFORE_ACTION |
Done after the current pattern has been matched and before the corresponding action - sets up yytext. More... | |
#define | YY_NUM_RULES 73 |
#define | YY_END_OF_BUFFER 74 |
#define | REJECT reject_used_but_not_detected |
The intent behind this definition is that it'll catch any uses of REJECT which flex missed. More... | |
#define | yymore() yymore_used_but_not_detected |
#define | YY_MORE_ADJ 0 |
#define | YY_RESTORE_YY_MORE_OFFSET |
#define | YY_NO_INPUT 1 |
#define | TOKEN_UNDEFINED (-1) |
The lexer cannot handle the ambiguity between named types and variables without extra-help. More... | |
#define | LEXER_RETURN(t) |
This is going to be the previous token because LEXER_RETURN is not used in case the lexer handles either a named type or a variable. More... | |
#define | SIMPLE_LEXER_RETURN(t) |
Some tokens, such as { and } do not mean that a statement has been entered. More... | |
#define | TK_TYPE_P(tk) |
#define | INITIAL 0 |
This should be used instead of the manual computation of C_line_number... More... | |
#define | the_end_of_pragma 1 |
#define | YY_EXTRA_TYPE void * |
Special case for "unistd.h", since it is non-ANSI. More... | |
#define | YY_READ_BUF_SIZE 8192 |
Amount of stuff to slurp up with each read. More... | |
#define | ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) |
ia64 More... | |
#define | YY_INPUT(buf, result, max_size) |
Gets input and stuffs it into "buf". More... | |
#define | yyterminate() return YY_NULL |
No semi-colon after return; correct usage is to write "yyterminate();" - we don't want an extra ';' after the "return" because that will cause some compilers to complain about unreachable statements. More... | |
#define | YY_START_STACK_INCR 25 |
Number of entries by which start-condition stack grows. More... | |
#define | YY_FATAL_ERROR(msg) yy_fatal_error( msg ) |
Report a fatal error. More... | |
#define | YY_DECL_IS_OURS 1 |
end tables serialization structures and prototypes More... | |
#define | YY_DECL int yylex (void) |
#define | YY_USER_ACTION |
!YY_DECL More... | |
#define | YY_BREAK /**INTED*/break; |
Code executed at the end of each rule. More... | |
#define | YY_RULE_SETUP |
#define | YY_EXIT_FAILURE 2 |
#define | yyless(n) |
Return all but the first "n" matched characters back to the input stream. More... | |
#define | YYTABLES_NAME "yytables" |
Typedefs | |
typedef signed char | flex_int8_t |
C99 systems have <inttypes.h>. More... | |
typedef short int | flex_int16_t |
typedef int | flex_int32_t |
typedef unsigned char | flex_uint8_t |
typedef unsigned short int | flex_uint16_t |
typedef unsigned int | flex_uint32_t |
typedef struct yy_buffer_state * | YY_BUFFER_STATE |
typedef size_t | yy_size_t |
typedef flex_uint8_t | YY_CHAR |
Begin user sect3. More... | |
typedef int | yy_state_type |
Functions | |
void | yyrestart (FILE *input_file) |
void | yy_switch_to_buffer (YY_BUFFER_STATE new_buffer) |
YY_BUFFER_STATE | yy_create_buffer (FILE *file, int size) |
void | yy_delete_buffer (YY_BUFFER_STATE b) |
void | yy_flush_buffer (YY_BUFFER_STATE b) |
void | yypush_buffer_state (YY_BUFFER_STATE new_buffer) |
static void | yy_init_buffer (YY_BUFFER_STATE b, FILE *file) |
YY_BUFFER_STATE | yy_scan_buffer (char *base, yy_size_t size) |
YY_BUFFER_STATE | yy_scan_string (const char *yy_str) |
YY_BUFFER_STATE | yy_scan_bytes (const char *bytes, int len) |
void * | yyalloc (yy_size_t) |
void * | yyrealloc (void *, yy_size_t) |
void | yyfree (void *) |
static yy_state_type | yy_get_previous_state (void) |
static yy_state_type | yy_try_NUL_trans (yy_state_type current_state) |
static int | yy_get_next_buffer (void) |
static void yynoreturn | yy_fatal_error (const char *msg) |
int | get_previous_c_lineno () |
unsigned int | character_occurences_in_string (string s, char c) |
Use a stack to survive to file inclusions if any. More... | |
int | get_current_C_line_number (void) |
int | get_previous_C_line_number (void) |
Should be called just before get_current_C_line_number. More... | |
void | set_current_C_line_number (void) |
void | push_current_C_line_number (void) |
The line number stack, designed for structured control structure, is not used yet. More... | |
int | pop_current_C_line_number (void) |
void | reset_current_C_line_number (void) |
void | error_reset_current_C_line_number (void) |
void | reset_token_has_been_seen_p () |
string | get_current_C_comment (void) |
Return the current comment as a string to be freed by the caller and reset the current comment. More... | |
void | push_current_C_comment (void) |
Push the current C comment so that we can get it back when building the statement later. More... | |
string | pop_current_C_comment (void) |
Pop the current comment. More... | |
void | update_C_comment (string a_comment) |
Add a comment to the current one. More... | |
void | remove_LFs_from_C_comment (int extra_LF) |
Remove "extra_LF" trailing LF from C_current_comment if they can be found at the end of the comment string. More... | |
void | discard_C_comment () |
Discard a C comment because we don't know how to deal with it. More... | |
void | reset_C_comment (bool is_compilation_unit_p) |
reset and reset_error should be handled differently More... | |
void | error_reset_C_comment (bool is_compilation_unit_p __attribute__((__unused__))) |
void | clear_C_comment () |
void | init_C_comment () |
static void | bsd_rewrite (char **pyytext) |
compatibility layer for BSD More... | |
static int | is_c_parser_keyword_typedef (char *id) |
See if id is a keyword, a typedef or an identifier. More... | |
static int | yy_init_globals (void) |
void | yyset_debug (int debug_flag) |
void | yyset_extra (YY_EXTRA_TYPE user_defined) |
void | yyset_in (FILE *_in_str) |
void | yyset_out (FILE *_out_str) |
void | yyset_lineno (int _line_number) |
if (!(yy_init)) | |
Variables | |
int | yyleng |
number of characters read into yy_ch_buf More... | |
FILE * | yyin |
FILE * | yyout |
static size_t | yy_buffer_stack_top = 0 |
!YY_STRUCT_YY_BUFFER_STATE More... | |
static size_t | yy_buffer_stack_max = 0 |
capacity of stack. More... | |
static YY_BUFFER_STATE * | yy_buffer_stack = NULL |
Stack as an array. More... | |
static char | yy_hold_char |
yy_hold_char holds the character lost when yytext is formed. More... | |
static int | yy_n_chars |
static char * | yy_c_buf_p = NULL |
Points to current character in buffer. More... | |
static int | yy_init = 0 |
static int | yy_start = 0 |
whether we need to initialize More... | |
static int | yy_did_buffer_switch_on_eof |
start state number More... | |
int | yylineno = 1 |
Begin user sect3. More... | |
char * | yytext |
static const flex_int16_t | yy_accept [282] |
static const YY_CHAR | yy_ec [256] |
static const YY_CHAR | yy_meta [65] |
static const flex_int16_t | yy_base [329] |
static const flex_int16_t | yy_def [329] |
static const flex_int16_t | yy_nxt [903] |
static const flex_int16_t | yy_chk [903] |
static const flex_int32_t | yy_rule_can_match_eol [74] |
Table of booleans, true if rule could match eol. More... | |
static yy_state_type | yy_last_accepting_state |
static char * | yy_last_accepting_cpos |
int | yy_flex_debug = 0 |
static int | C_line_number = UNDEFINED_C_LINE_NUMBER |
To track the user line number, that is the one in the original user file. More... | |
int | C_line_increment = 1 |
The line increment is set to zero when header files are parsed. More... | |
static int | previous_c_lineno = UNDEFINED_C_LINE_NUMBER |
To keep track of line intervals. More... | |
static int | previous_C_line_number = UNDEFINED_C_LINE_NUMBER |
static string | C_current_comment = string_undefined |
Comment management: More... | |
static bool | token_has_been_seen_p = false |
To see if comments are collected within a statement or outside it is pretty easy to turn it on. More... | |
static int | bracket_depth = -1 |
static int | previous_keyword_token = TOKEN_UNDEFINED |
YY_DECL | |
The main scanner function which does all the work. More... | |
char * | yy_cp |
char * | yy_bp |
int | yy_act |
#define BEGIN (yy_start) = 1 + 2 * |
#define FLEXINT_H |
#define INITIAL 0 |
This should be used instead of the manual computation of C_line_number...
but C_line_number is adjusted according to the preprocessor line pragmas. To deal more cleanly with the comments: x COMMENT To deal cleanly with complex pragma line escape, use a separate state: From C norm A.1: "
#define LEXER_RETURN | ( | t | ) |
This is going to be the previous token because LEXER_RETURN is not used in case the lexer handles either a named type or a variable.
#define REJECT reject_used_but_not_detected |
#define SIMPLE_LEXER_RETURN | ( | t | ) |
Some tokens, such as { and } do not mean that a statement has been entered.
#define TK_TYPE_P | ( | tk | ) |
#define TOKEN_UNDEFINED (-1) |
The lexer cannot handle the ambiguity between named types and variables without extra-help.
This piece of code is copied from preprocessor/lexer.l.
#define unput | ( | c | ) | yyunput( c, (yytext_ptr) ) |
#define YY_AT_BOL | ( | ) | (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) |
#define YY_BREAK /**INTED*/break; |
#define YY_BUFFER_EOF_PENDING 2 |
When an EOF's been seen but there's still some text to process then we mark the buffer as YY_EOF_PENDING, to indicate that we shouldn't try reading from the input source any more.
We might still have a bunch of tokens to match, though, because of possible backing-up.
When we actually see the EOF, we change the status to "new" (via yyrestart()), so that the user can continue scanning by just pointing yyin at a new input file.
#define yy_create_buffer c__create_buffer |
#define YY_CURRENT_BUFFER |
We provide macros for accessing buffer states in case in the future we want to put the buffer states in a more general "scanner state".
Returns the top of the stack, or NULL.
#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] |
#define YY_DECL_IS_OURS 1 |
#define YY_DO_BEFORE_ACTION |
Done after the current pattern has been matched and before the corresponding action - sets up yytext.
#define YY_EXIT_FAILURE 2 |
#define YY_EXTRA_TYPE void * |
#define YY_FATAL_ERROR | ( | msg | ) | yy_fatal_error( msg ) |
#define yy_flex_debug c__flex_debug |
#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER ) |
#define YY_INPUT | ( | buf, | |
result, | |||
max_size | |||
) |
Gets input and stuffs it into "buf".
number of characters read, or YY_NULL, is returned in "result".
#define YY_LESS_LINENO | ( | n | ) |
Note: We specifically omit the test for yy_rule_can_match_eol because it requires access to the local variable yy_act.
Since yyless() is a macro, it would break existing scanners that call yyless() from OUTSIDE yylex. One obvious solution it to make yy_act a global. I tried that, and saw a 5% performance hit in a non-yylineno scanner, because yy_act is normally declared as a register variable– so it is not worth it.
#define YY_LINENO_REWIND_TO | ( | dst | ) |
#define yy_load_buffer_state | ( | void | ) | c__load_buffer_state |
#define yy_new_buffer yy_create_buffer |
#define YY_NO_INPUT 1 |
#define YY_READ_BUF_SIZE 8192 |
#define YY_RULE_SETUP |
#define YY_SC_TO_UI | ( | c | ) | ((YY_CHAR) (c)) |
#define yy_set_bol | ( | at_bol | ) |
#define yy_set_interactive | ( | is_interactive | ) |
#define YY_START (((yy_start) - 1) / 2) |
#define YY_START_STACK_INCR 25 |
#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) |
#define YY_STATE_EOF | ( | state | ) | (YY_END_OF_BUFFER + state + 1) |
#define YY_USER_ACTION |
#define yyconst const |
#define yyensure_buffer_stack | ( | void | ) | c_ensure_buffer_stack |
#define yyget_debug | ( | void | ) | c_get_debug |
#define yyget_leng | ( | void | ) | c_get_leng |
#define yyget_lineno | ( | void | ) | c_get_lineno |
#define yyget_text | ( | void | ) | c_get_text |
#define yyless | ( | n | ) |
Return all but the first "n" matched characters back to the input stream.
#define yyless | ( | n | ) |
Return all but the first "n" matched characters back to the input stream.
#define yylex_destroy | ( | void | ) | c_lex_destroy |
#define yypop_buffer_state | ( | void | ) | c_pop_buffer_state |
#define yyset_debug c_set_debug |
#define yyset_lineno c_set_lineno |
#define YYTABLES_NAME "yytables" |
#define yywrap | ( | void | ) | c_wrap |
typedef short int flex_int16_t |
typedef int flex_int32_t |
typedef signed char flex_int8_t |
typedef unsigned short int flex_uint16_t |
typedef unsigned int flex_uint32_t |
typedef unsigned char flex_uint8_t |
typedef struct yy_buffer_state* YY_BUFFER_STATE |
typedef flex_uint8_t YY_CHAR |
typedef int yy_state_type |
|
static |
compatibility layer for BSD
Definition at line 1527 of file clexer.c.
References aliases, and same_string_p.
Use a stack to survive to file inclusions if any.
I guess that it is currently not used since file inclusion is already done by the preprocessor... RK To track the absolute line number in the file that is parsed use the default flex yylineno that is renamed c_lineno here Use a stack to survive to file inclusions if any Count the number of c in s.
Definition at line 1133 of file clexer.c.
References count, and string_undefined.
Referenced by discard_C_comment().
void clear_C_comment | ( | void | ) |
Comments in the compilation unit and outside of function bodies are lost because they are related only to declarations and because comments on declarations are lost.
Definition at line 1489 of file clexer.c.
References C_current_comment, count, free(), pips_assert, pips_debug, string_undefined, and string_undefined_p.
Referenced by error_reset_C_comment(), and reset_C_comment().
void discard_C_comment | ( | void | ) |
Discard a C comment because we don't know how to deal with it.
The comments are only made of '
', just silently discarding them
Definition at line 1426 of file clexer.c.
References C_current_comment, C_line_number, character_occurences_in_string(), free(), pips_debug, string_undefined, and string_undefined_p.
Referenced by MakeBlock().
void error_reset_C_comment | ( | bool is_compilation_unit_p | __attribute__(__unused__) | ) |
Definition at line 1477 of file clexer.c.
References bracket_depth, C_current_comment, clear_C_comment(), free(), string_undefined, string_undefined_p, and token_has_been_seen_p.
void error_reset_current_C_line_number | ( | void | ) |
Definition at line 1224 of file clexer.c.
References C_line_number, c_lineno, FIRST_C_LINE_NUMBER, previous_C_line_number, previous_c_lineno, and UNDEFINED_C_LINE_NUMBER.
Referenced by c_parser_error().
string get_current_C_comment | ( | void | ) |
Return the current comment as a string to be freed by the caller and reset the current comment.
If the current comment is undefined, returns a copy of the empty string, "".
Reset also the current comment.
If the comment begins with a new-line, it is indeed the new-line that ends the previous statement, so skip it. Quicker than strlen()
Note there won't be a memory leak since the orginal '\0' is in the malloc() bloc to be free()ed anyway...
If the comment is only an empty one, do not retain it:
Do retain it to keep the statement data structure easy to use, allowing strdup() on its text fields
Remove the trailing new-line if any since the RI is already line-oriented at the comment level: This is already done above.
It is a trailing new-line: just get rid of it:
pips_debug(3, "get_current_C_comment comment \"s"
", cc);
Definition at line 1282 of file clexer.c.
References C_current_comment, strdup(), and string_undefined.
Referenced by ExpressionToStatement(), MakeCaseStatement(), MakeDefaultStatement(), MakeGotoStatement(), and push_current_C_comment().
int get_current_C_line_number | ( | void | ) |
FI: I assume that get_current_C_line_number is called only by some kind of make_statement()
The PIPS preprocessed C function files contain a specific first line to convert the line number in the workspace unto a line number in the user source file.
Definition at line 1146 of file clexer.c.
References C_line_number, c_lineno, previous_C_line_number, and previous_c_lineno.
Referenced by c_parser_error(), c_parser_user_warning_alist(), ExpressionToStatement(), FindEntityFromLocalNameAndPrefix(), MakeForloop(), MakeGotoStatement(), MakeWhileLoop(), pop_current_C_comment(), push_current_C_comment(), and push_current_C_line_number().
int get_previous_C_line_number | ( | void | ) |
Should be called just before get_current_C_line_number.
Definition at line 1161 of file clexer.c.
References previous_C_line_number.
Referenced by c_parser_user_warning_alist().
int get_previous_c_lineno | ( | void | ) |
Definition at line 1115 of file clexer.c.
References previous_c_lineno.
Referenced by c_parser_user_warning_alist().
if | ( | ! | yy_init | ) |
first start state
Definition at line 1834 of file clexer.c.
References YY_BUF_SIZE, yy_create_buffer, YY_CURRENT_BUFFER, YY_CURRENT_BUFFER_LVALUE, yy_init, yy_load_buffer_state, yy_start, yyensure_buffer_stack, yyin, and yyout.
void init_C_comment | ( | void | ) |
Definition at line 1513 of file clexer.c.
References bracket_depth, C_current_comment, pips_internal_error, STACK_NULL_P, stack_undefined_p, string_undefined_p, and token_has_been_seen_p.
Referenced by actual_c_parser().
|
static |
See if id is a keyword, a typedef or an identifier.
Returns the token number for keywords and typedefs. Returns 0 for variable identifiers.
The new typedefs are stored by c_parser_put_new_typedef().
No need to bother for scopes when dealing with C keywords, but do not take into account top-level typedefs which may be masked.
Check again for a global typedef
Definition at line 1573 of file clexer.c.
References bracket_depth, c_parser_number_of_scopes(), concatenate(), fprintf(), free(), get_c_parser_current_scope(), get_c_parser_nth_scope(), ifdebug, is_c_keyword_typedef(), pips_debug, previous_keyword_token, strdup(), TK_NAMED_TYPE, TK_STATIC, TK_STATIC_DIMENSION, TK_TYPE_P, and token_has_been_seen_p.
string pop_current_C_comment | ( | void | ) |
Pop the current comment.
This is typically used at the end of a statement to be built.
Note this do not set the current comment. Strange API...
Definition at line 1352 of file clexer.c.
References get_current_C_line_number(), pips_debug, and string_undefined_p.
Referenced by MakeForloop().
int pop_current_C_line_number | ( | void | ) |
Definition at line 1202 of file clexer.c.
References c_lineno.
Referenced by MakeForloop().
void push_current_C_comment | ( | void | ) |
Push the current C comment so that we can get it back when building the statement later.
This reset the current comment through get_current_C_comment()
Definition at line 1331 of file clexer.c.
References get_current_C_comment(), get_current_C_line_number(), pips_debug, and string_undefined_p.
void push_current_C_line_number | ( | void | ) |
The line number stack, designed for structured control structure, is not used yet.
Definition at line 1194 of file clexer.c.
References c_lineno, and get_current_C_line_number().
void remove_LFs_from_C_comment | ( | int | extra_LF | ) |
Remove "extra_LF" trailing LF from C_current_comment if they can be found at the end of the comment string.
extra_LF | xtra_LF |
Definition at line 1398 of file clexer.c.
References C_current_comment, pips_debug, pips_user_warning, string_undefined, and token_has_been_seen_p.
Referenced by analyze_preprocessor_line().
void reset_C_comment | ( | bool | is_compilation_unit_p | ) |
reset and reset_error should be handled differently
Comments in the compilation unit are lost because they are related only to declarations and because comments on declarations are lost. Also, comments located at the end of a block are lost, as we do not generate an extra NOP to carry them.
pips_internal_error("Comments stack is not empty\n");
is_compilation_unit_p | s_compilation_unit_p |
Definition at line 1450 of file clexer.c.
References bracket_depth, C_current_comment, clear_C_comment(), count, fprintf(), free(), pips_user_warning, string_undefined, string_undefined_p, and token_has_been_seen_p.
Referenced by actual_c_parser(), and c_parser_error().
void reset_current_C_line_number | ( | void | ) |
Definition at line 1210 of file clexer.c.
References C_line_number, c_lineno, FIRST_C_LINE_NUMBER, pips_internal_error, previous_C_line_number, previous_c_lineno, and UNDEFINED_C_LINE_NUMBER.
Referenced by actual_c_parser().
void reset_token_has_been_seen_p | ( | void | ) |
void set_current_C_line_number | ( | void | ) |
Initialize the user line number...
... and the absolute line number in the current file
The first line is used to indicate the line number in the user source file
Some check on it first? It should have been disallocated by reset_current_C_line_number()
Definition at line 1166 of file clexer.c.
References C_line_increment, C_line_number, c_lineno, FIRST_C_LINE_NUMBER, pips_internal_error, previous_C_line_number, previous_c_lineno, and UNDEFINED_C_LINE_NUMBER.
Referenced by actual_c_parser().
void update_C_comment | ( | string | a_comment | ) |
Add a comment to the current one.
Do not add LFs that appear within a statement
Do not concatenate two comments without a LF
a_comment | _comment |
Definition at line 1365 of file clexer.c.
References C_current_comment, concatenate(), free(), pips_debug, strdup(), string_undefined, string_undefined_p, and token_has_been_seen_p.
YY_BUFFER_STATE yy_create_buffer | ( | FILE * | file, |
int | size | ||
) |
void yy_delete_buffer | ( | YY_BUFFER_STATE | b | ) |
|
static |
void yy_flush_buffer | ( | YY_BUFFER_STATE | b | ) |
|
static |
|
static |
|
static |
|
static |
YY_BUFFER_STATE yy_scan_buffer | ( | char * | base, |
yy_size_t | size | ||
) |
YY_BUFFER_STATE yy_scan_bytes | ( | const char * | bytes, |
int | len | ||
) |
YY_BUFFER_STATE yy_scan_string | ( | const char * | yy_str | ) |
void yy_switch_to_buffer | ( | YY_BUFFER_STATE | new_buffer | ) |
|
static |
void yyfree | ( | void * | ) |
void yypush_buffer_state | ( | YY_BUFFER_STATE | new_buffer | ) |
void* yyrealloc | ( | void * | , |
yy_size_t | |||
) |
void yyrestart | ( | FILE * | input_file | ) |
void yyset_debug | ( | int | debug_flag | ) |
void yyset_extra | ( | YY_EXTRA_TYPE | user_defined | ) |
void yyset_in | ( | FILE * | _in_str | ) |
void yyset_lineno | ( | int | _line_number | ) |
void yyset_out | ( | FILE * | _out_str | ) |
|
static |
Definition at line 1274 of file clexer.c.
Referenced by error_reset_C_comment(), init_C_comment(), is_c_parser_keyword_typedef(), and reset_C_comment().
|
static |
Comment management:
comments for structured control structures such as "for", "switch", "while",... are stacked so that we can get them back when building the statement at the end of the statement;
"do .... while()" is not handled properly; "else" cannot carry a comment, because the "while" and "else" do not really exist in the RI;
Definition at line 1266 of file clexer.c.
Referenced by clear_C_comment(), discard_C_comment(), error_reset_C_comment(), get_current_C_comment(), init_C_comment(), remove_LFs_from_C_comment(), reset_C_comment(), and update_C_comment().
int C_line_increment = 1 |
The line increment is set to zero when header files are parsed.
from "clex.l"
The goal is to reconstruct the line number in the user file and not the line number in the preprocessed file.
This is performed in analyze_preprocessor_line() (util.c)
Definition at line 1110 of file clexer.c.
Referenced by analyze_preprocessor_line(), and set_current_C_line_number().
|
static |
To track the user line number, that is the one in the original user file.
Definition at line 1102 of file clexer.c.
Referenced by analyze_preprocessor_line(), discard_C_comment(), error_reset_current_C_line_number(), get_current_C_line_number(), reset_current_C_line_number(), and set_current_C_line_number().
|
static |
Definition at line 1144 of file clexer.c.
Referenced by error_reset_current_C_line_number(), get_current_C_line_number(), get_previous_C_line_number(), reset_current_C_line_number(), and set_current_C_line_number().
|
static |
To keep track of line intervals.
Definition at line 1113 of file clexer.c.
Referenced by error_reset_current_C_line_number(), get_current_C_line_number(), get_previous_c_lineno(), reset_current_C_line_number(), and set_current_C_line_number().
|
static |
Definition at line 1552 of file clexer.c.
Referenced by is_c_parser_keyword_typedef().
To see if comments are collected within a statement or outside it is pretty easy to turn it on.
It is more difficult to turn it off.
Definition at line 1268 of file clexer.c.
Referenced by error_reset_C_comment(), init_C_comment(), is_c_parser_keyword_typedef(), remove_LFs_from_C_comment(), reset_C_comment(), reset_token_has_been_seen_p(), and update_C_comment().
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
YY_DECL |
The main scanner function which does all the work.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Table of booleans, true if rule could match eol.
|
static |