Mercurial > ~dholland > hg > ag > index.cgi
view tests/agcl/oldagsrc/cf.syn @ 10:5b21f127e957
silence random gcc warning
author | David A. Holland |
---|---|
date | Mon, 30 May 2022 23:58:14 -0400 |
parents | 13d2b8934445 |
children |
line wrap: on
line source
{/* AnaGram Syntax Analyzer. Copyright (c) Parsifal Software, 1993-1999. All Rights Reserved. Configuration file module */ //#define INCLUDE_LOGGING #include "arrays.h" //ARRAYS #include "assert.h" //ASSERT #include "cint.h" #include "config.h" #include "data.h" //DATA #include "error.h" #include "log.hpp" #include "myalloc.h" //MYALLOC #include "pf.h" //PF #include "tfile.h" //TFILE #include <ctype.h> //CTYPE #include <stdlib.h> //STDLIB #include <string.h> //STRING #undef MODULE #define MODULE 50 } [ auto resynch context type = cint grammar token = config file ~declare pcb diagnose errors lines and columns line numbers ~allow macros line numbers error frame nest comments ~test range token names pointer input default token type = int parser file name = "#.cpp" escape backslashes ] any digit = digit + hex letter backslash = '\\' blank char = ' ' + '\t' carriage return = '\r' digit = '0-9' double quote = '"' eof = 0 + 26 eol chars = newline + carriage return hex letter = 'a-f' + 'A-F' letter = 'a-z' + 'A-Z' + '_' newline = '\n' nonoctal digit = any digit - octal digit octal digit = '0-7' simple string char = ~eof - (any digit + double quote + backslash + eol chars) tab = '\t' vertical space = '\f' + '\v' equals -> '=', space? minus -> '-', space? plus -> '+', space? tilde -> '~', space? left parenthesis -> '(', space? right parenthesis -> ')', blank?... config file -> blank?..., [global parameter | end of line]/..., eof (void) global parameter -> name =ConfigParam::set(1, cfErrorHandler); //cf_gp4(1); -> tilde, name =ConfigParam::set(0, cfErrorHandler); //cf_gp4(0); -> name, equals, data type =ConfigParam::set(cfErrorHandler); //cf_gp2(); -> name, equals, keyword string =ConfigParam::set(cfErrorHandler); //cf_gp3(); -> name, equals, number:n =ConfigParam::set(cfErrorHandler); //cf_gp5(n); (void) data type -> name -> name, abstract declarator =concat_string(); (void) abstract declarator -> indirect data type -> direct abstract declarator -> indirect data type, direct abstract declarator =concat_string(); (void) direct abstract declarator -> {left parenthesis =scs('('),0;}, abstract declarator, right parenthesis =concat_string(), acs(')'); (void) pointer -> star -> star, name =concat_string(); (void) star -> '*', blank?... =sss(" *"); (void) indirect data type -> pointer -> indirect data type, pointer =concat_string(); (void) name string -> letter:a =scs(a); -> name string, letter + digit :a =acs(a); -> name string, blank..., letter + digit :a =acs(' '), acs(a); name -> name string, blank?... blank -> blank char -> c comment space -> blank... -> blank..., continuation -> continuation continuation -> comment, next line -> next line next line -> carriage return?, newline -> carriage return?, newline, blank... white -> blank -> carriage return?, newline -> comment, carriage return?, newline end of line -> comment, carriage return?, newline -> carriage return?, newline -> end of line, white -> end of line, vertical space //form feed comment -> "//", ~eol chars & ~eof?... decimal number -> '1-9':d =d - '0'; -> decimal number:n, '0-9':d =10*n + d - '0'; octal number -> '0' =0; -> octal number:n, '0-7':d =8*n + d - '0'; hex number -> "0x" =0; -> "0X" =0; -> hex number:n, '0-9':d =16*n + d - '0'; -> hex number:n, 'A-F' + 'a-f':d =16*n + (d&7) + 9; simple number -> decimal number -> octal number -> hex number number -> sign:s, simple number:n, blank?... =s*n; sign -> plus? =1; -> minus =-1; keyword string -> keyword string head, string, double quote, blank?... string -> string A | string B | string C (void) keyword string head -> double quote =ics(); string char -> simple string char -> escape sequence escape sequence -> "\\a" ='\a'; -> "\\b" ='\b'; -> "\\f" ='\f'; -> "\\n" ='\n'; -> "\\r" ='\r'; -> "\\t" ='\t'; -> "\\v" ='\v'; -> "\\\\" ='\\'; -> "\\?" = '\?'; -> "\\'" ='\''; -> "\\\"" ='"'; -> three octal:n =n==0?cf_error("Null character in string"),0 : n; one octal -> backslash, '0-7':n =n&7; two octal -> one octal:n, '0-7':d = n*8 + (d&7); three octal -> two octal:n, '0-7':d = n*8 + (d&7); octal escape -> {one octal | two octal}:n = n==0?cf_error("Null character in string"),0 : n; hex escape -> "\\x", hex number:n =n; (void) string A -> string char:c =acs(c); -> any digit:c =acs(c); -> string, string char:c =acs(c); -> string A, any digit:c =acs(c); -> string B, nonoctal digit:c =acs(c); (void) string B -> octal escape:n =acs(n); -> string, octal escape:n =acs(n); (void) string C -> hex escape:n =acs(n); -> string, hex escape:n =acs(n); (void) c comment -> c comment text, "*/" (void) c comment text -> "/*" -> c comment text, ~eof c comment, c comment text -> c comment text, c comment = {if (nest_comments) PCB.reduction_token = cf_c_comment_text_token;} [ hidden { left parenthesis, right parenthesis, pointer, indirect data type, name string, space, next line, sign, one octal, two octal, three octal, string A, string B, string C, c comment text, escape sequence, octal escape, hex escape, name string } ] { #define PARSER_STACK_OVERFLOW assert(0) #define REDUCTION_TOKEN_ERROR assert(0) #define SYNTAX_ERROR cf_syn_error() #define GET_CONTEXT CONTEXT.x = PCB.column, CONTEXT.y = PCB.line static void cf_error(const char *); class CfErrorHandler : public ConfigParam::ErrorHandler { void badParam(const char *s){cf_error(s);} } cfErrorHandler; static cf_pcb_type cfcb; #define PCB cfcb extern unsigned char *input_base; static AgString config_file; void read_config(const AgString path) { LOGSECTION("read_config"); LOGV(path); config_file = path.lastCut(PATH_DELIMITER).leftI().concat("AnaGram.cfg"); text_file tf(config_file); cfcb.pointer = input_base = (unsigned char *) tf; if (input_base) cf(); config_file = "AnaGram.cfg"; tf = text_file(config_file); cfcb.pointer = input_base = (unsigned char *) tf; LOGS("Starting parse"); if (input_base) cf(); } static void cf_error(const char *msg) { errorList.push(Error(config_file, msg, 1)); } Error::Error(AgString f, AgString msg, int contextFlag) : file(f), line(contextFlag? ERROR_CONTEXT.y : PCB.line), column(contextFlag? ERROR_CONTEXT.y :PCB.column), key(warn), message(msg) { // Nothing here } static void cf_syn_error(void) { reset_stk(); cf_error(PCB.error_message); } int allow_macros = 1; int auto_init = 1; int auto_resynch = 0; int backtrack = 1; int bottom_margin = 3; int bright_background = 1; int case_sensitive = 1; AgString compile_command(""); int const_data = 1; AgString context_type; AgString coverage_file_name("#.nrc"); int declare_pcb = 1; int default_input_type; int default_token_type; int default_reductions = 1; int diagnose_errors = 1; int distinguish_lexemes = 0; AgString edit_command("ed #.syn"); int enable_mouse = 1; AgString enum_constant_name("$_%_token"); int error_frame = 0; int error_trace = 0; int escape_backslashes = 0; int event_driven = 0; int far_tables = 0; int grammar_token = 0; AgString header_file_name("#.h"); int input_values = 0; int iso_latin_1 = 1; int line_length = 80; int line_numbers = 0; AgString line_numbers_path; int lines_and_columns = 1; int main_program = 1; int max_conflicts = 50; //AgString mutex_type; int near_functions = 0; int nest_comments = 0; int old_style = 0; int page_length = 66; AgString parser_file_name("#.c"); AgString parser_name("#"); int parser_stack_alignment; int parser_stack_size = 32; int pointer_input = 0; AgString pointer_type("unsigned char *"); AgString print_file_name("LPT1"); int quick_reference = 0; int reduction_choices =0; int reentrant_parser = 0; int rule_coverage = 0; int tab_spacing = 8; int test_file_binary = 0; AgString test_file_mask("*.*"); int test_range = 1; int token_names = 0; int top_margin = 3; int traditional_engine = 0; int video_mode = -1; int trial_copy_code = 0; int error_token; int eof_token = 0; }