Soar Kernel
9.3.2 08-06-12
|
#include <portability.h>
#include <stdlib.h>
#include "lexer.h"
#include "mem.h"
#include "kernel.h"
#include "agent.h"
#include "print.h"
#include "init_soar.h"
#include "xml.h"
#include <math.h>
#include <ctype.h>
#include <assert.h>
Go to the source code of this file.
Macros | |
#define | lu lex_unknown |
Functions | |
int | current_lexer_parentheses_level (agent *thisAgent) |
void | determine_possible_symbol_types_for_string (char *s, size_t length_of_s, Bool *possible_id, Bool *possible_var, Bool *possible_sc, Bool *possible_ic, Bool *possible_fc, Bool *rereadable) |
Bool | determine_type_of_constituent_string (agent *thisAgent) |
void | do_fake_rparen (agent *thisAgent) |
void | fake_rparen_at_next_end_of_line (agent *thisAgent) |
void | finish (agent *thisAgent) |
void | get_lexeme (agent *thisAgent) |
Bool | get_lexer_allow_ids (agent *thisAgent) |
void | get_next_char (agent *thisAgent) |
void | init_lexer (agent *thisAgent) |
void | lex_ampersand (agent *thisAgent) |
void | lex_at (agent *thisAgent) |
void | lex_comma (agent *thisAgent) |
void | lex_constituent_string (agent *thisAgent) |
void | lex_digit (agent *thisAgent) |
void | lex_dollar (agent *thisAgent) |
void | lex_eof (agent *thisAgent) |
void | lex_equal (agent *thisAgent) |
void | lex_exclamation_point (agent *thisAgent) |
void | lex_greater (agent *thisAgent) |
void | lex_lbrace (agent *thisAgent) |
void | lex_less (agent *thisAgent) |
void | lex_lparen (agent *thisAgent) |
void | lex_minus (agent *thisAgent) |
void | lex_period (agent *thisAgent) |
void | lex_plus (agent *thisAgent) |
void | lex_quote (agent *thisAgent) |
void | lex_rbrace (agent *thisAgent) |
void | lex_rparen (agent *thisAgent) |
void | lex_tilde (agent *thisAgent) |
void | lex_unknown (agent *thisAgent) |
void | lex_up_arrow (agent *thisAgent) |
void | lex_vbar (agent *thisAgent) |
void | lexer_routines (agent *) |
void | print_location_of_most_recent_lexeme (agent *thisAgent) |
void | read_constituent_string (agent *thisAgent) |
void | read_rest_of_floating_point_number (agent *thisAgent) |
void | record_position_of_start_of_lexeme (agent *thisAgent) |
void | set_lexer_allow_ids (agent *thisAgent, Bool allow_identifiers) |
void | skip_ahead_to_balanced_parentheses (agent *thisAgent, int parentheses_level) |
void | start_lex_from_file (agent *thisAgent, const char *filename, FILE *already_opened_file) |
void | stop_lex_from_file (agent *thisAgent) |
void | store_and_advance (agent *thisAgent) |
Variables | |
Bool | constituent_char [256] |
Bool | number_starters [256] |
Bool | whitespace [256] |
#define lu lex_unknown |
Definition at line 1078 of file lexer.cpp.
References agent_struct::current_file, and lexer_source_file_struct::parentheses_level.
void determine_possible_symbol_types_for_string | ( | char * | s, |
size_t | length_of_s, | ||
Bool * | possible_id, | ||
Bool * | possible_var, | ||
Bool * | possible_sc, | ||
Bool * | possible_ic, | ||
Bool * | possible_fc, | ||
Bool * | rereadable | ||
) |
Definition at line 1125 of file lexer.cpp.
References constituent_char, FALSE, LENGTH_OF_LONGEST_SPECIAL_LEXEME, number_starters, and TRUE.
Referenced by determine_type_of_constituent_string(), get_io_symbol_from_tio_constituent_string(), and symbol_to_string().
Definition at line 307 of file lexer.cpp.
References lexer_source_file_struct::allow_ids, agent_struct::current_file, determine_possible_symbol_types_for_string(), FLOAT_CONSTANT_LEXEME, lexeme_info::float_val, lexeme_info::id_letter, lexeme_info::id_number, IDENTIFIER_LEXEME, INT_CONSTANT_LEXEME, lexeme_info::int_val, lexeme_info::length, agent_struct::lexeme, print(), print_location_of_most_recent_lexeme(), PRINT_WARNINGS_SYSPARAM, QUOTED_STRING_LEXEME, lexeme_info::string, SYM_CONSTANT_LEXEME, agent_struct::sysparams, TRUE, lexeme_info::type, VARIABLE_LEXEME, and xml_generate_warning().
Referenced by get_lexeme_from_string(), lex_ampersand(), lex_constituent_string(), lex_digit(), lex_equal(), lex_greater(), lex_less(), lex_minus(), lex_period(), and lex_plus().
void do_fake_rparen | ( | agent * | thisAgent | ) |
Definition at line 386 of file lexer.cpp.
References agent_struct::current_file, lexer_source_file_struct::fake_rparen_at_eol, FALSE, lexeme_info::length, agent_struct::lexeme, lexer_source_file_struct::parentheses_level, R_PAREN_LEXEME, record_position_of_start_of_lexeme(), lexeme_info::string, and lexeme_info::type.
Referenced by get_lexeme(), and lex_eof().
void fake_rparen_at_next_end_of_line | ( | agent * | thisAgent | ) |
Definition at line 1092 of file lexer.cpp.
References agent_struct::current_file, lexer_source_file_struct::fake_rparen_at_eol, lexer_source_file_struct::parentheses_level, and TRUE.
|
inline |
Definition at line 261 of file lexer.cpp.
References lexeme_info::length, agent_struct::lexeme, and lexeme_info::string.
Referenced by lex_at(), lex_comma(), lex_eof(), lex_exclamation_point(), lex_lbrace(), lex_lparen(), lex_period(), lex_rbrace(), lex_rparen(), lex_tilde(), lex_up_arrow(), read_constituent_string(), and read_rest_of_floating_point_number().
void get_lexeme | ( | agent * | thisAgent | ) |
Definition at line 747 of file lexer.cpp.
References agent_struct::current_char, agent_struct::current_file, do_fake_rparen(), lexer_source_file_struct::fake_rparen_at_eol, FALSE, get_next_char(), lexeme_info::length, agent_struct::lex_alias, lex_eof(), expansion_node::lexeme, agent_struct::lexeme, lexer_routines(), agent_struct::load_errors_quit, expansion_node::next, record_position_of_start_of_lexeme(), lexeme_info::string, and whitespace.
Referenced by lex_unknown(), parse_attr_value_make(), parse_attr_value_tests(), parse_cond(), parse_disjunction_test(), parse_function_call_after_lparen(), parse_head_of_conds_for_one_id(), parse_lti(), parse_preference_specifier_without_referent(), parse_preferences(), parse_preferences_soar8_non_operator(), parse_production(), parse_relational_test(), parse_rhs_action(), parse_rhs_value(), parse_tail_of_conds_for_one_id(), parse_test(), parse_value_test_star(), skip_ahead_to_balanced_parentheses(), smem_parse_chunk(), and smem_parse_chunks().
Definition at line 1109 of file lexer.cpp.
References lexer_source_file_struct::allow_ids, and agent_struct::current_file.
Referenced by parse_lti().
void get_next_char | ( | agent * | thisAgent | ) |
Definition at line 140 of file lexer.cpp.
References abort_with_fatal_error(), agent_struct::alternate_input_exit, agent_struct::alternate_input_string, agent_struct::alternate_input_suffix, lexer_source_file_struct::buffer, BUFSIZE, agent_struct::current_char, lexer_source_file_struct::current_column, agent_struct::current_file, lexer_source_file_struct::current_line, lexer_source_file_struct::file, lexer_source_file_struct::filename, MAX_LEXER_LINE_LENGTH, NIL, print(), reading_from_top_level(), and tell_printer_that_output_column_has_been_reset().
Referenced by get_lexeme(), lex_dollar(), lex_quote(), lex_unknown(), lex_vbar(), and store_and_advance().
void init_lexer | ( | agent * | thisAgent | ) |
Definition at line 861 of file lexer.cpp.
References constituent_char, lex_ampersand(), lex_at(), lex_comma(), lex_constituent_string(), lex_digit(), lex_dollar(), lex_equal(), lex_exclamation_point(), lex_greater(), lex_lbrace(), lex_less(), lex_lparen(), lex_minus(), lex_period(), lex_plus(), lex_quote(), lex_rbrace(), lex_rparen(), lex_tilde(), lex_up_arrow(), lex_vbar(), lexer_routines(), number_starters, start_lex_from_file(), TRUE, and whitespace.
Referenced by init_soar_agent().
void lex_ampersand | ( | agent * | thisAgent | ) |
Definition at line 492 of file lexer.cpp.
References AMPERSAND_LEXEME, determine_type_of_constituent_string(), lexeme_info::length, agent_struct::lexeme, read_constituent_string(), and lexeme_info::type.
Referenced by init_lexer().
void lex_at | ( | agent * | thisAgent | ) |
Definition at line 441 of file lexer.cpp.
References AT_LEXEME, finish(), agent_struct::lexeme, store_and_advance(), and lexeme_info::type.
Referenced by init_lexer().
void lex_comma | ( | agent * | thisAgent | ) |
Definition at line 477 of file lexer.cpp.
References COMMA_LEXEME, finish(), agent_struct::lexeme, store_and_advance(), and lexeme_info::type.
Referenced by init_lexer().
void lex_constituent_string | ( | agent * | thisAgent | ) |
Definition at line 634 of file lexer.cpp.
References determine_type_of_constituent_string(), and read_constituent_string().
Referenced by init_lexer().
void lex_digit | ( | agent * | thisAgent | ) |
Definition at line 599 of file lexer.cpp.
References agent_struct::current_char, determine_type_of_constituent_string(), FALSE, lexeme_info::length, agent_struct::lexeme, read_constituent_string(), read_rest_of_floating_point_number(), lexeme_info::string, and TRUE.
Referenced by init_lexer().
void lex_dollar | ( | agent * | thisAgent | ) |
Definition at line 714 of file lexer.cpp.
References agent_struct::current_char, DOLLAR_STRING_LEXEME, get_next_char(), lexeme_info::length, agent_struct::lexeme, MAX_LEXEME_LENGTH, lexeme_info::string, and lexeme_info::type.
Referenced by init_lexer().
void lex_eof | ( | agent * | thisAgent | ) |
Definition at line 431 of file lexer.cpp.
References agent_struct::current_file, do_fake_rparen(), EOF_LEXEME, lexer_source_file_struct::fake_rparen_at_eol, finish(), agent_struct::lexeme, store_and_advance(), and lexeme_info::type.
Referenced by get_lexeme().
void lex_equal | ( | agent * | thisAgent | ) |
Definition at line 483 of file lexer.cpp.
References determine_type_of_constituent_string(), EQUAL_LEXEME, lexeme_info::length, agent_struct::lexeme, read_constituent_string(), and lexeme_info::type.
Referenced by init_lexer().
void lex_exclamation_point | ( | agent * | thisAgent | ) |
Definition at line 471 of file lexer.cpp.
References EXCLAMATION_POINT_LEXEME, finish(), agent_struct::lexeme, store_and_advance(), and lexeme_info::type.
Referenced by init_lexer().
void lex_greater | ( | agent * | thisAgent | ) |
Definition at line 515 of file lexer.cpp.
References determine_type_of_constituent_string(), GREATER_EQUAL_LEXEME, GREATER_GREATER_LEXEME, GREATER_LEXEME, lexeme_info::length, agent_struct::lexeme, read_constituent_string(), lexeme_info::string, and lexeme_info::type.
Referenced by init_lexer().
void lex_lbrace | ( | agent * | thisAgent | ) |
Definition at line 459 of file lexer.cpp.
References finish(), L_BRACE_LEXEME, agent_struct::lexeme, store_and_advance(), and lexeme_info::type.
Referenced by init_lexer().
void lex_less | ( | agent * | thisAgent | ) |
Definition at line 528 of file lexer.cpp.
References determine_type_of_constituent_string(), lexeme_info::length, LESS_EQUAL_GREATER_LEXEME, LESS_EQUAL_LEXEME, LESS_LESS_LEXEME, LESS_LEXEME, agent_struct::lexeme, NOT_EQUAL_LEXEME, read_constituent_string(), lexeme_info::string, and lexeme_info::type.
Referenced by init_lexer().
void lex_lparen | ( | agent * | thisAgent | ) |
Definition at line 501 of file lexer.cpp.
References agent_struct::current_file, finish(), L_PAREN_LEXEME, agent_struct::lexeme, lexer_source_file_struct::parentheses_level, store_and_advance(), and lexeme_info::type.
Referenced by init_lexer().
void lex_minus | ( | agent * | thisAgent | ) |
Definition at line 576 of file lexer.cpp.
References agent_struct::current_char, determine_type_of_constituent_string(), FALSE, lexeme_info::length, agent_struct::lexeme, MINUS_LEXEME, read_constituent_string(), read_rest_of_floating_point_number(), RIGHT_ARROW_LEXEME, lexeme_info::string, TRUE, and lexeme_info::type.
Referenced by init_lexer().
void lex_period | ( | agent * | thisAgent | ) |
Definition at line 547 of file lexer.cpp.
References agent_struct::current_char, determine_type_of_constituent_string(), finish(), lexeme_info::length, agent_struct::lexeme, PERIOD_LEXEME, read_rest_of_floating_point_number(), store_and_advance(), and lexeme_info::type.
Referenced by init_lexer().
void lex_plus | ( | agent * | thisAgent | ) |
Definition at line 557 of file lexer.cpp.
References agent_struct::current_char, determine_type_of_constituent_string(), FALSE, lexeme_info::length, agent_struct::lexeme, PLUS_LEXEME, read_constituent_string(), read_rest_of_floating_point_number(), lexeme_info::string, TRUE, and lexeme_info::type.
Referenced by init_lexer().
void lex_quote | ( | agent * | thisAgent | ) |
Definition at line 669 of file lexer.cpp.
References agent_struct::current_char, EOF_LEXEME, get_next_char(), lexeme_info::length, agent_struct::lexeme, MAX_LEXEME_LENGTH, print(), print_location_of_most_recent_lexeme(), QUOTED_STRING_LEXEME, lexeme_info::string, TRUE, and lexeme_info::type.
Referenced by init_lexer().
void lex_rbrace | ( | agent * | thisAgent | ) |
Definition at line 465 of file lexer.cpp.
References finish(), agent_struct::lexeme, R_BRACE_LEXEME, store_and_advance(), and lexeme_info::type.
Referenced by init_lexer().
void lex_rparen | ( | agent * | thisAgent | ) |
Definition at line 508 of file lexer.cpp.
References agent_struct::current_file, finish(), agent_struct::lexeme, lexer_source_file_struct::parentheses_level, R_PAREN_LEXEME, store_and_advance(), and lexeme_info::type.
Referenced by init_lexer().
void lex_tilde | ( | agent * | thisAgent | ) |
Definition at line 447 of file lexer.cpp.
References finish(), agent_struct::lexeme, store_and_advance(), TILDE_LEXEME, and lexeme_info::type.
Referenced by init_lexer().
void lex_unknown | ( | agent * | thisAgent | ) |
Definition at line 615 of file lexer.cpp.
References agent_struct::current_char, lexer_source_file_struct::current_column, agent_struct::current_file, lexer_source_file_struct::current_line, lexer_source_file_struct::filename, get_lexeme(), get_next_char(), agent_struct::load_errors_quit, print(), and reading_from_top_level().
void lex_up_arrow | ( | agent * | thisAgent | ) |
Definition at line 453 of file lexer.cpp.
References finish(), agent_struct::lexeme, store_and_advance(), lexeme_info::type, and UP_ARROW_LEXEME.
Referenced by init_lexer().
void lex_vbar | ( | agent * | thisAgent | ) |
Definition at line 639 of file lexer.cpp.
References agent_struct::current_char, EOF_LEXEME, get_next_char(), lexeme_info::length, agent_struct::lexeme, MAX_LEXEME_LENGTH, print(), print_location_of_most_recent_lexeme(), lexeme_info::string, SYM_CONSTANT_LEXEME, TRUE, and lexeme_info::type.
Referenced by init_lexer().
void lexer_routines | ( | agent * | ) |
Referenced by get_lexeme(), and init_lexer().
void print_location_of_most_recent_lexeme | ( | agent * | thisAgent | ) |
Definition at line 1022 of file lexer.cpp.
References lexer_source_file_struct::buffer, lexer_source_file_struct::column_of_start_of_last_lexeme, agent_struct::current_char, agent_struct::current_file, lexer_source_file_struct::current_line, lexer_source_file_struct::filename, lexer_source_file_struct::line_of_start_of_last_lexeme, agent_struct::load_errors_quit, print(), print_string(), and reading_from_top_level().
Referenced by determine_type_of_constituent_string(), lex_quote(), lex_vbar(), parse_attr_value_make(), parse_attr_value_tests(), parse_cond(), parse_disjunction_test(), parse_function_call_after_lparen(), parse_head_of_conds_for_one_id(), parse_preferences_soar8_non_operator(), parse_production(), parse_relational_test(), parse_rhs_action(), parse_rhs_value(), and read_identifier_or_context_variable().
void read_constituent_string | ( | agent * | thisAgent | ) |
Definition at line 266 of file lexer.cpp.
References constituent_char, agent_struct::current_char, finish(), and store_and_advance().
Referenced by lex_ampersand(), lex_constituent_string(), lex_digit(), lex_equal(), lex_greater(), lex_less(), lex_minus(), and lex_plus().
void read_rest_of_floating_point_number | ( | agent * | thisAgent | ) |
Definition at line 278 of file lexer.cpp.
References allocate_memory(), agent_struct::current_char, finish(), free_memory_block_for_string(), agent_struct::lexeme, store_and_advance(), lexeme_info::string, and STRING_MEM_USAGE.
Referenced by lex_digit(), lex_minus(), lex_period(), and lex_plus().
|
inline |
Definition at line 236 of file lexer.cpp.
References lexer_source_file_struct::column_of_start_of_last_lexeme, lexer_source_file_struct::current_column, agent_struct::current_file, lexer_source_file_struct::current_line, and lexer_source_file_struct::line_of_start_of_last_lexeme.
Referenced by do_fake_rparen(), and get_lexeme().
Definition at line 1105 of file lexer.cpp.
References lexer_source_file_struct::allow_ids, and agent_struct::current_file.
Referenced by parse_lti(), and smem_parse_chunks().
Definition at line 1082 of file lexer.cpp.
References agent_struct::current_file, EOF_LEXEME, get_lexeme(), agent_struct::lexeme, lexer_source_file_struct::parentheses_level, R_PAREN_LEXEME, TRUE, and lexeme_info::type.
void start_lex_from_file | ( | agent * | thisAgent, |
const char * | filename, | ||
FILE * | already_opened_file | ||
) |
Definition at line 94 of file lexer.cpp.
References allocate_memory(), lexer_source_file_struct::allow_ids, lexer_source_file_struct::buffer, lexer_source_file_struct::column_of_start_of_last_lexeme, agent_struct::current_char, lexer_source_file_struct::current_column, agent_struct::current_file, lexer_source_file_struct::current_line, lexer_source_file_struct::fake_rparen_at_eol, FALSE, lexer_source_file_struct::file, lexer_source_file_struct::filename, agent_struct::lexeme, lexer_source_file_struct::line_of_start_of_last_lexeme, make_memory_block_for_string(), MISCELLANEOUS_MEM_USAGE, lexer_source_file_struct::parent_file, lexer_source_file_struct::parentheses_level, lexer_source_file_struct::saved_current_char, lexer_source_file_struct::saved_lexeme, and TRUE.
Referenced by init_lexer(), and load_file().
void stop_lex_from_file | ( | agent * | thisAgent | ) |
Definition at line 117 of file lexer.cpp.
References agent_struct::current_char, agent_struct::current_file, lexer_source_file_struct::filename, free_memory(), free_memory_block_for_string(), agent_struct::lexeme, MISCELLANEOUS_MEM_USAGE, lexer_source_file_struct::parent_file, print(), reading_from_top_level(), lexer_source_file_struct::saved_current_char, and lexer_source_file_struct::saved_lexeme.
Referenced by load_file().
|
inline |
Definition at line 254 of file lexer.cpp.
References agent_struct::current_char, get_next_char(), lexeme_info::length, agent_struct::lexeme, and lexeme_info::string.
Referenced by lex_at(), lex_comma(), lex_eof(), lex_exclamation_point(), lex_lbrace(), lex_lparen(), lex_period(), lex_rbrace(), lex_rparen(), lex_tilde(), lex_up_arrow(), read_constituent_string(), and read_rest_of_floating_point_number().
Bool constituent_char[256] |
Definition at line 79 of file lexer.cpp.
Referenced by determine_possible_symbol_types_for_string(), init_lexer(), and read_constituent_string().
Bool number_starters[256] |
Definition at line 81 of file lexer.cpp.
Referenced by determine_possible_symbol_types_for_string(), and init_lexer().
Bool whitespace[256] |
Definition at line 80 of file lexer.cpp.
Referenced by get_lexeme(), and init_lexer().