view examples/dsl/symbol.h @ 24:a4899cdfc2d6 default tip

Obfuscate the regexps to strip off the IBM compiler's copyright banners. I don't want bots scanning github to think they're real copyright notices because that could cause real problems.
author David A. Holland
date Mon, 13 Jun 2022 00:40:23 -0400
parents 13d2b8934445
children
line wrap: on
line source

/*****

 AnaGram Programming Examples

 A Dos Script Language
 Symbol Table Declarations

 Copyright 1993 Parsifal Software. All Rights Reserved.

 This software is provided 'as-is', without any express or implied
 warranty.  In no event will the authors be held liable for any damages
 arising from the use of this software.

 Permission is granted to anyone to use this software for any purpose,
 including commercial applications, and to alter it and redistribute it
 freely, subject to the following restrictions:

 1. The origin of this software must not be misrepresented; you must not
    claim that you wrote the original software. If you use this software
    in a product, an acknowledgment in the product documentation would be
    appreciated but is not required.
 2. Altered source versions must be plainly marked as such, and must not be
    misrepresented as being the original software.
 3. This notice may not be removed or altered from any source distribution.

*****/

#ifndef SYMBOL_H
#define SYMBOL_H

#include "array.h"
#include "charsink.h"
#include "strdict.h"

struct action_pointer {
  unsigned char *pointer;
  int line, column;
};

enum symbol_type {
  undefined_type,
  dos_type,
  action_type,
  value_type,
  internal_type,
  integer_type,
  string_type,
  formula_type,
  built_in_function_type
};

struct action_descriptor {
  int n_args;
  unsigned *args;
  action_pointer ap;
};

struct symbol_table_entry {
  symbol_type type;
  union {
    char *text;
    int (*proc)(int, char *[]);
    long (*func)(void);
    action_descriptor *action;
    long integer;
  } data;
};

struct internal_commands_descriptor {
  const char *name;
  int (*proc)(int n_args, char *args[]);
};

struct built_ins_descriptor {
  const char *name;
  long (*proc) (void);
};

extern string_accumulator        sa;
extern string_dictionary         sd;
extern array<symbol_table_entry> st;

void define_action(int n);
void define_integer(const char *name, long value);
void define_string(void);
void expand_formula(const int *s);
void init_dos_internals(void);
void release(action_descriptor *d);
void release(symbol_table_entry &s);
void set_arg(int, char *);

#endif