a68g-non-terminal.c

     
   1  //! @file a68g-non-terminal.c
   2  //! @author J. Marcel van der Veer
   3  
   4  //! @section Copyright
   5  //!
   6  //! This file is part of Algol68G - an Algol 68 compiler-interpreter.
   7  //! Copyright 2001-2024 J. Marcel van der Veer [algol68g@xs4all.nl].
   8  
   9  //! @section License
  10  //!
  11  //! This program is free software; you can redistribute it and/or modify it 
  12  //! under the terms of the GNU General Public License as published by the 
  13  //! Free Software Foundation; either version 3 of the License, or 
  14  //! (at your option) any later version.
  15  //!
  16  //! This program is distributed in the hope that it will be useful, but 
  17  //! WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
  18  //! or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 
  19  //! more details. You should have received a copy of the GNU General Public 
  20  //! License along with this program. If not, see [http://www.gnu.org/licenses/].
  21  
  22  //! @section Synopsis
  23  //!
  24  //! Non-terminal tables.
  25  
  26  #include "a68g.h"
  27  
  28  // Translate int attributes to string names.
  29  
  30  static char *attribute_names[WILDCARD + 1] = {
  31    NO_TEXT,
  32    "A68_PATTERN",
  33    "ACCO_SYMBOL",
  34    "ACTUAL_DECLARER_MARK",
  35    "ALIF_IF_PART",
  36    "ALIF_PART",
  37    "ALIF_SYMBOL",
  38    "ALT_DO_PART",
  39    "ALT_DO_SYMBOL",
  40    "ALT_EQUALS_SYMBOL",
  41    "ALT_FORMAL_BOUNDS_LIST",
  42    "ANDF_SYMBOL",
  43    "AND_FUNCTION",
  44    "ANONYMOUS",
  45    "ARGUMENT",
  46    "ARGUMENT_LIST",
  47    "ASSERTION",
  48    "ASSERT_SYMBOL",
  49    "ASSIGNATION",
  50    "ASSIGN_SYMBOL",
  51    "ASSIGN_TO_SYMBOL",
  52    "AT_SYMBOL",
  53    "BEGIN_SYMBOL",
  54    "BITS_C_PATTERN",
  55    "BITS_DENOTATION",
  56    "BITS_PATTERN",
  57    "BITS_SYMBOL",
  58    "BOLD_COMMENT_SYMBOL",
  59    "BOLD_PRAGMAT_SYMBOL",
  60    "BOLD_TAG",
  61    "BOOLEAN_PATTERN",
  62    "BOOL_SYMBOL",
  63    "BOUND",
  64    "BOUNDS",
  65    "BOUNDS_LIST",
  66    "BRIEF_OUSE_PART",
  67    "BRIEF_CONFORMITY_OUSE_PART",
  68    "BRIEF_ELIF_PART",
  69    "BRIEF_OPERATOR_DECLARATION",
  70    "BUS_SYMBOL",
  71    "BYTES_SYMBOL",
  72    "BY_PART",
  73    "BY_SYMBOL",
  74    "CALL",
  75    "CASE_CHOICE_CLAUSE",
  76    "CASE_CLAUSE",
  77    "CASE_IN_PART",
  78    "CASE_OUSE_PART",
  79    "CASE_PART",
  80    "CASE_SYMBOL",
  81    "CAST",
  82    "CHANNEL_SYMBOL",
  83    "CHAR_C_PATTERN",
  84    "CHAR_SYMBOL",
  85    "CHOICE",
  86    "CHOICE_PATTERN",
  87    "CLASS_SYMBOL",
  88    "CLOSED_CLAUSE",
  89    "CLOSE_SYMBOL",
  90    "CODE_CLAUSE",
  91    "CODE_LIST",
  92    "CODE_SYMBOL",
  93    "COLLATERAL_CLAUSE",
  94    "COLLECTION",
  95    "COLON_SYMBOL",
  96    "COLUMN_FUNCTION",
  97    "COLUMN_SYMBOL",
  98    "COMMA_SYMBOL",
  99    "COMPLEX_PATTERN",
 100    "COMPLEX_SYMBOL",
 101    "COMPL_SYMBOL",
 102    "CONDITIONAL_CLAUSE",
 103    "CONFORMITY_CHOICE",
 104    "CONFORMITY_CLAUSE",
 105    "CONFORMITY_IN_PART",
 106    "CONFORMITY_OUSE_PART",
 107    "CONSTRUCT",
 108    "DECLARATION_LIST",
 109    "DECLARER",
 110    "DEFINING_IDENTIFIER",
 111    "DEFINING_INDICANT",
 112    "DEFINING_OPERATOR",
 113    "DENOTATION",
 114    "DEPROCEDURING",
 115    "DEREFERENCING",
 116    "DIAGONAL_FUNCTION",
 117    "DIAGONAL_SYMBOL",
 118    "DOTDOT_SYMBOL",
 119    "DOWNTO_SYMBOL",
 120    "DO_PART",
 121    "DO_SYMBOL",
 122    "DYNAMIC_REPLICATOR",
 123    "EDOC_SYMBOL",
 124    "ELIF_IF_PART",
 125    "ELIF_PART",
 126    "ELIF_SYMBOL",
 127    "ELSE_BAR_SYMBOL",
 128    "ELSE_OPEN_PART",
 129    "ELSE_PART",
 130    "ELSE_SYMBOL",
 131    "EMPTY_SYMBOL",
 132    "ENCLOSED_CLAUSE",
 133    "END_SYMBOL",
 134    "ENQUIRY_CLAUSE",
 135    "ENVIRON_NAME",
 136    "ENVIRON_SYMBOL",
 137    "EQUALS_SYMBOL",
 138    "ERROR",
 139    "ERROR_IDENTIFIER",
 140    "ESAC_SYMBOL",
 141    "EXIT_SYMBOL",
 142    "EXPONENT_FRAME",
 143    "FALSE_SYMBOL",
 144    "FIELD",
 145    "FIELD_IDENTIFIER",
 146    "FILE_SYMBOL",
 147    "FIRM",
 148    "FIXED_C_PATTERN",
 149    "FI_SYMBOL",
 150    "FLEX_SYMBOL",
 151    "FLOAT_C_PATTERN",
 152    "FORMAL_BOUNDS",
 153    "FORMAL_BOUNDS_LIST",
 154    "FORMAL_DECLARERS",
 155    "FORMAL_DECLARERS_LIST",
 156    "FORMAL_DECLARER_MARK",
 157    "FORMAT_A_FRAME",
 158    "FORMAT_CLOSE_SYMBOL",
 159    "FORMAT_DELIMITER_SYMBOL",
 160    "FORMAT_D_FRAME",
 161    "FORMAT_E_FRAME",
 162    "FORMAT_IDENTIFIER",
 163    "FORMAT_ITEM_A",
 164    "FORMAT_ITEM_B",
 165    "FORMAT_ITEM_C",
 166    "FORMAT_ITEM_D",
 167    "FORMAT_ITEM_E",
 168    "FORMAT_ITEM_ESCAPE",
 169    "FORMAT_ITEM_F",
 170    "FORMAT_ITEM_G",
 171    "FORMAT_ITEM_H",
 172    "FORMAT_ITEM_I",
 173    "FORMAT_ITEM_J",
 174    "FORMAT_ITEM_K",
 175    "FORMAT_ITEM_L",
 176    "FORMAT_ITEM_M",
 177    "FORMAT_ITEM_MINUS",
 178    "FORMAT_ITEM_N",
 179    "FORMAT_ITEM_O",
 180    "FORMAT_ITEM_P",
 181    "FORMAT_ITEM_PLUS",
 182    "FORMAT_ITEM_POINT",
 183    "FORMAT_ITEM_Q",
 184    "FORMAT_ITEM_R",
 185    "FORMAT_ITEM_S",
 186    "FORMAT_ITEM_T",
 187    "FORMAT_ITEM_U",
 188    "FORMAT_ITEM_V",
 189    "FORMAT_ITEM_W",
 190    "FORMAT_ITEM_X",
 191    "FORMAT_ITEM_Y",
 192    "FORMAT_ITEM_Z",
 193    "FORMAT_I_FRAME",
 194    "FORMAT_OPEN_SYMBOL",
 195    "FORMAT_PATTERN",
 196    "FORMAT_POINT_FRAME",
 197    "FORMAT_SYMBOL",
 198    "FORMAT_TEXT",
 199    "FORMAT_Z_FRAME",
 200    "FORMULA",
 201    "FOR_PART",
 202    "FOR_SYMBOL",
 203    "FROM_PART",
 204    "FROM_SYMBOL",
 205    "GENERAL_C_PATTERN",
 206    "GENERAL_PATTERN",
 207    "GENERATOR",
 208    "GENERIC_ARGUMENT",
 209    "GENERIC_ARGUMENT_LIST",
 210    "GOTO_SYMBOL",
 211    "GO_SYMBOL",
 212    "GUARDED_CONDITIONAL_CLAUSE",
 213    "GUARDED_LOOP_CLAUSE",
 214    "HEAP_SYMBOL",
 215    "IDENTIFIER",
 216    "IDENTITY_DECLARATION",
 217    "IDENTITY_RELATION",
 218    "IF_PART",
 219    "IF_SYMBOL",
 220    "INDICANT",
 221    "INITIALISER_SERIES",
 222    "INSERTION",
 223    "INTEGRAL_C_PATTERN",
 224    "INTEGRAL_MOULD",
 225    "INTEGRAL_PATTERN",
 226    "INT_DENOTATION",
 227    "INT_SYMBOL",
 228    "IN_SYMBOL",
 229    "IN_TYPE_MODE",
 230    "ISNT_SYMBOL",
 231    "IS_SYMBOL",
 232    "JUMP",
 233    "KEYWORD",
 234    "LABEL",
 235    "LABELED_UNIT",
 236    "LABEL_IDENTIFIER",
 237    "LABEL_SEQUENCE",
 238    "LITERAL",
 239    "LOCAL_LABEL",
 240    "LOC_SYMBOL",
 241    "LONGETY",
 242    "LONG_SYMBOL",
 243    "LOOP_CLAUSE",
 244    "LOOP_IDENTIFIER",
 245    "MAIN_SYMBOL",
 246    "MEEK",
 247    "MODE_BITS",
 248    "MODE_BOOL",
 249    "MODE_BYTES",
 250    "MODE_CHAR",
 251    "MODE_COMPLEX",
 252    "MODE_DECLARATION",
 253    "MODE_FILE",
 254    "MODE_FORMAT",
 255    "MODE_INT",
 256    "MODE_LONG_LONG_BITS",
 257    "MODE_LONG_LONG_COMPLEX",
 258    "MODE_LONG_LONG_INT",
 259    "MODE_LONG_LONG_REAL",
 260    "MODE_LONG_BITS",
 261    "MODE_LONG_BYTES",
 262    "MODE_LONG_COMPLEX",
 263    "MODE_LONG_INT",
 264    "MODE_LONG_REAL",
 265    "MODE_NO_CHECK",
 266    "MODE_PIPE",
 267    "MODE_REAL",
 268    "MODE_SOUND",
 269    "MODE_SYMBOL",
 270    "MONADIC_FORMULA",
 271    "MONAD_SEQUENCE",
 272    "NEW_SYMBOL",
 273    "NIHIL",
 274    "NIL_SYMBOL",
 275    "NORMAL_IDENTIFIER",
 276    "NO_SORT",
 277    "OCCA_SYMBOL",
 278    "OD_SYMBOL",
 279    "OF_SYMBOL",
 280    "OPEN_PART",
 281    "OPEN_SYMBOL",
 282    "OPERATOR",
 283    "OPERATOR_DECLARATION",
 284    "OPERATOR_PLAN",
 285    "OP_SYMBOL",
 286    "ORF_SYMBOL",
 287    "OR_FUNCTION",
 288    "OUSE_PART",
 289    "OUSE_SYMBOL",
 290    "OUT_PART",
 291    "OUT_SYMBOL",
 292    "OUT_TYPE_MODE",
 293    "PARALLEL_CLAUSE",
 294    "PARAMETER",
 295    "PARAMETER_IDENTIFIER",
 296    "PARAMETER_LIST",
 297    "PARAMETER_PACK",
 298    "PARTICULAR_PROGRAM",
 299    "PAR_SYMBOL",
 300    "PICTURE",
 301    "PICTURE_LIST",
 302    "PIPE_SYMBOL",
 303    "POINT_SYMBOL",
 304    "PRIMARY",
 305    "PRIORITY",
 306    "PRIORITY_DECLARATION",
 307    "PRIO_SYMBOL",
 308    "PROCEDURE_DECLARATION",
 309    "PROCEDURE_VARIABLE_DECLARATION",
 310    "PROCEDURING",
 311    "PROC_SYMBOL",
 312    "QUALIFIER",
 313    "RADIX_FRAME",
 314    "REAL_DENOTATION",
 315    "REAL_PATTERN",
 316    "REAL_SYMBOL",
 317    "REF_SYMBOL",
 318    "REPLICATOR",
 319    "ROUTINE_TEXT",
 320    "ROUTINE_UNIT",
 321    "ROWING",
 322    "ROWS_SYMBOL",
 323    "ROW_CHAR_DENOTATION",
 324    "ROW_FUNCTION",
 325    "ROW_SYMBOL",
 326    "SECONDARY",
 327    "SELECTION",
 328    "SELECTOR",
 329    "SEMA_SYMBOL",
 330    "SEMI_SYMBOL",
 331    "SERIAL_CLAUSE",
 332    "SERIES_MODE",
 333    "SHORTETY",
 334    "SHORT_SYMBOL",
 335    "SIGN_MOULD",
 336    "SKIP",
 337    "SKIP_SYMBOL",
 338    "SLICE",
 339    "SOFT",
 340    "SOME_CLAUSE",
 341    "SOUND_SYMBOL",
 342    "SPECIFICATION",
 343    "SPECIFIED_UNIT",
 344    "SPECIFIED_UNIT_LIST",
 345    "SPECIFIED_UNIT_UNIT",
 346    "SPECIFIER",
 347    "SPECIFIER_IDENTIFIER",
 348    "STANDARD",
 349    "STATIC_REPLICATOR",
 350    "STOWED_MODE",
 351    "STRING_C_PATTERN",
 352    "STRING_PATTERN",
 353    "STRING_SYMBOL",
 354    "STRONG",
 355    "STRUCTURED_FIELD",
 356    "STRUCTURED_FIELD_LIST",
 357    "STRUCTURE_PACK",
 358    "STRUCT_SYMBOL",
 359    "STYLE_II_COMMENT_SYMBOL",
 360    "STYLE_I_COMMENT_SYMBOL",
 361    "STYLE_I_PRAGMAT_SYMBOL",
 362    "SUB_SYMBOL",
 363    "SUB_UNIT",
 364    "TERTIARY",
 365    "THEN_BAR_SYMBOL",
 366    "THEN_PART",
 367    "THEN_SYMBOL",
 368    "TO_PART",
 369    "TO_SYMBOL",
 370    "TRANSPOSE_FUNCTION",
 371    "TRANSPOSE_SYMBOL",
 372    "TRIMMER",
 373    "TRUE_SYMBOL",
 374    "UNION_DECLARER_LIST",
 375    "UNION_PACK",
 376    "UNION_SYMBOL",
 377    "UNIT",
 378    "UNITING",
 379    "UNIT_LIST",
 380    "UNIT_SERIES",
 381    "UNTIL_PART",
 382    "UNTIL_SYMBOL",
 383    "VARIABLE_DECLARATION",
 384    "VIRTUAL_DECLARER_MARK",
 385    "VOIDING",
 386    "VOID_SYMBOL",
 387    "WEAK",
 388    "WHILE_PART",
 389    "WHILE_SYMBOL",
 390    "WIDENING",
 391    "WILDCARD"
 392  };
 393  
 394  //! @brief Non_terminal_string.
 395  
 396  char *non_terminal_string (char *buf, int att)
 397  {
 398    if (att > 0 && att < WILDCARD) {
 399      if (attribute_names[att] != NO_TEXT) {
 400        char *q = buf;
 401        a68_bufcpy (q, attribute_names[att], BUFFER_SIZE);
 402        while (q[0] != NULL_CHAR) {
 403          if (q[0] == '_') {
 404            q[0] = '-';
 405          } else {
 406            q[0] = (char) TO_LOWER (q[0]);
 407          }
 408          q++;
 409        }
 410        return buf;
 411      } else {
 412        return NO_TEXT;
 413      }
 414    } else {
 415      return NO_TEXT;
 416    }
 417  }
     


© 2002-2024 J.M. van der Veer (jmvdveer@xs4all.nl)