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

Contents of /linuxsampler/trunk/src/scriptvm/editor/CodeScanner.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3573 - (show annotations) (download) (as text)
Tue Aug 27 21:36:53 2019 UTC (4 years, 7 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 2174 byte(s)
NKSP: Introducing floating point support.

* NKSP language: Added support for NKSP real number literals and
  arithmetic operations on them (e.g. "(3.9 + 2.9) / 12.3 - 42.0").

* NKSP language: Added support for NKSP real number (floating point)
  script variables (declare ~foo := 3.4).

* NKSP language: Added support for NKSP real number (floating point)
  array script variables (declare ?foo[3] := ( 1.1, 2.7, 49.0 )).

* NKSP built-in script function "message()" accepts now real number
  argument as well.

* Added built-in NKSP script function "real_to_int()" and its short
  hand form "int()" for casting from real number to integer in NKSP
  scripts.

* Added built-in NKSP script function "int_to_real()" and its short
  hand form "real()" for casting from integer to real number in NKSP
  scripts.

* Bumped version (2.1.1.svn6).

1 /*
2 * Copyright (c) 2015-2019 Christian Schoenebeck
3 *
4 * http://www.linuxsampler.org
5 *
6 * This file is part of LinuxSampler and released under the same terms.
7 * See README file for details.
8 */
9
10 #include <iostream>
11 #include <sstream>
12 #include <vector>
13 #include "SourceToken.h"
14
15 #ifndef CRUDEBYTE_CODE_SCANNER_H
16 #define CRUDEBYTE_CODE_SCANNER_H
17
18 namespace LinuxSampler {
19
20 class CodeScanner {
21 public:
22 void* scanner;
23 std::istream* is;
24 SourceToken token;
25 int line;
26 int column;
27
28 CodeScanner(std::istream* is);
29 virtual ~CodeScanner();
30 std::vector<SourceToken> tokens() const { return m_tokens; }
31 bool isMultiLine() const;
32
33 protected:
34 std::vector<SourceToken> m_tokens;
35
36 virtual int processScanner() = 0;
37 SourceToken processOneToken();
38 void processAll();
39 void trim();
40 };
41
42 // base types
43 #define EofToken() SourceToken()
44 #define NewLineToken() SourceToken(SourceToken::NEW_LINE, "\n")
45 #define KeywordToken(s) SourceToken(SourceToken::KEYWORD, s)
46 #define VariableNameToken(s) SourceToken(SourceToken::VARIABLE_NAME, s)
47 #define IdentifierToken(s) SourceToken(SourceToken::IDENTIFIER, s)
48 #define NumberLiteralToken(s) SourceToken(SourceToken::NUMBER_LITERAL, s)
49 #define StringLiteralToken(s) SourceToken(SourceToken::STRING_LITERAL, s)
50 #define CommentToken(s) SourceToken(SourceToken::COMMENT, s)
51 #define PreprocessorToken(s) SourceToken(SourceToken::PREPROCESSOR, s)
52 #define MetrixPrefixToken(s) SourceToken(SourceToken::METRIC_PREFIX, s)
53 #define StdUnitToken(s) SourceToken(SourceToken::STANDARD_UNIT, s)
54 #define OtherToken(s) SourceToken(SourceToken::OTHER, s)
55
56 // extended types
57 #define IntegerVariableToken(s) SourceToken(SourceToken::INTEGER_VARIABLE, s)
58 #define RealVariableToken(s) SourceToken(SourceToken::REAL_VARIABLE, s)
59 #define StringVariableToken(s) SourceToken(SourceToken::STRING_VARIABLE, s)
60 #define IntegerArrayVariableToken(s) SourceToken(SourceToken::INTEGER_ARRAY_VARIABLE, s)
61 #define RealArrayVariableToken(s) SourceToken(SourceToken::REAL_ARRAY_VARIABLE, s)
62 #define EventHandlerNameToken(s) SourceToken(SourceToken::EVENT_HANDLER_NAME, s)
63
64 } // namespace LinuxSampler
65
66 #endif // CRUDEBYTE_CODE_SCANNER_H

  ViewVC Help
Powered by ViewVC