module documentation

A simplified parser for nwscript.nss.

Class Constant A constant definition from the language spec (e.g. const int TRUE = 1;).
Class Function Undocumented
Class FunctionArg Undocumented
Class LanguageSpec Undocumented
Function read Reads a language specification from a given file.
Constant _CONST_RX Undocumented
Constant _FUNC_ARG_RX Undocumented
Constant _FUNC_RX Undocumented
Constant _VM_TYPE_RX Undocumented
def read(file: TextIO) -> LanguageSpec: (source)

Reads a language specification from a given file.

Parameters
file:TextIOA file-like object containing the language specification; usually nwscript.nss.
Returns
LanguageSpecAn object containing constants and functions parsed from the file.
Raises
ValueErrorIf the parsing fails.
_CONST_RX = (source)

Undocumented

Value
re.compile(('(' + _VM_TYPE_RX + ')' + '\\s+([A-Z0-9_]+)\\s*=\\s*([^;]+);'))
_FUNC_ARG_RX = (source)

Undocumented

Value
re.compile(('\\s*(' + _VM_TYPE_RX + ')\\s+(\\w+)(?:\\s*=\\s*(' + re.escape('[0.0,
0.0,0.0]') + '|[\\w\\"-]+))?'))
_FUNC_RX = (source)

Undocumented

Value
re.compile(('\\b(' + _VM_TYPE_RX + ')\\s+(\\w+)\\s*\\((.*?)\\)\\s*;'))
_VM_TYPE_RX = (source)

Undocumented

Value
'(?:' + '|'.join([f.value for f in VMType]) + ')'