diff anagram/agcore/config.cpp @ 0:13d2b8934445

Import AnaGram (near-)release tree into Mercurial.
author David A. Holland
date Sat, 22 Dec 2007 17:52:45 -0500
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/anagram/agcore/config.cpp	Sat Dec 22 17:52:45 2007 -0500
@@ -0,0 +1,239 @@
+/*
+ * AnaGram, A System for Syntax Directed Programming
+ * Copyright 1993-2002 Parsifal Software. All Rights Reserved.
+ * See the file COPYING for license and usage terms.
+ *
+ * config.cpp
+ */
+
+#include "agstring.h"
+#include "config.h"
+#include "configparam.h"
+
+//#define INCLUDE_LOGGING
+#include "log.h"
+
+
+#ifdef AG_ON_UNIX
+#define ALL_MASK "*"
+#endif
+
+#ifdef AG_ON_WINDOWS
+#define ALL_MASK "*.*"
+#endif
+
+#ifdef AG_ON_AMIGA
+#define ALL_MASK "#?"
+#endif
+
+////////////////////////////////////////////////////////////
+
+#undef INTEGER_PARAM
+#undef STRING_PARAM
+#undef SWITCH
+#undef DICT_PARAM
+#undef TOKEN_PARAM
+#undef TEXT_PARAM
+
+#define INTEGER_PARAM(txt,nm) static IntegerParam nm##Param(txt,nm); int nm
+#define STRING_PARAM(txt, nm) static StringParam  nm##Param(txt,nm);AgString nm
+#define SWITCH(txt, nm)       static ConfigSwitch nm##Param(txt,nm); int nm
+#define CAST_PARAM(txt, nm)   static CastParam    nm##Param(txt,nm); int nm
+#define TOKEN_PARAM(txt, nm)  static TokenParam   nm##Param(txt,nm); int nm
+#define TEXT_PARAM(txt, nm)   static TextParam    nm##Param(txt,nm);AgString nm
+
+SWITCH       ("allow macros",           allow_macros)           = 1;
+SWITCH       ("auto init",              auto_init)              = 1;
+SWITCH       ("auto resynch",           auto_resynch)           = 0;
+
+SWITCH       ("backtrack",              backtrack)              = 1;
+INTEGER_PARAM("bottom margin",          bottom_margin)          = 3;
+SWITCH       ("bright background",      bright_background)      = 1;
+
+SWITCH       ("case sensitive",         case_sensitive)         = 1;
+STRING_PARAM ("compile command",        compile_command)        = "";
+SWITCH       ("const data",             const_data)             = 1;
+TEXT_PARAM   ("context type",           context_type)           ;
+STRING_PARAM ("coverage file name",     coverage_file_name)     = "#.nrc";
+
+SWITCH       ("declare pcb",            declare_pcb)            = 1;
+CAST_PARAM   ("default input type",     default_input_type)     ;
+SWITCH       ("default reductions",     default_reductions)     = 1; 
+CAST_PARAM   ("default token type",     default_token_type)     ;
+SWITCH       ("diagnose errors",        diagnose_errors)        = 1;
+SWITCH       ("distinguish lexemes",    distinguish_lexemes)    = 0;
+
+STRING_PARAM ("edit command",           edit_command)           = "ed #.syn";
+SWITCH       ("enable mouse",           enable_mouse)           = 1;
+STRING_PARAM ("enum constant name",     enum_constant_name)     = "$_%_token";
+TOKEN_PARAM  ("eof token",              eof_token)              = 0;
+SWITCH       ("error frame",            error_frame)            = 0;
+TOKEN_PARAM  ("error token",            error_token)            ;
+SWITCH       ("error trace",            error_trace)            = 0;
+SWITCH       ("escape backslashes",     escape_backslashes)     = 0;
+SWITCH       ("event driven",           event_driven)           = 0;
+
+SWITCH       ("far tables",             far_tables)             = 0;
+
+TOKEN_PARAM  ("grammar token",          grammar_token)          = 0;
+
+STRING_PARAM ("header file name",       header_file_name)       = "#.h";
+
+SWITCH       ("input values",           input_values)           = 0;
+SWITCH       ("iso latin 1",            iso_latin_1)            = 1;
+
+INTEGER_PARAM("line length",            line_length)            = 80;
+SWITCH       ("line numbers",           line_numbers)           = 0;
+STRING_PARAM ("line numbers path",      line_numbers_path)      ;
+SWITCH       ("lines and columns",      lines_and_columns)      = 1;
+
+SWITCH       ("main program",           main_program)           = 1;
+INTEGER_PARAM("max conflicts",          max_conflicts)          = 50;
+
+SWITCH       ("near functions",         near_functions)         = 0;
+SWITCH       ("nest comments",          nest_comments)          = 0;
+SWITCH       ("no cr",                  no_cr)                  = 0;
+
+SWITCH       ("old style",              old_style)              = 0;
+
+INTEGER_PARAM("page length",            page_length)            = 66;
+STRING_PARAM ("parser file name",       parser_file_name)       = "#.c";
+TEXT_PARAM   ("parser name",            parser_name)            = "#";
+CAST_PARAM   ("parser stack alignment", parser_stack_alignment) ;
+INTEGER_PARAM("parser stack size",      parser_stack_size)      = 128;
+SWITCH       ("pointer input",          pointer_input)          = 0;
+TEXT_PARAM   ("pointer type",           pointer_type)      = "unsigned char *";
+STRING_PARAM ("print file name",        print_file_name)        = "LPT1";
+
+SWITCH       ("quick reference",        quick_reference)        = 0;
+
+SWITCH       ("reduction choices",      reduction_choices)      = 0;
+SWITCH       ("reentrant parser",       reentrant_parser)       = 0;
+SWITCH       ("rule coverage",          rule_coverage)          = 0;
+
+INTEGER_PARAM("tab spacing",            tab_spacing)            = 8;
+SWITCH       ("test file binary",       test_file_binary)       = 0;
+STRING_PARAM ("test file mask",         test_file_mask)         = ALL_MASK;
+SWITCH       ("test range",             test_range)             = 1;
+SWITCH       ("token names",            token_names)            = 0;
+SWITCH       ("token names only",       token_names_only)       = 0;
+INTEGER_PARAM("top margin",             top_margin)             = 3;
+SWITCH       ("traditional engine",     traditional_engine)     = 0;
+
+INTEGER_PARAM("video mode",             video_mode)             = -1;
+
+////////////////////////////////////////////////////////////
+
+#define PARAM_REF(name) &name##Param
+
+ConfigParam *ConfigParam::table[] = {
+  PARAM_REF(allow_macros),
+  PARAM_REF(auto_init),
+  PARAM_REF(auto_resynch),
+
+  PARAM_REF(backtrack),
+  PARAM_REF(bottom_margin),
+  PARAM_REF(bright_background),
+
+  PARAM_REF(case_sensitive),
+  PARAM_REF(compile_command),
+  PARAM_REF(const_data),
+  PARAM_REF(context_type),
+  PARAM_REF(coverage_file_name),
+
+  PARAM_REF(declare_pcb),
+  PARAM_REF(default_input_type),
+  PARAM_REF(default_reductions),
+  PARAM_REF(default_token_type),
+  PARAM_REF(diagnose_errors),
+  PARAM_REF(distinguish_lexemes),
+
+  PARAM_REF(edit_command),
+  PARAM_REF(enable_mouse),
+  PARAM_REF(enum_constant_name),
+  PARAM_REF(eof_token),
+  PARAM_REF(error_frame),
+  PARAM_REF(error_token),
+  PARAM_REF(error_trace),
+  PARAM_REF(escape_backslashes),
+  PARAM_REF(event_driven),
+
+  PARAM_REF(far_tables),
+
+  PARAM_REF(grammar_token),
+
+  PARAM_REF(header_file_name),
+
+  PARAM_REF(input_values),
+  PARAM_REF(iso_latin_1),
+
+  PARAM_REF(line_length),
+  PARAM_REF(line_numbers),
+  PARAM_REF(line_numbers_path),
+  PARAM_REF(lines_and_columns),
+
+  PARAM_REF(main_program),
+  PARAM_REF(max_conflicts),
+
+  PARAM_REF(near_functions),
+  PARAM_REF(nest_comments),
+  PARAM_REF(no_cr),
+
+  PARAM_REF(old_style),
+
+  PARAM_REF(page_length),
+  PARAM_REF(parser_file_name),
+  PARAM_REF(parser_name),
+  PARAM_REF(parser_stack_alignment),
+  PARAM_REF(parser_stack_size),
+  PARAM_REF(pointer_input),
+  PARAM_REF(pointer_type),
+  PARAM_REF(print_file_name),
+
+  PARAM_REF(quick_reference),
+
+  PARAM_REF(reduction_choices),
+  PARAM_REF(reentrant_parser),
+  PARAM_REF(rule_coverage),
+
+  PARAM_REF(tab_spacing),
+  PARAM_REF(test_file_binary),
+  PARAM_REF(test_file_mask),
+  PARAM_REF(test_range),
+  PARAM_REF(token_names),
+  PARAM_REF(token_names_only),
+  PARAM_REF(top_margin),
+  PARAM_REF(traditional_engine),
+  //PARAM_REF(trial_copy_code),
+
+  PARAM_REF(video_mode),
+};
+
+int ConfigParam::paramCount = sizeof(ConfigParam::table)/sizeof(ConfigParam *);
+
+#ifdef __IBMCPP__
+#pragma define(Param<int>)
+#pragma define(Param<AgString>)
+#endif
+
+#ifdef _MSC_VER
+template class Param<int>;
+template class Param<AgString>;
+#endif
+
+#ifdef __GNUC__
+template class Param<int>;
+template class Param<AgString>;
+#endif
+
+#ifdef __WATCOM_CPLUSPLUS__
+typedef Param<int> fake1;
+template Param<AgString> fake2;
+#endif
+
+#ifdef __BCPLUSPLUS__
+#pragma option -Jgd
+typedef Param<int> fake1;
+template Param<AgString> fake2;
+#endif
+