token More...
Go to the source code of this file.
Macros | |
#define | isoctal(c) (c=='0'||c=='1'||c=='2'||c=='3'||c=='4'||c=='5'||c=='6'||c=='7') |
Functions | |
void | TOKEN_ERROR (ptr_psi_term p) |
TOKEN_ERROR. More... | |
void | stdin_cleareof () |
stdin_cleareof More... | |
void | heap_add_int_attr (ptr_psi_term t, char *attrname, long value) |
heap_add_int_attr More... | |
void | stack_add_int_attr (ptr_psi_term t, char *attrname, long value) |
stack_add_int_attr More... | |
void | heap_mod_int_attr (ptr_psi_term t, char *attrname, long value) |
heap_mod_int_attr More... | |
void | heap_add_str_attr (ptr_psi_term t, char *attrname, char *str) |
heap_add_str_attr More... | |
void | stack_add_str_attr (ptr_psi_term t, char *attrname, char *str) |
stack_add_str_attr More... | |
void | heap_mod_str_attr (ptr_psi_term t, char *attrname, char *str) |
heap_mod_str_attr More... | |
void | heap_add_psi_attr (ptr_psi_term t, char *attrname, ptr_psi_term g) |
heap_add_psi_attr More... | |
void | stack_add_psi_attr (ptr_psi_term t, char *attrname, ptr_psi_term g) |
stack_add_psi_attr More... | |
void | bk_stack_add_psi_attr (ptr_psi_term t, char *attrname, ptr_psi_term g) |
bk_stack_add_psi_attr More... | |
GENERIC | get_attr (ptr_psi_term t, char *attrname) |
get_attr More... | |
FILE * | get_stream (ptr_psi_term t) |
get_stream More... | |
void | save_state (ptr_psi_term t) |
save_state More... | |
void | restore_state (ptr_psi_term t) |
restore_state More... | |
void | new_state (ptr_psi_term *t) |
new_state More... | |
void | save_parse_state (ptr_parse_block pb) |
save_parse_state More... | |
void | restore_parse_state (ptr_parse_block pb) |
restore_parse_state More... | |
void | init_parse_state () |
init_parse_state More... | |
void | begin_terminal_io () |
begin_terminal_io More... | |
void | end_terminal_io () |
end_terminal_io More... | |
char * | expand_file_name (char *s) |
expand_file_name More... | |
long | open_input_file (char *file) |
open_input_file More... | |
long | open_output_file (string file) |
open_output_file More... | |
long | read_char () |
read_char More... | |
void | put_back_char (long c) |
put_back_char More... | |
void | put_back_token (psi_term t) |
put_back_token More... | |
void | psi_term_error () |
psi_term_error More... | |
void | read_comment (ptr_psi_term tok) |
read_comment More... | |
void | read_string_error (int n) |
read_string_error More... | |
int | base2int (int n) |
base2int More... | |
void | read_string (ptr_psi_term tok, long e) |
read_string More... | |
long | symbolic (long c) |
symbolic More... | |
long | legal_in_name (long c) |
legal_in_name More... | |
void | read_name (ptr_psi_term tok, long ch, long(*f)(long), ptr_definition typ) |
read_name More... | |
void | read_number (ptr_psi_term tok, long c) |
read_number More... | |
void | read_token (ptr_psi_term tok) |
read_token More... | |
void | read_token_b (ptr_psi_term tok) |
read_token_b More... | |
void | read_token_main (ptr_psi_term tok, long for_parser) |
read_token_main More... | |
Variables | |
long | trace_input =FALSE |
static long | inchange |
static long | outchange |
static FILE * | out |
ptr_psi_term | old_state =NULL |
token
Definition in file token.c.
#define isoctal | ( | c | ) | (c=='0'||c=='1'||c=='2'||c=='3'||c=='4'||c=='5'||c=='6'||c=='7') |
void begin_terminal_io | ( | ) |
begin_terminal_io
BEGIN_TERMINAL_IO() These two routines must bracket any I/O directed to the terminal. This is to avoid mix-ups between terminal and file I/O since the program's input and output streams may be different from stdin stdout. See the routine what_next_aim(), which uses them to isolate the user interface I/O from the program's own I/O.
Definition at line 493 of file token.c.
References inchange, input_state, input_stream, open_input_file(), out, outchange, and output_stream.
void bk_stack_add_psi_attr | ( | ptr_psi_term | t, |
char * | attrname, | ||
ptr_psi_term | g | ||
) |
bk_stack_add_psi_attr
t | - ptr_psi_term t |
attrname | - char *attrname |
g | - ptr_psi_term g |
Definition at line 252 of file token.c.
References wl_psi_term::attr_list, bk_stack_insert(), FEATCMP, and heap_copy_string().
void end_terminal_io | ( | ) |
end_terminal_io
END_TERMINAL_IO() End of terminal I/O bracketing.
Definition at line 516 of file token.c.
References inchange, input_state, NULL, old_state, out, outchange, output_stream, and restore_state().
char* expand_file_name | ( | char * | s | ) |
expand_file_name
s | - char *s |
EXPAND_FILE_NAME(str) Return the expansion of file name STR. For the time being all this does is replace '~' by the HOME directory if no user is given, or tries to find the user.
Definition at line 537 of file token.c.
References STRLEN.
GENERIC get_attr | ( | ptr_psi_term | t, |
char * | attrname | ||
) |
get_attr
t | - ptr_psi_term t |
attrname | - char *attrname |
Get the GENERIC value of a psi-term's attribute
Definition at line 265 of file token.c.
References wl_psi_term::attr_list, wl_node::data, FEATCMP, and find().
FILE* get_stream | ( | ptr_psi_term | t | ) |
get_stream
t | - ptr_psi_term t |
Get the psi-term's STREAM attribute
Definition at line 278 of file token.c.
References get_attr(), and STREAM.
void heap_add_int_attr | ( | ptr_psi_term | t, |
char * | attrname, | ||
long | value | ||
) |
heap_add_int_attr
t | - ptr_psi_term t |
attrname | - char *attrname |
value | - long value |
Add an attribute whose value is an integer to a psi-term that does not yet contains this attribute.
Definition at line 74 of file token.c.
References wl_psi_term::attr_list, FEATCMP, heap_alloc(), heap_copy_string(), heap_insert(), heap_psi_term(), integer, REAL, wl_psi_term::type, and wl_psi_term::value_3.
void heap_add_psi_attr | ( | ptr_psi_term | t, |
char * | attrname, | ||
ptr_psi_term | g | ||
) |
heap_add_psi_attr
t | - ptr_psi_term t |
attrname | - char *attrname |
g | - ptr_psi_term g |
Attach a psi-term to another as an attribute.
Definition at line 226 of file token.c.
References wl_psi_term::attr_list, FEATCMP, heap_copy_string(), and heap_insert().
void heap_add_str_attr | ( | ptr_psi_term | t, |
char * | attrname, | ||
char * | str | ||
) |
heap_add_str_attr
t | - ptr_psi_term t |
attrname | - char *attrname |
str | - char *str |
Add an attribute whose value is a string to a psi-term that does not yet contains this attribute.
Definition at line 151 of file token.c.
References wl_psi_term::attr_list, FEATCMP, heap_copy_string(), heap_insert(), heap_psi_term(), quoted_string, wl_psi_term::type, and wl_psi_term::value_3.
void heap_mod_int_attr | ( | ptr_psi_term | t, |
char * | attrname, | ||
long | value | ||
) |
heap_mod_int_attr
t | - ptr_psi_term t |
attrname | - char *attrname |
value | - long value |
Modify an attribute whose value is an integer to a psi-term that already contains this attribute with another integer value.
Definition at line 116 of file token.c.
References wl_psi_term::attr_list, wl_node::data, FEATCMP, find(), REAL, and wl_psi_term::value_3.
void heap_mod_str_attr | ( | ptr_psi_term | t, |
char * | attrname, | ||
char * | str | ||
) |
heap_mod_str_attr
t | - ptr_psi_term t |
attrname | - char *attrname |
str | - char *str |
Modify an attribute whose value is a string to a psi-term that already contains this attribute with another integer value.
Definition at line 191 of file token.c.
References wl_psi_term::attr_list, wl_node::data, FEATCMP, find(), heap_copy_string(), and wl_psi_term::value_3.
void init_parse_state | ( | ) |
init_parse_state
Initialize the parser/tokenizer state variables.
Definition at line 464 of file token.c.
References eof_flag, FALSE, line_count, NULL, old_saved_char, old_saved_psi_term, saved_char, saved_psi_term, start_of_line, stringparse, and TRUE.
long legal_in_name | ( | long | c | ) |
void new_state | ( | ptr_psi_term * | t | ) |
new_state
t | - ptr_psi_term *t |
Create a new file state psi-term that reflects the current global state
Definition at line 372 of file token.c.
References current_module, CURRENT_MODULE, eof_flag, EOF_FLAG, heap_add_int_attr(), heap_add_psi_attr(), heap_add_str_attr(), heap_psi_term(), INPUT_FILE_NAME, input_file_name, input_stream, inputfilesym, lf_false, lf_true, LINE_COUNT, line_count, wl_module::module_name, null_psi_term, old_saved_char, OLD_SAVED_CHAR, old_saved_psi_term, OLD_SAVED_PSI_TERM, saved_char, SAVED_CHAR, saved_psi_term, SAVED_PSI_TERM, start_of_line, START_OF_LINE, stream, STREAM, wl_psi_term::type, and wl_psi_term::value_3.
long open_input_file | ( | char * | file | ) |
open_input_file
file | - char *file |
OPEN_INPUT_FILE(file) Open the input file specified by the string FILE. If the file is "stdin", restore the stdin state. Otherwise, open the file and create a new global state for it. If the file can't be opened, print an error and open "stdin" instead.
Definition at line 594 of file token.c.
References Errorline(), expand_file_name(), FALSE, init_parse_state(), input_file_name, input_state, input_stream, new_state(), noisy, NULL, restore_state(), save_state(), stdin_state, and TRUE.
long open_output_file | ( | string | file | ) |
open_output_file
file | - string file |
OPEN_OUTPUT_FILE(file) Same thing as OPEN_INPUT_FILE, only for output. If FILE="stdout" then output_stream=stdout.
Definition at line 646 of file token.c.
References Errorline(), expand_file_name(), FALSE, NULL, output_stream, and TRUE.
void psi_term_error | ( | ) |
psi_term_error
PSI_TERM_ERROR Print the line number at which the current psi_term started.
Definition at line 761 of file token.c.
References FALSE, input_file_name, parse_ok, perr_i(), perr_s(), and psi_term_line_number.
void put_back_char | ( | long | c | ) |
put_back_char
c | - long c |
PUT_BACK_CHAR Put back one character, if there already are 2 saved characters then report an error (= bug).
Definition at line 729 of file token.c.
References Errorline(), old_saved_char, and saved_char.
void put_back_token | ( | psi_term | t | ) |
put_back_token
t | - psi_term t |
PUT_BACK_TOKEN Put back a psi_term, if there already are two saved then report an error (= bug).
Definition at line 746 of file token.c.
References Errorline(), NULL, old_saved_psi_term, saved_psi_term, and stack_copy_psi_term().
long read_char | ( | ) |
read_char
READ_CHAR Return the char read from the input stream, if end of file reached then return EOF. If stringparse==TRUE then read characters from the input string instead of from a file.
Definition at line 680 of file token.c.
References EOLN, FALSE, infoline(), input_stream, line_count, NULL, old_saved_char, prompt, saved_char, start_of_line, stringinput, stringparse, trace_input, and TRUE.
void read_comment | ( | ptr_psi_term | tok | ) |
read_comment
tok | - ptr_psi_term tok |
READ_COMMENT Read a comment starting with '' to the end of the line.
Definition at line 779 of file token.c.
References comment, EOLN, read_char(), and wl_psi_term::type.
void read_name | ( | ptr_psi_term | tok, |
long | ch, | ||
long(*)(long) | f, | ||
ptr_definition | typ | ||
) |
read_name
tok | - ptr_psi_term tok |
ch | - long ch |
f | - long (*f)(long) |
typ | - ptr_definition typ |
READ_NAME(C,F,TYP) Read in the name starting with character C followed by character of whose type function is F. The result is a psi_term of symbol type TYP.
Definition at line 1002 of file token.c.
References wl_psi_term::attr_list, bk2_stack_insert(), constant, wl_psi_term::coref, create_module(), FALSE, find(), global_it, wl_definition::global_value, heap_copy_string(), wl_definition::keyword, legal_in_name(), wl_module::module_name, NULL, put_back_char(), read_char(), wl_psi_term::resid, STRCMP, STRLEN, SYMBOL, wl_keyword::symbol, symbolic(), TOKEN_ERROR(), TRUE, wl_psi_term::type, wl_definition::type_def, update_symbol(), wl_psi_term::value_3, var_occurred, var_tree, and warningline().
void read_number | ( | ptr_psi_term | tok, |
long | c | ||
) |
read_number
tok | - ptr_psi_term tok |
c | - long c |
READ_NUMBER(c) Read in the number whose first character is c. Accepted syntax: digit+ [ . digit+ ] [ {e|E} {+|-|empty} digit* ] Negative numbers are dealt with in the parser.
Definition at line 1110 of file token.c.
References DIGIT, heap_alloc(), integer, put_back_char(), read_char(), REAL, real, wl_psi_term::type, and wl_psi_term::value_3.
void read_string | ( | ptr_psi_term | tok, |
long | e | ||
) |
read_string
tok | - ptr_psi_term tok |
e | - long e |
READ_STRING(e) Read a string ending with character E, where E=" or '. Transform a double occurrence into a single one so that 'ab""cd' is the string 'ab"cd'.
Definition at line 859 of file token.c.
References base2int(), FALSE, heap_copy_string(), isoctal, NULL, put_back_char(), read_char(), read_string_error(), STRLEN, TOKEN_ERROR(), TRUE, wl_psi_term::type, update_symbol(), wl_psi_term::value_3, and warningline().
void read_string_error | ( | int | n | ) |
read_string_error
n | - int n |
Definition at line 796 of file token.c.
References FALSE, parse_ok, stringparse, and Syntaxerrorline().
void read_token | ( | ptr_psi_term | tok | ) |
read_token
tok | - ptr_psi_term tok |
READ_TOKEN Read in one token from the input stream, represented as a psi_term. Return the psi_term 'end_of_file' if that is the case.
Used in the parser Set prompt to the 'partial input' prompt
Definition at line 1186 of file token.c.
References read_token_main(), and TRUE.
void read_token_b | ( | ptr_psi_term | tok | ) |
read_token_b
tok | - ptr_psi_term tok |
Used as a built-in Prompt is unchanged
Definition at line 1197 of file token.c.
References FALSE, and read_token_main().
void read_token_main | ( | ptr_psi_term | tok, |
long | for_parser | ||
) |
read_token_main
tok | - ptr_psi_term tok |
for_parser | - long for_parser |
Definition at line 1207 of file token.c.
References wl_psi_term::attr_list, bk2_stack_insert(), choice_stack, comment, constant, wl_psi_term::coref, current_module, cut, wl_node::data, DIGIT, eof, EOLN, Errorline(), FALSE, final_dot, final_question, find(), wl_psi_term::flags, legal_in_name(), line_count, LOWER, nothing, NULL, old_saved_psi_term, prompt, psi_term_line_number, put_back_char(), quoted_string, read_char(), read_comment(), read_name(), read_number(), read_string(), read_token(), wl_psi_term::resid, saved_psi_term, SINGLE, stack_psi_term(), wl_psi_term::status, STRCMP, SYMBOL, symbolic(), TOKEN_ERROR(), TRUE, wl_psi_term::type, update_symbol(), UPPER, wl_psi_term::value_3, var_occurred, var_tree, and variable.
void restore_parse_state | ( | ptr_parse_block | pb | ) |
restore_parse_state
pb | - ptr_parse_block pb |
Definition at line 444 of file token.c.
References wl_parse_block::ef, eof_flag, wl_parse_block::lc, line_count, old_saved_char, old_saved_psi_term, wl_parse_block::osc, wl_parse_block::ospt, saved_char, saved_psi_term, wl_parse_block::sc, wl_parse_block::sol, wl_parse_block::spt, and start_of_line.
void restore_state | ( | ptr_psi_term | t | ) |
restore_state
t | - ptr_psi_term t |
Restore global state from an existing file state psi-term t
Definition at line 334 of file token.c.
References eof_flag, EOF_FLAG, get_attr(), INPUT_FILE_NAME, input_file_name, input_stream, lf_true, LINE_COUNT, line_count, NULL, null_psi_term, old_saved_char, OLD_SAVED_CHAR, old_saved_psi_term, OLD_SAVED_PSI_TERM, REAL, saved_char, SAVED_CHAR, saved_psi_term, SAVED_PSI_TERM, start_of_line, START_OF_LINE, and STREAM.
void save_parse_state | ( | ptr_parse_block | pb | ) |
save_parse_state
pb | - ptr_parse_block pb |
Definition at line 425 of file token.c.
References wl_parse_block::ef, eof_flag, wl_parse_block::lc, line_count, old_saved_char, old_saved_psi_term, wl_parse_block::osc, wl_parse_block::ospt, saved_char, saved_psi_term, wl_parse_block::sc, wl_parse_block::sol, wl_parse_block::spt, and start_of_line.
void save_state | ( | ptr_psi_term | t | ) |
save_state
t | - ptr_psi_term t |
Save global state into an existing file state psi-term t
Definition at line 293 of file token.c.
References wl_psi_term::attr_list, wl_node::data, eof_flag, EOF_FLAG, FEATCMP, find(), heap_add_psi_attr(), heap_mod_int_attr(), heap_mod_str_attr(), heap_psi_term(), INPUT_FILE_NAME, input_file_name, input_stream, lf_false, lf_true, LINE_COUNT, line_count, null_psi_term, old_saved_char, OLD_SAVED_CHAR, old_saved_psi_term, OLD_SAVED_PSI_TERM, saved_char, SAVED_CHAR, saved_psi_term, SAVED_PSI_TERM, start_of_line, START_OF_LINE, STREAM, wl_psi_term::type, and wl_psi_term::value_3.
void stack_add_int_attr | ( | ptr_psi_term | t, |
char * | attrname, | ||
long | value | ||
) |
stack_add_int_attr
t | - ptr_psi_term t |
attrname | - char *attrname |
value | - long value |
Definition at line 94 of file token.c.
References wl_psi_term::attr_list, FEATCMP, heap_alloc(), heap_copy_string(), integer, REAL, stack_insert(), stack_psi_term(), wl_psi_term::type, and wl_psi_term::value_3.
void stack_add_psi_attr | ( | ptr_psi_term | t, |
char * | attrname, | ||
ptr_psi_term | g | ||
) |
stack_add_psi_attr
t | - ptr_psi_term t |
attrname | - char *attrname |
g | - ptr_psi_term g |
Definition at line 239 of file token.c.
References wl_psi_term::attr_list, FEATCMP, heap_copy_string(), and stack_insert().
void stack_add_str_attr | ( | ptr_psi_term | t, |
char * | attrname, | ||
char * | str | ||
) |
stack_add_str_attr
t | - ptr_psi_term t |
attrname | - char *attrname |
str | - char *str |
Definition at line 170 of file token.c.
References wl_psi_term::attr_list, FEATCMP, heap_copy_string(), quoted_string, stack_copy_string(), stack_insert(), stack_psi_term(), wl_psi_term::type, and wl_psi_term::value_3.
void stdin_cleareof | ( | ) |
stdin_cleareof
Clear EOF if necessary for stdin
Definition at line 51 of file token.c.
References eof_flag, FALSE, NULL, old_saved_char, old_saved_psi_term, saved_char, saved_psi_term, start_of_line, stdin_terminal, and TRUE.
long symbolic | ( | long | c | ) |
void TOKEN_ERROR | ( | ptr_psi_term | p | ) |
TOKEN_ERROR.
p | - ptr_psi_term p |
Definition at line 38 of file token.c.
References error_psi_term, Syntaxerrorline(), and wl_psi_term::type.
ptr_psi_term old_state =NULL |