/[svn]/linuxsampler/trunk/src/scriptvm/common.h
ViewVC logotype

Diff of /linuxsampler/trunk/src/scriptvm/common.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2727 by schoenebeck, Tue Mar 31 17:46:11 2015 UTC revision 2885 by schoenebeck, Fri Apr 22 15:37:45 2016 UTC
# Line 1  Line 1 
1  /*  /*
2   * Copyright (c) 2014-2015 Christian Schoenebeck   * Copyright (c) 2014-2016 Christian Schoenebeck
3   *   *
4   * http://www.linuxsampler.org   * http://www.linuxsampler.org
5   *   *
# Line 76  namespace LinuxSampler { Line 76  namespace LinuxSampler {
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;
# Line 341  namespace LinuxSampler { Line 353  namespace LinuxSampler {
353           * Script data type of the function's @c iArg 'th function argument.           * Script data type of the function's @c iArg 'th function argument.
354           * The information provided here is less strong than acceptsArgType().           * The information provided here is less strong than acceptsArgType().
355           * The parser will compare argument data types provided in scripts by           * The parser will compare argument data types provided in scripts by
356           * calling cceptsArgType(). The return value of argType() is used by the           * calling acceptsArgType(). The return value of argType() is used by the
357           * parser instead to show an appropriate parser error which data type           * parser instead to show an appropriate parser error which data type
358           * this function usually expects as "default" data type. Reason: a           * this function usually expects as "default" data type. Reason: a
359           * function may accept multiple data types for a certain function           * function may accept multiple data types for a certain function
# Line 604  namespace LinuxSampler { Line 616  namespace LinuxSampler {
616           * engine) which is using the virtual machine classes here, must take           * engine) which is using the virtual machine classes here, must take
617           * care by itself about taking time stamps, determining the script           * care by itself about taking time stamps, determining the script
618           * handlers that shall be put aside for the requested amount of           * handlers that shall be put aside for the requested amount of
619           * microseconds indicated by this method by comparing the time stamps in           * microseconds, indicated by this method by comparing the time stamps in
620           * real-time, and to continue passing the respective handler to           * real-time, and to continue passing the respective handler to
621           * ScriptVM::exec() as soon as its suspension exceeded, etc. Or in other           * ScriptVM::exec() as soon as its suspension exceeded, etc. Or in other
622           * words: all classes in this directory never have an idea what time it           * words: all classes in this directory never have an idea what time it
# Line 627  namespace LinuxSampler { Line 639  namespace LinuxSampler {
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.
# Line 748  namespace LinuxSampler { Line 767  namespace LinuxSampler {
767          virtual VMEventHandler* eventHandlerByName(const String& name) = 0;          virtual VMEventHandler* eventHandlerByName(const String& name) = 0;
768      };      };
769    
770        class SourceToken;
771    
772        /** @brief Recognized token of a script's source code.
773         *
774         * Represents one recognized token of a script's source code, for example
775         * a keyword, variable name, etc. and it provides further informations about
776         * that particular token, i.e. the precise location (line and column) of the
777         * token within the original script's source code.
778         *
779         * This class is not actually used by the sampler itself. It is rather
780         * provided for external script editor applications. Primary purpose of
781         * this class is syntax highlighting for external script editors.
782         */
783        class VMSourceToken {
784        public:
785            VMSourceToken();
786            VMSourceToken(SourceToken* ct);
787            VMSourceToken(const VMSourceToken& other);
788            virtual ~VMSourceToken();
789    
790            // original text of this token as it is in the script's source code
791            String text() const;
792    
793            // position of token in script
794            int firstLine() const;
795            int firstColumn() const;
796    
797            // base types
798            bool isEOF() const;
799            bool isNewLine() const;
800            bool isKeyword() const;
801            bool isVariableName() const;
802            bool isIdentifier() const;
803            bool isNumberLiteral() const;
804            bool isStringLiteral() const;
805            bool isComment() const;
806            bool isPreprocessor() const;
807            bool isOther() const;
808    
809            // extended types
810            bool isIntegerVariable() const;
811            bool isStringVariable() const;
812            bool isArrayVariable() const;
813            bool isEventHandlerName() const;
814    
815            VMSourceToken& operator=(const VMSourceToken& other);
816    
817        private:
818            SourceToken* m_token;
819        };
820    
821  } // namespace LinuxSampler  } // namespace LinuxSampler
822    
823  #endif // LS_INSTR_SCRIPT_PARSER_COMMON_H  #endif // LS_INSTR_SCRIPT_PARSER_COMMON_H

Legend:
Removed from v.2727  
changed lines
  Added in v.2885

  ViewVC Help
Powered by ViewVC