76 |
VM_EXEC_ERROR = (1<<2), ///< A runtime error occurred while executing the script (i.e. a call to some built-in script function failed). |
VM_EXEC_ERROR = (1<<2), ///< A runtime error occurred while executing the script (i.e. a call to some built-in script function failed). |
77 |
}; |
}; |
78 |
|
|
79 |
|
/** @brief Script event handler type. |
80 |
|
* |
81 |
|
* Identifies one of the possible event handler callback types defined by |
82 |
|
* the NKSP script language. |
83 |
|
*/ |
84 |
|
enum VMEventHandlerType_t { |
85 |
|
VM_EVENT_HANDLER_INIT, ///< Initilization event handler, that is script's "on init ... end on" code block. |
86 |
|
VM_EVENT_HANDLER_NOTE, ///< Note event handler, that is script's "on note ... end on" code block. |
87 |
|
VM_EVENT_HANDLER_RELEASE, ///< Release event handler, that is script's "on release ... end on" code block. |
88 |
|
VM_EVENT_HANDLER_CONTROLLER, ///< Controller event handler, that is script's "on controller ... end on" code block. |
89 |
|
}; |
90 |
|
|
91 |
// just symbol prototyping |
// just symbol prototyping |
92 |
class VMIntExpr; |
class VMIntExpr; |
93 |
class VMStringExpr; |
class VMStringExpr; |
639 |
class VMEventHandler { |
class VMEventHandler { |
640 |
public: |
public: |
641 |
/** |
/** |
642 |
|
* Type of this event handler, which identifies its purpose. For example |
643 |
|
* for a "on note ... end on" script callback block, |
644 |
|
* @c VM_EVENT_HANDLER_NOTE would be returned here. |
645 |
|
*/ |
646 |
|
virtual VMEventHandlerType_t eventHandlerType() const = 0; |
647 |
|
|
648 |
|
/** |
649 |
* Name of the event handler which identifies its purpose. For example |
* Name of the event handler which identifies its purpose. For example |
650 |
* for a "on note ... end on" script callback block, the name "note" |
* for a "on note ... end on" script callback block, the name "note" |
651 |
* would be returned here. |
* would be returned here. |
667 |
*/ |
*/ |
668 |
struct ParserIssue { |
struct ParserIssue { |
669 |
String txt; ///< Human readable explanation text of the parser issue. |
String txt; ///< Human readable explanation text of the parser issue. |
670 |
int line; ///< Line number within the script where this issue was encountered. |
int firstLine; ///< The first line number within the script where this issue was encountered (indexed with 1 being the very first line). |
671 |
|
int lastLine; ///< The last line number within the script where this issue was encountered. |
672 |
|
int firstColumn; ///< The first column within the script where this issue was encountered (indexed with 1 being the very first column). |
673 |
|
int lastColumn; ///< The last column within the script where this issue was encountered. |
674 |
ParserIssueType_t type; ///< Whether this issue is either a parser error or just a parser warning. |
ParserIssueType_t type; ///< Whether this issue is either a parser error or just a parser warning. |
675 |
|
|
676 |
/** |
/** |
679 |
inline void dump() { |
inline void dump() { |
680 |
switch (type) { |
switch (type) { |
681 |
case PARSER_ERROR: |
case PARSER_ERROR: |
682 |
printf("[ERROR] line %d: %s\n", line, txt.c_str()); |
printf("[ERROR] line %d, column %d: %s\n", firstLine, firstColumn, txt.c_str()); |
683 |
break; |
break; |
684 |
case PARSER_WARNING: |
case PARSER_WARNING: |
685 |
printf("[Warning] line %d: %s\n", line, txt.c_str()); |
printf("[Warning] line %d, column %d: %s\n", firstLine, firstColumn, txt.c_str()); |
686 |
break; |
break; |
687 |
} |
} |
688 |
} |
} |
770 |
virtual VMEventHandler* eventHandlerByName(const String& name) = 0; |
virtual VMEventHandler* eventHandlerByName(const String& name) = 0; |
771 |
}; |
}; |
772 |
|
|
773 |
|
class SourceToken; |
774 |
|
|
775 |
|
/** @brief Recognized token of a script's source code. |
776 |
|
* |
777 |
|
* Represents one recognized token of a script's source code, for example |
778 |
|
* a keyword, variable name, etc. and it provides further informations about |
779 |
|
* that particular token, i.e. the precise location (line and column) of the |
780 |
|
* token within the original script's source code. |
781 |
|
* |
782 |
|
* This class is not actually used by the sampler itself. It is rather |
783 |
|
* provided for external script editor applications. Primary purpose of |
784 |
|
* this class is syntax highlighting for external script editors. |
785 |
|
*/ |
786 |
|
class VMSourceToken { |
787 |
|
public: |
788 |
|
VMSourceToken(); |
789 |
|
VMSourceToken(SourceToken* ct); |
790 |
|
VMSourceToken(const VMSourceToken& other); |
791 |
|
virtual ~VMSourceToken(); |
792 |
|
|
793 |
|
// original text of this token as it is in the script's source code |
794 |
|
String text() const; |
795 |
|
|
796 |
|
// position of token in script |
797 |
|
int firstLine() const; ///< First line this source token is located at in script source code (indexed with 0 being the very first line). |
798 |
|
int firstColumn() const; ///< Last line this source token is located at in script source code. |
799 |
|
|
800 |
|
// base types |
801 |
|
bool isEOF() const; |
802 |
|
bool isNewLine() const; |
803 |
|
bool isKeyword() const; |
804 |
|
bool isVariableName() const; |
805 |
|
bool isIdentifier() const; |
806 |
|
bool isNumberLiteral() const; |
807 |
|
bool isStringLiteral() const; |
808 |
|
bool isComment() const; |
809 |
|
bool isPreprocessor() const; |
810 |
|
bool isOther() const; |
811 |
|
|
812 |
|
// extended types |
813 |
|
bool isIntegerVariable() const; |
814 |
|
bool isStringVariable() const; |
815 |
|
bool isArrayVariable() const; |
816 |
|
bool isEventHandlerName() const; |
817 |
|
|
818 |
|
VMSourceToken& operator=(const VMSourceToken& other); |
819 |
|
|
820 |
|
private: |
821 |
|
SourceToken* m_token; |
822 |
|
}; |
823 |
|
|
824 |
} // namespace LinuxSampler |
} // namespace LinuxSampler |
825 |
|
|
826 |
#endif // LS_INSTR_SCRIPT_PARSER_COMMON_H |
#endif // LS_INSTR_SCRIPT_PARSER_COMMON_H |