--- linuxsampler/trunk/src/scriptvm/common.h 2016/07/17 12:10:06 2960 +++ linuxsampler/trunk/src/scriptvm/common.h 2019/08/18 00:06:04 3557 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2016 Christian Schoenebeck + * Copyright (c) 2014-2019 Christian Schoenebeck * * http://www.linuxsampler.org * @@ -9,7 +9,8 @@ // This header defines data types shared between the VM core implementation // (inside the current source directory) and other parts of the sampler -// (located at other source directories). +// (located at other source directories). It also acts as public API of the +// Real-Time script engine for other applications. #ifndef LS_INSTR_SCRIPT_PARSER_COMMON_H #define LS_INSTR_SCRIPT_PARSER_COMMON_H @@ -22,6 +23,20 @@ namespace LinuxSampler { /** + * Native data type used by the script engine both internally, as well as + * for all integer data types used by scripts (i.e. for all $foo variables + * in NKSP scripts). Note that this is different from the original KSP which + * is limited to 32 bit for integer variables in KSP scripts. + */ + typedef int64_t vmint; + + /** + * Native data type used internally by the script engine for all unsigned + * integer types. This type is currently not exposed to scripts. + */ + typedef uint64_t vmuint; + + /** * Identifies the type of a noteworthy issue identified by the script * parser. That's either a parser error or parser warning. */ @@ -80,8 +95,17 @@ * * Identifies one of the possible event handler callback types defined by * the NKSP script language. + * + * IMPORTANT: this type is forced to be emitted as int32_t type ATM, because + * that's the native size expected by the built-in instrument script + * variable bindings (see occurrences of VMInt32RelPtr and DECLARE_VMINT + * respectively. A native type mismatch between the two could lead to + * undefined behavior! Background: By definition the C/C++ compiler is free + * to choose a bit size for individual enums which it might find + * appropriate, which is usually decided by the compiler according to the + * biggest enum constant value defined (in practice it is usually 32 bit). */ - enum VMEventHandlerType_t { + enum VMEventHandlerType_t : int32_t { VM_EVENT_HANDLER_INIT, ///< Initilization event handler, that is script's "on init ... end on" code block. VM_EVENT_HANDLER_NOTE, ///< Note event handler, that is script's "on note ... end on" code block. VM_EVENT_HANDLER_RELEASE, ///< Release event handler, that is script's "on release ... end on" code block. @@ -93,6 +117,7 @@ class VMStringExpr; class VMIntArrayExpr; class VMStringArrayExpr; + class VMParserContext; /** @brief Virtual machine expression * @@ -157,9 +182,17 @@ * expressions to an array expression for you, instead this method will * simply return NULL! * + * @b Note: this method is currently, and in contrast to its other + * counter parts, declared as virtual method. Some deriving classes are + * currently using this to override this default implementation in order + * to implement an "evaluate now as integer array" behavior. This has + * efficiency reasons, however this also currently makes this part of + * the API less clean and should thus be addressed in future with + * appropriate changes to the API. + * * @see exprType() */ - VMIntArrayExpr* asIntArray() const; + virtual VMIntArrayExpr* asIntArray() const; /** * Returns true in case this expression can be considered to be a @@ -205,7 +238,7 @@ * Returns the result of this expression as integer (scalar) value. * This abstract method must be implemented by deriving classes. */ - virtual int evalInt() = 0; + virtual vmint evalInt() = 0; /** * Returns always INT_EXPR for instances of this class. @@ -247,7 +280,7 @@ * Returns amount of elements in this array. This abstract method must * be implemented by deriving classes. */ - virtual int arraySize() const = 0; + virtual vmint arraySize() const = 0; }; /** @brief Virtual Machine Integer Array Expression @@ -265,7 +298,7 @@ * * @param i - array element index (must be between 0 .. arraySize() - 1) */ - virtual int evalIntElement(uint i) = 0; + virtual vmint evalIntElement(vmuint i) = 0; /** * Changes the current value of an element (given by array element @@ -274,7 +307,7 @@ * @param i - array element index (must be between 0 .. arraySize() - 1) * @param value - new integer scalar value to be assigned to that array element */ - virtual void assignIntElement(uint i, int value) = 0; + virtual void assignIntElement(vmuint i, vmint value) = 0; /** * Returns always INT_ARR_EXPR for instances of this class. @@ -296,7 +329,7 @@ * Returns the amount of arguments going to be passed to the script * function. */ - virtual int argsCount() const = 0; + virtual vmint argsCount() const = 0; /** * Returns the respective argument (requested by argument index @a i) of @@ -306,7 +339,7 @@ * * @param i - function argument index (indexed from left to right) */ - virtual VMExpr* arg(int i) = 0; + virtual VMExpr* arg(vmint i) = 0; }; /** @brief Result value returned from a call to a built-in script function. @@ -370,14 +403,14 @@ * script is calling this function with less arguments, the script * parser will throw a parser error. */ - virtual int minRequiredArgs() const = 0; + virtual vmint minRequiredArgs() const = 0; /** * Maximum amount of function arguments this functions accepts. If a * script is calling this function with more arguments, the script * parser will throw a parser error. */ - virtual int maxAllowedArgs() const = 0; + virtual vmint maxAllowedArgs() const = 0; /** * Script data type of the function's @c iArg 'th function argument. @@ -393,7 +426,7 @@ * @param iArg - index of the function argument in question * (must be between 0 .. maxAllowedArgs() - 1) */ - virtual ExprType_t argType(int iArg) const = 0; + virtual ExprType_t argType(vmint iArg) const = 0; /** * This method is called by the parser to check whether arguments @@ -411,7 +444,7 @@ * @return true if the given data type would be accepted for the * respective function argument by the function */ - virtual bool acceptsArgType(int iArg, ExprType_t type) const = 0; + virtual bool acceptsArgType(vmint iArg, ExprType_t type) const = 0; /** * This method is called by the parser to check whether some arguments @@ -426,7 +459,7 @@ * @param iArg - index of the function argument in question * (must be between 0 .. maxAllowedArgs() - 1) */ - virtual bool modifiesArg(int iArg) const = 0; + virtual bool modifiesArg(vmint iArg) const = 0; /** * Implements the actual function execution. This exec() method is @@ -460,25 +493,85 @@ /** @brief Virtual machine relative pointer. * - * POD base of VMIntRelPtr and VMInt8RelPtr structures. Not intended to be - * used directly. Use VMIntRelPtr or VMInt8RelPtr instead. + * POD base of VMInt64RelPtr, VMInt32RelPtr and VMInt8RelPtr structures. Not + * intended to be used directly. Use VMInt64RelPtr, VMInt32RelPtr, + * VMInt8RelPtr instead. * - * @see VMIntRelPtr, VMInt8RelPtr + * @see VMInt64RelPtr, VMInt32RelPtr, VMInt8RelPtr */ struct VMRelPtr { void** base; ///< Base pointer. - int offset; ///< Offset (in bytes) relative to base pointer. + vmint offset; ///< Offset (in bytes) relative to base pointer. bool readonly; ///< Whether the pointed data may be modified or just be read. }; - /** @brief Pointer to built-in VM integer variable (of C/C++ type int). + /** @brief Pointer to built-in VM integer variable (interface class). + * + * This class acts as an abstract interface to all built-in integer script + * variables, independent of their actual native size (i.e. some built-in + * script variables are internally using a native int size of 64 bit or 32 + * bit or 8 bit). The virtual machine is using this interface class instead + * of its implementing descendants (VMInt64RelPtr, VMInt32RelPtr, + * VMInt8RelPtr) in order for the virtual machine for not being required to + * handle each of them differently. + */ + struct VMIntPtr { + virtual vmint evalInt() = 0; + virtual void assign(vmint i) = 0; + virtual bool isAssignable() const = 0; + }; + + /** @brief Pointer to built-in VM integer variable (of C/C++ type int64_t). + * + * Used for defining built-in 64 bit integer script variables. + * + * @b CAUTION: You may only use this class for pointing to C/C++ variables + * of type "int64_t" (thus being exactly 64 bit in size). If the C/C++ int + * variable you want to reference is only 32 bit in size then you @b must + * use VMInt32RelPtr instead! Respectively for a referenced native variable + * with only 8 bit in size you @b must use VMInt8RelPtr instead! + * + * For efficiency reasons the actual native C/C++ int variable is referenced + * by two components here. The actual native int C/C++ variable in memory + * is dereferenced at VM run-time by taking the @c base pointer dereference + * and adding @c offset bytes. This has the advantage that for a large + * number of built-in int variables, only one (or few) base pointer need + * to be re-assigned before running a script, instead of updating each + * built-in variable each time before a script is executed. + * + * Refer to DECLARE_VMINT() for example code. + * + * @see VMInt32RelPtr, VMInt8RelPtr, DECLARE_VMINT() + */ + struct VMInt64RelPtr : VMRelPtr, VMIntPtr { + VMInt64RelPtr() { + base = NULL; + offset = 0; + readonly = false; + } + VMInt64RelPtr(const VMRelPtr& data) { + base = data.base; + offset = data.offset; + readonly = false; + } + vmint evalInt() OVERRIDE { + return (vmint)*(int64_t*)&(*(uint8_t**)base)[offset]; + } + void assign(vmint i) OVERRIDE { + *(int64_t*)&(*(uint8_t**)base)[offset] = (int64_t)i; + } + bool isAssignable() const OVERRIDE { return !readonly; } + }; + + /** @brief Pointer to built-in VM integer variable (of C/C++ type int32_t). * * Used for defining built-in 32 bit integer script variables. * * @b CAUTION: You may only use this class for pointing to C/C++ variables - * of type "int" (which on most systems is 32 bit in size). If the C/C++ int - * variable you want to reference is only 8 bit in size, then you @b must - * use VMInt8RelPtr instead! + * of type "int32_t" (thus being exactly 32 bit in size). If the C/C++ int + * variable you want to reference is 64 bit in size then you @b must use + * VMInt64RelPtr instead! Respectively for a referenced native variable with + * only 8 bit in size you @b must use VMInt8RelPtr instead! * * For efficiency reasons the actual native C/C++ int variable is referenced * by two components here. The actual native int C/C++ variable in memory @@ -490,21 +583,26 @@ * * Refer to DECLARE_VMINT() for example code. * - * @see VMInt8RelPtr, DECLARE_VMINT() + * @see VMInt64RelPtr, VMInt8RelPtr, DECLARE_VMINT() */ - struct VMIntRelPtr : VMRelPtr { - VMIntRelPtr() { + struct VMInt32RelPtr : VMRelPtr, VMIntPtr { + VMInt32RelPtr() { base = NULL; offset = 0; readonly = false; } - VMIntRelPtr(const VMRelPtr& data) { + VMInt32RelPtr(const VMRelPtr& data) { base = data.base; offset = data.offset; readonly = false; } - virtual int evalInt() { return *(int*)&(*(uint8_t**)base)[offset]; } - virtual void assign(int i) { *(int*)&(*(uint8_t**)base)[offset] = i; } + vmint evalInt() OVERRIDE { + return (vmint)*(int32_t*)&(*(uint8_t**)base)[offset]; + } + void assign(vmint i) OVERRIDE { + *(int32_t*)&(*(uint8_t**)base)[offset] = (int32_t)i; + } + bool isAssignable() const OVERRIDE { return !readonly; } }; /** @brief Pointer to built-in VM integer variable (of C/C++ type int8_t). @@ -513,8 +611,9 @@ * * @b CAUTION: You may only use this class for pointing to C/C++ variables * of type "int8_t" (8 bit integer). If the C/C++ int variable you want to - * reference is an "int" type (which is 32 bit on most systems), then you - * @b must use VMIntRelPtr instead! + * reference is not exactly 8 bit in size then you @b must respectively use + * either VMInt32RelPtr for native 32 bit variables or VMInt64RelPtrl for + * native 64 bit variables instead! * * For efficiency reasons the actual native C/C++ int variable is referenced * by two components here. The actual native int C/C++ variable in memory @@ -526,27 +625,56 @@ * * Refer to DECLARE_VMINT() for example code. * - * @see VMIntRelPtr, DECLARE_VMINT() + * @see VMIntRel32Ptr, VMIntRel64Ptr, DECLARE_VMINT() */ - struct VMInt8RelPtr : VMIntRelPtr { - VMInt8RelPtr() : VMIntRelPtr() {} - VMInt8RelPtr(const VMRelPtr& data) : VMIntRelPtr(data) {} - virtual int evalInt() OVERRIDE { - return *(uint8_t*)&(*(uint8_t**)base)[offset]; + struct VMInt8RelPtr : VMRelPtr, VMIntPtr { + VMInt8RelPtr() { + base = NULL; + offset = 0; + readonly = false; + } + VMInt8RelPtr(const VMRelPtr& data) { + base = data.base; + offset = data.offset; + readonly = false; + } + vmint evalInt() OVERRIDE { + return (vmint)*(uint8_t*)&(*(uint8_t**)base)[offset]; } - virtual void assign(int i) OVERRIDE { - *(uint8_t*)&(*(uint8_t**)base)[offset] = i; + void assign(vmint i) OVERRIDE { + *(uint8_t*)&(*(uint8_t**)base)[offset] = (uint8_t)i; } + bool isAssignable() const OVERRIDE { return !readonly; } }; + /** @brief Pointer to built-in VM integer variable (of C/C++ type vmint). + * + * Use this typedef if the native variable to be pointed to is using the + * typedef vmint. If the native C/C++ variable to be pointed to is using + * another C/C++ type then better use one of VMInt64RelPtr or VMInt32RelPtr + * instead. + */ + typedef VMInt64RelPtr VMIntRelPtr; + + #if HAVE_CXX_EMBEDDED_PRAGMA_DIAGNOSTICS + # define COMPILER_DISABLE_OFFSETOF_WARNING \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Winvalid-offsetof\"") + # define COMPILER_RESTORE_OFFSETOF_WARNING \ + _Pragma("GCC diagnostic pop") + #else + # define COMPILER_DISABLE_OFFSETOF_WARNING + # define COMPILER_RESTORE_OFFSETOF_WARNING + #endif + /** - * Convenience macro for initializing VMIntRelPtr and VMInt8RelPtr - * structures. Usage example: + * Convenience macro for initializing VMInt64RelPtr, VMInt32RelPtr and + * VMInt8RelPtr structures. Usage example: * @code * struct Foo { * uint8_t a; // native representation of a built-in integer script variable - * int b; // native representation of another built-in integer script variable - * int c; // native representation of another built-in integer script variable + * int64_t b; // native representation of another built-in integer script variable + * int64_t c; // native representation of another built-in integer script variable * uint8_t d; // native representation of another built-in integer script variable * }; * @@ -557,8 +685,8 @@ * Foo* pFoo; * * VMInt8RelPtr varA = DECLARE_VMINT(pFoo, class Foo, a); - * VMIntRelPtr varB = DECLARE_VMINT(pFoo, class Foo, b); - * VMIntRelPtr varC = DECLARE_VMINT(pFoo, class Foo, c); + * VMInt64RelPtr varB = DECLARE_VMINT(pFoo, class Foo, b); + * VMInt64RelPtr varC = DECLARE_VMINT(pFoo, class Foo, c); * VMInt8RelPtr varD = DECLARE_VMINT(pFoo, class Foo, d); * * pFoo = &foo1; @@ -581,19 +709,22 @@ * complexity inside the sampler engines which provide the actual script * functionalities. */ - #define DECLARE_VMINT(basePtr, T_struct, T_member) ( \ - (VMRelPtr) { \ - (void**) &basePtr, \ - offsetof(T_struct, T_member), \ - false \ - } \ - ) \ + #define DECLARE_VMINT(basePtr, T_struct, T_member) ( \ + /* Disable offsetof warning, trust us, we are cautios. */ \ + COMPILER_DISABLE_OFFSETOF_WARNING \ + (VMRelPtr) { \ + (void**) &basePtr, \ + offsetof(T_struct, T_member), \ + false \ + } \ + COMPILER_RESTORE_OFFSETOF_WARNING \ + ) \ /** - * Same as DECLARE_VMINT(), but this one defines the VMIntRelPtr and - * VMInt8RelPtr structures to be of read-only type. That means the script - * parser will abort any script at parser time if the script is trying to - * modify such a read-only built-in variable. + * Same as DECLARE_VMINT(), but this one defines the VMInt64RelPtr, + * VMInt32RelPtr and VMInt8RelPtr structures to be of read-only type. + * That means the script parser will abort any script at parser time if the + * script is trying to modify such a read-only built-in variable. * * @b NOTE: this is only intended for built-in read-only variables that * may change during runtime! If your built-in variable's data is rather @@ -603,12 +734,15 @@ * @see ScriptVM::builtInConstIntVariables() */ #define DECLARE_VMINT_READONLY(basePtr, T_struct, T_member) ( \ - (VMRelPtr) { \ - (void**) &basePtr, \ - offsetof(T_struct, T_member), \ - true \ - } \ - ) \ + /* Disable offsetof warning, trust us, we are cautios. */ \ + COMPILER_DISABLE_OFFSETOF_WARNING \ + (VMRelPtr) { \ + (void**) &basePtr, \ + offsetof(T_struct, T_member), \ + true \ + } \ + COMPILER_RESTORE_OFFSETOF_WARNING \ + ) \ /** @brief Built-in VM 8 bit integer array variable. * @@ -618,9 +752,10 @@ */ struct VMInt8Array { int8_t* data; - int size; + vmint size; + bool readonly; ///< Whether the array data may be modified or just be read. - VMInt8Array() : data(NULL), size(0) {} + VMInt8Array() : data(NULL), size(0), readonly(false) {} }; /** @brief Virtual machine script variable. @@ -708,6 +843,8 @@ * @param expr - new value to be assigned to this variable */ void assignExpr(VMExpr* expr) OVERRIDE {} + + virtual ~VMDynVar() {} }; /** @brief Dynamically executed variable (of integer data type). @@ -730,6 +867,16 @@ public: }; + /** @brief Dynamically executed variable (of integer array data type). + * + * This is the base class for all built-in integer array script variables + * whose variable content needs to be provided dynamically by executable + * native code on each script variable access. + */ + class VMDynIntArrayVar : virtual public VMDynVar, virtual public VMIntArrayExpr { + public: + }; + /** @brief Provider for built-in script functions and variables. * * Abstract base class defining the high-level interface for all classes @@ -748,10 +895,28 @@ virtual VMFunction* functionByName(const String& name) = 0; /** + * Returns @c true if the passed built-in function is disabled and + * should be ignored by the parser. This method is called by the + * parser on preprocessor level for each built-in function call within + * a script. Accordingly if this method returns @c true, then the + * respective function call is completely filtered out on preprocessor + * level, so that built-in function won't make into the result virtual + * machine representation, nor would expressions of arguments passed to + * that built-in function call be evaluated, nor would any check + * regarding correct usage of the built-in function be performed. + * In other words: a disabled function call ends up as a comment block. + * + * @param fn - built-in function to be checked + * @param ctx - parser context at the position where the built-in + * function call is located within the script + */ + virtual bool isFunctionDisabled(VMFunction* fn, VMParserContext* ctx) = 0; + + /** * Returns a variable name indexed map of all built-in script variables * which point to native "int" scalar (usually 32 bit) variables. */ - virtual std::map builtInIntVariables() = 0; + virtual std::map builtInIntVariables() = 0; /** * Returns a variable name indexed map of all built-in script integer @@ -763,7 +928,7 @@ * Returns a variable name indexed map of all built-in constant script * variables, which never change their value at runtime. */ - virtual std::map builtInConstIntVariables() = 0; + virtual std::map builtInConstIntVariables() = 0; /** * Returns a variable name indexed map of all built-in dynamic variables, @@ -812,7 +977,66 @@ * * @see ScriptVM::exec() */ - virtual int suspensionTimeMicroseconds() const = 0; + virtual vmint suspensionTimeMicroseconds() const = 0; + + /** + * Causes all polyphonic variables to be reset to zero values. A + * polyphonic variable is expected to be zero when entering a new event + * handler instance. As an exception the values of polyphonic variables + * shall only be preserved from an note event handler instance to its + * correspending specific release handler instance. So in the latter + * case the script author may pass custom data from the note handler to + * the release handler, but only for the same specific note! + */ + virtual void resetPolyphonicData() = 0; + + /** + * Returns amount of virtual machine instructions which have been + * performed the last time when this execution context was executing a + * script. So in case you need the overall amount of instructions + * instead, then you need to add them by yourself after each + * ScriptVM::exec() call. + */ + virtual size_t instructionsPerformed() const = 0; + + /** + * Sends a signal to this script execution instance to abort its script + * execution as soon as possible. This method is called i.e. when one + * script execution instance intends to stop another script execution + * instance. + */ + virtual void signalAbort() = 0; + + /** + * Copies the current entire execution state from this object to the + * given object. So this can be used to "fork" a new script thread which + * then may run independently with its own polyphonic data for instance. + */ + virtual void forkTo(VMExecContext* ectx) const = 0; + + /** + * In case the script called the built-in exit() function and passed a + * value as argument to the exit() function, then this method returns + * the value that had been passed as argument to the exit() function. + * Otherwise if the exit() function has not been called by the script + * or no argument had been passed to the exit() function, then this + * method returns NULL instead. + * + * Currently this is only used for automated test cases against the + * script engine, which return some kind of value in the individual + * test case scripts to check their behaviour in automated way. There + * is no purpose for this mechanism in production use. Accordingly this + * exit result value is @b always completely ignored by the sampler + * engines. + * + * Officially the built-in exit() function does not expect any arguments + * to be passed to its function call, and by default this feature is + * hence disabled and will yield in a parser error unless + * ScriptVM::setExitResultEnabled() was explicitly set. + * + * @see ScriptVM::setExitResultEnabled() + */ + virtual VMExpr* exitResult() = 0; }; /** @brief Script callback for a certain event. @@ -844,17 +1068,33 @@ }; /** + * Reflects the precise position and span of a specific code block within + * a script. This is currently only used for the locations of commented + * code blocks due to preprocessor statements, and for parser errors and + * parser warnings. + * + * @see ParserIssue for code locations of parser errors and parser warnings + * + * @see VMParserContext::preprocessorComments() for locations of code which + * have been filtered out by preprocessor statements + */ + struct CodeBlock { + int firstLine; ///< The first line number of this code block within the script (indexed with 1 being the very first line). + int lastLine; ///< The last line number of this code block within the script. + int firstColumn; ///< The first column of this code block within the script (indexed with 1 being the very first column). + int lastColumn; ///< The last column of this code block within the script. + }; + + /** * Encapsulates a noteworty parser issue. This encompasses the type of the * issue (either a parser error or parser warning), a human readable * explanation text of the error or warning and the location of the * encountered parser issue within the script. + * + * @see VMSourceToken for processing syntax highlighting instead. */ - struct ParserIssue { + struct ParserIssue : CodeBlock { String txt; ///< Human readable explanation text of the parser issue. - int firstLine; ///< The first line number within the script where this issue was encountered (indexed with 1 being the very first line). - int lastLine; ///< The last line number within the script where this issue was encountered. - int firstColumn; ///< The first column within the script where this issue was encountered (indexed with 1 being the very first column). - int lastColumn; ///< The last column within the script where this issue was encountered. ParserIssueType_t type; ///< Whether this issue is either a parser error or just a parser warning. /** @@ -934,6 +1174,12 @@ virtual std::vector warnings() const = 0; /** + * Returns all code blocks of the script which were filtered out by the + * preprocessor. + */ + virtual std::vector preprocessorComments() const = 0; + + /** * Returns the translated virtual machine representation of an event * handler block (i.e. "on note ... end on" code block) within the * parsed script. This translated representation of the event handler @@ -966,6 +1212,8 @@ * This class is not actually used by the sampler itself. It is rather * provided for external script editor applications. Primary purpose of * this class is syntax highlighting for external script editors. + * + * @see ParserIssue for processing compile errors and warnings instead. */ class VMSourceToken { public: @@ -978,26 +1226,26 @@ String text() const; // position of token in script - int firstLine() const; ///< First line this source token is located at in script source code (indexed with 0 being the very first line). - int firstColumn() const; ///< Last line this source token is located at in script source code. + int firstLine() const; ///< First line this source token is located at in script source code (indexed with 0 being the very first line). Most source code tokens are not spanning over multiple lines, the only current exception are comments, in the latter case you need to process text() to get the last line and last column for the comment. + int firstColumn() const; ///< First column on the first line this source token is located at in script source code (indexed with 0 being the very first column). To get the length of this token use text().length(). // base types - bool isEOF() const; - bool isNewLine() const; - bool isKeyword() const; - bool isVariableName() const; - bool isIdentifier() const; - bool isNumberLiteral() const; - bool isStringLiteral() const; - bool isComment() const; - bool isPreprocessor() const; - bool isOther() const; + bool isEOF() const; ///< Returns true in case this source token represents the end of the source code file. + bool isNewLine() const; ///< Returns true in case this source token represents a line feed character (i.e. "\n" on Unix systems). + bool isKeyword() const; ///< Returns true in case this source token represents a language keyword (i.e. "while", "function", "declare", "on", etc.). + bool isVariableName() const; ///< Returns true in case this source token represents a variable name (i.e. "$someIntVariable", "%someArrayVariable", "\@someStringVariable"). @see isIntegerVariable(), isStringVariable(), isArrayVariable() for the precise variable type. + bool isIdentifier() const; ///< Returns true in case this source token represents an identifier, which currently always means a function name. + bool isNumberLiteral() const; ///< Returns true in case this source token represents a number literal (i.e. 123). + bool isStringLiteral() const; ///< Returns true in case this source token represents a string literal (i.e. "Some text"). + bool isComment() const; ///< Returns true in case this source token represents a source code comment. + bool isPreprocessor() const; ///< Returns true in case this source token represents a preprocessor statement. + bool isOther() const; ///< Returns true in case this source token represents anything else not covered by the token types mentioned above. // extended types - bool isIntegerVariable() const; - bool isStringVariable() const; - bool isArrayVariable() const; - bool isEventHandlerName() const; + bool isIntegerVariable() const; ///< Returns true in case this source token represents an integer variable name (i.e. "$someIntVariable"). + bool isStringVariable() const; ///< Returns true in case this source token represents an string variable name (i.e. "\@someStringVariable"). + bool isArrayVariable() const; ///< Returns true in case this source token represents an array variable name (i.e. "%someArryVariable"). + bool isEventHandlerName() const; ///< Returns true in case this source token represents an event handler name (i.e. "note", "release", "controller"). VMSourceToken& operator=(const VMSourceToken& other);