include "category.s7i";
include "bstring.s7i";
include "bigint.s7i";
include "float.s7i";
include "external_file.s7i";
include "graph.s7i";
include "poll.s7i";
include "process.s7i";
const type: program is subtype object;
IN_PARAM_IS_REFERENCE(program);
const proc: (ref program: dest) ::= (ref program: source) is action "PRG_CREATE";
const proc: destroy (ref program: aValue) is action "PRG_DESTR";
const proc: (inout program: dest) := (ref program: source) is action "PRG_CPY";
const func program: _GENERATE_EMPTY_PROG is action "PRG_EMPTY";
const program: (attr program) . EMPTY is _GENERATE_EMPTY_PROG;
const program: (attr program) . value is program.EMPTY;
const func boolean: (in program: prog1) = (in program: prog2) is action "PRG_EQ";
const func boolean: (in program: prog1) <> (in program: prog2) is action "PRG_NE";
const func string: name (in program: aProgram) is action "PRG_NAME";
const func string: path (in program: aProgram) is action "PRG_PATH";
const type: singleParseOption is new enum
TRACE_ACTIONS,
TRACE_DO_ACTION_CHECK,
TRACE_DYNAMIC_CALLS,
TRACE_EXCEPTIONS,
TRACE_HEAP_SIZE,
TRACE_MATCH,
TRACE_EXECUTIL,
WRITE_LIBRARY_NAMES,
WRITE_LINE_NUMBERS,
SHOW_IDENT_TABLE,
SHOW_STATISTICS
end enum;
const type: parseOptions is set of singleParseOption;
const func program: parseFile (in string: fileName, in parseOptions: options,
in array string: libraryDirs,
in string: protFileName) is action "PRG_FIL_PARSE";
const func program: parseFile (in string: fileName, in parseOptions: options,
in array string: libraryDirs) is
return parseFile(fileName, options, libraryDirs, "");
const func program: parseFile (in string: fileName, in parseOptions: options) is
return parseFile(fileName, options, 0 times "", "");
const func program: parseFile (in string: fileName) is
return parseFile(fileName, parseOptions.value, 0 times "", "");
const func program: parseStri (in string: stri, in parseOptions: options,
in array string: libraryDirs,
in string: protFileName) is action "PRG_STR_PARSE";
const func program: parseStri (in string: stri, in parseOptions: options,
in array string: libraryDirs) is
return parseStri(stri, options, libraryDirs, "");
const func program: parseStri (in string: stri, in parseOptions: options) is
return parseStri(stri, options, 0 times "", "");
const func program: parseStri (in string: stri) is
return parseStri(stri, parseOptions.value, 0 times "", "");
const func program: parseStri (in bstring: bstri, in parseOptions: options,
in array string: libraryDirs,
in string: protFileName) is action "PRG_BSTRI_PARSE";
const func program: parseStri (in bstring: bstri, in parseOptions: options,
in array string: libraryDirs) is
return parseStri(bstri, options, libraryDirs, "");
const func program: parseStri (in bstring: bstri, in parseOptions: options) is
return parseStri(bstri, options, 0 times "", "");
const func program: parseStri (in bstring: bstri) is
return parseStri(bstri, parseOptions.value, 0 times "", "");
const func reference: evaluate (in program: aProgram,
in reference: anExpression) is action "PRG_EVAL";
const proc: execute (in program: aProgram, in array string: parameters,
in parseOptions: options,
in string: protFileName) is action "PRG_EXEC";
const proc: execute (in program: aProgram, in array string: parameters,
in parseOptions: options) is func
begin
execute(aProgram, parameters, options, "");
end func;
const proc: execute (in program: aProgram, in array string: parameters) is func
begin
execute(aProgram, parameters, parseOptions.value, "");
end func;
const proc: execute (in program: aProgram) is func
begin
execute(aProgram, 0 times "", parseOptions.value, "");
end func;
const func reference: sysVar (in program: aProgram, in string: name) is action "PRG_SYSVAR";
const func integer: errorCount (in program: aProgram) is action "PRG_ERROR_COUNT";
const type: errorType is new enum
OUT_OF_HEAP_SPACE,
NO_SOURCEFILE,
FILENOTFOUND,
EOF_ENCOUNTERED,
CHAR_ILLEGAL,
COMMENTOPEN,
ILLEGALPRAGMA,
WRONGACTION,
WRONGSYSTEM,
CARD_DECIMAL_TOO_BIG,
NEGATIVEEXPONENT,
DIGITEXPECTED,
CARD_WITH_EXPONENT_TOO_BIG,
BASE2TO36ALLOWED,
EXTDIGITEXPECTED,
ILLEGALBASEDDIGIT,
CARD_BASED_TOO_BIG,
APOSTROPHEXPECTED,
CHAREXCEEDS,
WRONG_QUOTATION_REPRESENTATION,
STRINGESCAPE,
WRONGNUMERICALESCAPE,
NUMERICAL_ESCAPE_TOO_BIG,
BACKSLASHEXPECTED,
STRINGEXCEEDS,
NAMEEXPECTED,
CARD_EXPECTED,
STRI_EXPECTED,
IDENT_EXPECTED,
EXPR_EXPECTED,
PARAM_DECL_FAILED,
DECL_FAILED,
EXCEPTION_RAISED,
OBJTWICEDECLARED,
PREVIOUS_DECLARATION,
ILLEGAL_ASSOCIATIVITY,
ILLEGAL_PRIORITY,
TWO_PARAMETER_SYNTAX,
EMPTY_SYNTAX,
SYNTAX_DECLARED_TWICE,
DOT_EXPR_EXPECTED,
REDECLARED_INFIX_PRIORITY,
REDECLARED_PREFIX_PRIORITY,
WRONG_EXPR_PARAM_PRIORITY,
WRONG_PREFIX_PRIORITY,
DOT_EXPR_ILLEGAL,
EXPECTED_SYMBOL,
LITERAL_TYPE_UNDEFINED,
KIND_OF_IN_PARAM_UNDEFINED,
DOLLAR_VALUE_WRONG,
DOLLAR_TYPE_WRONG,
NO_MATCH,
WRONGACCESSRIGHT,
TYPE_EXPECTED,
PROC_EXPECTED,
PARAM_SPECIFIER_EXPECTED,
PARAM_DECL_OR_SYMBOL_EXPECTED,
OVERLONG_UTF8_ENCODING,
UTF16_SURROGATE_CHAR_FOUND,
CHAR_NOT_UNICODE,
UTF8_CONTINUATION_BYTE_EXPECTED,
UNEXPECTED_UTF8_CONTINUATION_BYTE,
SOLITARY_UTF8_START_BYTE,
UTF16_BYTE_ORDER_MARK_FOUND,
WRONG_PATH_DELIMITER,
EXCEPTION_EXPECTED,
ESSENTIAL_INCLUDE_FAILED,
SYSTEM_MAIN_MISSING
end enum;
const func string: str (in errorType: error) is
return literal(error);
enable_output(errorType);
const type: parseError is new struct
var errorType: error is errorType.value;
var string: fileName is "";
var integer: lineNumber is 0;
var integer: columnNumber is 0;
var string: message is "";
var string: errorLine is "";
end struct;
const proc: DO_GET_ERROR (in program: aProgram, in integer: errorIndex,
inout integer: errorNumber, inout string: fileName,
inout integer: lineNumber, inout integer: columnNumber,
inout string: msg, inout string: errorLine) is action "PRG_GET_ERROR";
const func parseError: getError (in program: aProgram, in integer: errorIndex) is func
result
var parseError: error is parseError.value;
local
var integer: errorNumber is 0;
begin
DO_GET_ERROR(aProgram, errorIndex, errorNumber,
error.fileName, error.lineNumber, error.columnNumber,
error.message, error.errorLine);
error.error := errorType conv errorNumber;
end func;
const func ref_list: globalObjects (in program: aProgram) is action "PRG_GLOBAL_OBJECTS";
const func reference: syobject (in program: aProgram, in string: name) is action "PRG_SYOBJECT";
const func reference: match (in program: aProgram, in ref_list: expression) is action "PRG_MATCH";
const func reference: matchExpr (in program: aProgram, in ref_list: expression) is action "PRG_MATCH_EXPR";
const func boolean: isTemp (in reference: aReference) is action "REF_ISTEMP";
const func boolean: isVar (in reference: aReference) is action "REF_ISVAR";
const proc: setVar (in reference: aReference, in boolean: isVariable) is action "REF_SETVAR";
const func category: category (in reference: aReference) is action "REF_CATEGORY";
const proc: setCategory (in reference: aReference,
in category: aCategory) is action "REF_SETCATEGORY";
const func ref_list: formalParams (in reference: funcRef) is action "REF_PARAMS";
const proc: setFormalParams (in reference: funcRef, in ref_list: params) is action "REF_SETPARAMS";
const func reference: resultVar (in reference: funcRef) is action "REF_RESULT";
const func reference: resultInitValue (in reference: funcRef) is action "REF_RESINI";
const func ref_list: localConsts (in reference: funcRef) is action "REF_LOCAL_CONSTS";
const func ref_list: localVars (in reference: funcRef) is action "REF_LOCAL_VARS";
const func reference: body (in reference: funcRef) is action "REF_BODY";
const func integer: arrayMinIdx (in reference: arrayRef) is action "REF_ARRMINIDX";
const func integer: arrayMaxIdx (in reference: arrayRef) is action "REF_ARRMAXIDX";
const func integer: arrayLength (in reference: arrayRef) is
return succ(arrayMaxIdx(arrayRef) - arrayMinIdx(arrayRef));
const func ref_list: arrayToList (in reference: arrayRef) is action "REF_ARRTOLIST";
const func ref_list: structToList (in reference: structRef) is action "REF_SCTTOLIST";
const func ref_list: hashDataToList (in reference: hashRef) is action "REF_HSHDATATOLIST";
const func ref_list: hashKeysToList (in reference: hashRef) is action "REF_HSHKEYSTOLIST";
const func integer: hashLength (in reference: hashRef) is action "REF_HSHLENGTH";
const func reference: interfaceToStruct (in reference: interfaceRef) is action "REF_ITFTOSCT";
const func string: file (in reference: aReference) is action "REF_FILE";
const func integer: line (in reference: aReference) is action "REF_LINE";
const func integer: objNumber (in reference: aReference) is action "REF_NUM";
const func reference: alloc (in reference: aReference) is action "REF_ALLOC";
const func reference: alloc (in boolean: isVar, in type: aType, in integer: number) is action "REF_ALLOC_INT";
const func reference: alloc (in boolean: isVar, in type: aType, in string: stri) is action "REF_ALLOC_STRI";
const func reference: allocVar (in type: aType, in category: aCategory) is action "REF_ALLOC_VAR";
const func boolean: getValue (in reference: aReference, attr boolean) is action "BLN_VALUE";
const func integer: getValue (in reference: aReference, attr integer) is action "INT_VALUE";
const func char: getValue (in reference: aReference, attr char) is action "CHR_VALUE";
const func string: getValue (in reference: aReference, attr string) is action "STR_VALUE";
const func bstring: getValue (in reference: aReference, attr bstring) is action "BST_VALUE";
const func bitset: getValue (in reference: aReference, attr bitset) is action "SET_VALUE";
const func pollData: getValue (in reference: aReference, attr pollData) is action "POL_VALUE";
const func program: getValue (in reference: aReference, attr program) is action "PRG_VALUE";
const func ACTION: getValue (in reference: aReference, attr ACTION) is action "ACT_VALUE";
const func clib_file: getValue (in reference: aReference, attr clib_file) is action "FIL_VALUE";
const func ref_list: getValue (in reference: aReference, attr ref_list) is action "RFL_VALUE";
const func bigInteger: getValue (in reference: aReference, attr bigInteger) is action "BIG_VALUE";
const func float: getValue (in reference: aReference, attr float) is action "FLT_VALUE";
const func reference: getValue (in reference: aReference, attr reference) is action "REF_VALUE";
const func PRIMITIVE_WINDOW: getValue (in reference: aReference,
attr PRIMITIVE_WINDOW) is action "DRW_VALUE";
const func pointList: getValue (in reference: aReference, attr pointList) is action "PLT_VALUE";
const func process: getValue (in reference: aReference, attr process) is action "PCS_VALUE";
const proc: setValue(inout reference: listRef, in ref_list: list) is action "RFL_SET_VALUE";
const func integer: typeNumber (in type: aType) is action "TYP_NUM";
const func reference: typeObject (in type: aType) is action "TYP_MATCHOBJ";