Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
srcs
sbnana
sbnanalysis
ana
SBNOscReco
uScript
scanner.h
Go to the documentation of this file.
1
#ifndef uscript_scanner_h
2
#define uscript_scanner_h
3
4
#include "
vm.h
"
5
#include "
chunk.h
"
6
7
namespace
uscript {
8
enum
TokenType
{
9
// Single-character tokens.
10
TOKEN_LEFT_PAREN
,
TOKEN_RIGHT_PAREN
,
11
TOKEN_LEFT_BRACE
,
TOKEN_RIGHT_BRACE
,
12
TOKEN_LEFT_BRACKET
,
TOKEN_RIGHT_BRACKET
,
13
TOKEN_COMMA
,
TOKEN_DOT
,
TOKEN_MINUS
,
TOKEN_PLUS
,
14
TOKEN_SEMICOLON
,
TOKEN_SLASH
,
TOKEN_STAR
,
15
16
// One or two character tokens.
17
TOKEN_BANG
,
TOKEN_BANG_EQUAL
,
18
TOKEN_EQUAL
,
TOKEN_EQUAL_EQUAL
,
19
TOKEN_GREATER
,
TOKEN_GREATER_EQUAL
,
20
TOKEN_LESS
,
TOKEN_LESS_EQUAL
,
21
22
// Literals.
23
TOKEN_IDENTIFIER
,
TOKEN_STRING
,
TOKEN_NUMBER
,
24
25
// Keywords.
26
TOKEN_AND
,
TOKEN_CLASS
,
TOKEN_ELSE
,
TOKEN_FALSE
,
27
TOKEN_FOR
,
TOKEN_FUN
,
TOKEN_IF
,
TOKEN_NIL
,
TOKEN_OR
,
28
TOKEN_PRINT
,
TOKEN_RETURN
,
TOKEN_SUPER
,
TOKEN_THIS
,
29
TOKEN_TRUE
,
TOKEN_VAR
,
TOKEN_WHILE
,
30
31
// more keywords
32
TOKEN_LENGTH
,
TOKEN_FIELDS
,
33
34
TOKEN_ERROR
,
35
TOKEN_EOF
36
};
37
38
struct
Token
{
39
TokenType
type
;
40
const
char
*
start
;
41
int
length
;
42
};
43
44
class
Scanner
{
45
const
char
*
start
;
46
const
char
*
current
;
47
public
:
48
Scanner
();
49
void
SetSource
(
const
char
*_start);
50
51
Token
ScanToken
();
52
Token
MakeToken
(
TokenType
type
)
const
;
53
Token
ErrorToken
(
const
char
*
message
)
const
;
54
bool
IsAtEnd
()
const
;
55
char
Advance
();
56
bool
Match
(
char
c);
57
void
SkipWhitespace
();
58
Token
String
();
59
Token
Number
();
60
Token
Identifier
();
61
TokenType
IdentifierType
()
const
;
62
};
63
64
65
}
// end namespace
66
#endif
uscript::TOKEN_SLASH
Definition:
scanner.h:14
uscript::TOKEN_GREATER
Definition:
scanner.h:19
uscript::Token::length
int length
Definition:
scanner.h:41
uscript::Scanner::ErrorToken
Token ErrorToken(const char *message) const
Definition:
scanner.cc:175
uscript::Scanner::String
Token String()
Definition:
scanner.cc:116
uscript::Scanner::start
const char * start
Definition:
scanner.h:45
uscript::TOKEN_OR
Definition:
scanner.h:27
uscript::TOKEN_LENGTH
Definition:
scanner.h:32
uscript::TOKEN_ERROR
Definition:
scanner.h:34
uscript::Scanner::SetSource
void SetSource(const char *_start)
Definition:
scanner.cc:11
uscript::TOKEN_LESS_EQUAL
Definition:
scanner.h:20
uscript::TOKEN_AND
Definition:
scanner.h:26
uscript::TOKEN_FALSE
Definition:
scanner.h:26
uscript::Scanner::IsAtEnd
bool IsAtEnd() const
Definition:
scanner.cc:104
uscript::TOKEN_DOT
Definition:
scanner.h:13
uscript::TOKEN_THIS
Definition:
scanner.h:28
uscript::TOKEN_RIGHT_BRACE
Definition:
scanner.h:11
uscript::TOKEN_TRUE
Definition:
scanner.h:29
uscript::Scanner::Match
bool Match(char c)
Definition:
scanner.cc:91
uscript::TOKEN_SUPER
Definition:
scanner.h:28
uscript::Scanner::IdentifierType
TokenType IdentifierType() const
Definition:
scanner.cc:140
uscript::TOKEN_IF
Definition:
scanner.h:27
uscript::TOKEN_LEFT_BRACE
Definition:
scanner.h:11
uscript::TOKEN_LEFT_BRACKET
Definition:
scanner.h:12
uscript::Token::type
TokenType type
Definition:
scanner.h:39
uscript::Scanner::Scanner
Scanner()
Definition:
scanner.cc:6
uscript::Scanner::Identifier
Token Identifier()
Definition:
scanner.cc:169
uscript::Scanner::MakeToken
Token MakeToken(TokenType type) const
Definition:
scanner.cc:108
message
services message
Definition:
icarus_ci_nucosmics_gen_quick_test_icaruscode.fcl:20
type
Definition:
ShowerProducedPtrsHolder.hh:50
uscript::Scanner::ScanToken
Token ScanToken()
Definition:
scanner.cc:48
chunk.h
uscript::TOKEN_EOF
Definition:
scanner.h:35
uscript::TOKEN_IDENTIFIER
Definition:
scanner.h:23
uscript::TOKEN_PLUS
Definition:
scanner.h:13
uscript::TOKEN_RIGHT_PAREN
Definition:
scanner.h:10
uscript::TOKEN_NUMBER
Definition:
scanner.h:23
uscript::TOKEN_BANG
Definition:
scanner.h:17
uscript::TOKEN_FIELDS
Definition:
scanner.h:32
uscript::TOKEN_STRING
Definition:
scanner.h:23
uscript::TOKEN_ELSE
Definition:
scanner.h:26
uscript::TOKEN_LESS
Definition:
scanner.h:20
uscript::TokenType
TokenType
Definition:
scanner.h:8
uscript::TOKEN_VAR
Definition:
scanner.h:29
uscript::TOKEN_SEMICOLON
Definition:
scanner.h:14
uscript::TOKEN_EQUAL
Definition:
scanner.h:18
uscript::TOKEN_STAR
Definition:
scanner.h:14
uscript::TOKEN_GREATER_EQUAL
Definition:
scanner.h:19
uscript::Scanner::SkipWhitespace
void SkipWhitespace()
Definition:
scanner.cc:16
uscript::TOKEN_NIL
Definition:
scanner.h:27
uscript::TOKEN_FUN
Definition:
scanner.h:27
uscript::Scanner::Number
Token Number()
Definition:
scanner.cc:127
uscript::TOKEN_RIGHT_BRACKET
Definition:
scanner.h:12
vm.h
uscript::TOKEN_MINUS
Definition:
scanner.h:13
uscript::TOKEN_BANG_EQUAL
Definition:
scanner.h:17
uscript::Token::start
const char * start
Definition:
scanner.h:40
uscript::TOKEN_LEFT_PAREN
Definition:
scanner.h:10
uscript::Scanner::current
const char * current
Definition:
scanner.h:46
uscript::TOKEN_COMMA
Definition:
scanner.h:13
uscript::TOKEN_WHILE
Definition:
scanner.h:29
uscript::Token
Definition:
scanner.h:38
uscript::TOKEN_RETURN
Definition:
scanner.h:28
uscript::TOKEN_PRINT
Definition:
scanner.h:28
uscript::TOKEN_EQUAL_EQUAL
Definition:
scanner.h:18
uscript::Scanner::Advance
char Advance()
Definition:
scanner.cc:99
uscript::Scanner
Definition:
scanner.h:44
uscript::TOKEN_FOR
Definition:
scanner.h:27
uscript::TOKEN_CLASS
Definition:
scanner.h:26
Generated by
1.8.5