84#define NUMBER_LITERAL_BASE_PREFIX '0'
85#define NUMBER_LITERAL_BIN_PREFIX 'b'
86#define NUMBER_LITERAL_OCT_PREFIX 'o'
87#define NUMBER_LITERAL_HEX_PREFIX 'x'
88#define NUMBER_LITERAL_LONG_SUFFIX 'L'
90#define NUMBER_LITERAL_SPACING_SEPARATOR '\''
91#define NUMBER_LITERAL_BASE_SEPARATOR '#'
97 "EOF",
"+",
"-",
"*",
"/",
"pow",
"==",
"!=",
"<",
">",
"<=",
">=",
"and",
"or",
"xor",
"nand",
98 "nor",
"xnor",
"&",
"*",
"true",
"false",
"character literal",
"short literal",
99 "integer literal",
"long literal",
"void",
"bool",
"char",
"short",
"int",
"long",
"=",
"print",
100 "if",
"else",
"while",
"for",
"return",
";",
"(",
")",
"{",
"}",
"identifier",
",",
102 "ast glue",
"function",
"function call",
"TOKENTYPE_MAX"};
107#define TOKENTYPE_IS_BINARY_ARITHMETIC(type) (type >= T_PLUS && type <= T_EXPONENT)
112#define TOKENTYPE_IS_TYPE(type) (type >= T_VOID && type <= T_LONG)
117#define TOKENTYPE_IS_NUMBER_TYPE(tt) \
118 ((tt >= T_BOOL && tt <= T_LONG) || (T_TRUE <= tt && tt <= T_LONG_LITERAL))
123#define TOKENTYPE_IS_LITERAL(type) (type >= T_TRUE && type <= T_LONG_LITERAL)
128#define TOKENTYPE_IS_BOOL_LITERAL(type) (type >= T_TRUE && type <= T_FALSE)
133#define TOKENTYPE_IS_COMPARATOR(type) (type >= T_EQ && type <= T_GE)
139#define TOKENTYPE_IS_LOGICAL_OPERATOR(type) (type >= T_AND && type <= T_XNOR)
144#define number_literal_type long long int
149#define MAX_NUMBER_LITERAL_DIGITS 19
Definitions for identifiers.
#define MAX_IDENTIFIER_LENGTH
Definition: identifier.h:12
Definitions and function headers for the internal "Number" type.
char next(void)
Get the next valid character from the current input file.
Definition: scan.c:20
static char * tokenStrings[]
Token string equivalents.
Definition: scan.h:96
bool scan()
Scan tokens into the Token struct.
Definition: scan.c:439
TokenType
Types of scannable tokens.
Definition: scan.h:20
@ T_FOR
Definition: scan.h:66
@ T_AND
Definition: scan.h:36
@ T_RIGHT_BRACE
Definition: scan.h:73
@ T_IDENTIFIER
Definition: scan.h:74
@ T_INTEGER_LITERAL
Definition: scan.h:50
@ T_LONG
Definition: scan.h:58
@ T_NAND
Definition: scan.h:39
@ TOKENTYPE_MAX
Definition: scan.h:81
@ T_XOR
Definition: scan.h:38
@ T_SEMICOLON
Definition: scan.h:69
@ T_RIGHT_PAREN
Definition: scan.h:71
@ T_SHORT_LITERAL
Definition: scan.h:49
@ T_VOID
Definition: scan.h:53
@ T_WHILE
Definition: scan.h:65
@ T_NOR
Definition: scan.h:40
@ T_TRUE
Definition: scan.h:46
@ T_GE
Definition: scan.h:34
@ T_STAR
Definition: scan.h:25
@ T_BOOL
Definition: scan.h:54
@ T_LONG_LITERAL
Definition: scan.h:51
@ T_EOF
Definition: scan.h:21
@ T_LT
Definition: scan.h:31
@ T_CHAR_LITERAL
Definition: scan.h:48
@ T_LE
Definition: scan.h:33
@ T_INT
Definition: scan.h:57
@ T_ELSE
Definition: scan.h:64
@ T_PRINT
Definition: scan.h:62
@ T_SLASH
Definition: scan.h:26
@ T_XNOR
Definition: scan.h:41
@ T_AST_GLUE
Definition: scan.h:77
@ T_FUNCTION_CALL
Definition: scan.h:79
@ T_EQ
Definition: scan.h:29
@ T_AMPERSAND
Definition: scan.h:43
@ T_ASSIGN
Definition: scan.h:60
@ T_GT
Definition: scan.h:32
@ T_FALSE
Definition: scan.h:47
@ T_LEFT_PAREN
Definition: scan.h:70
@ T_PLUS
Definition: scan.h:23
@ T_FUNCTION_DECLARATION
Definition: scan.h:78
@ T_IF
Definition: scan.h:63
@ T_COMMA
Definition: scan.h:75
@ T_DEREFERENCE
Definition: scan.h:44
@ T_MINUS
Definition: scan.h:24
@ T_OR
Definition: scan.h:37
@ T_RETURN
Definition: scan.h:67
@ T_SHORT
Definition: scan.h:56
@ T_NEQ
Definition: scan.h:30
@ T_LEFT_BRACE
Definition: scan.h:72
@ T_EXPONENT
Definition: scan.h:27
@ T_CHAR
Definition: scan.h:55
void put_back_into_stream(char c)
Put a character back into the input stream.
Definition: scan.c:51
struct Token Token
Structure containing information about individual scannable tokens.
struct position position
Structure containing information about a Token's position in the input.
Container for various kinds of number data.
Definition: number.h:56
Structure containing information about individual scannable tokens.
Definition: scan.h:166
position pos
Definition: scan.h:170
TokenType token_type
Definition: scan.h:168
char symbol_name[MAX_IDENTIFIER_LENGTH]
Definition: scan.h:176
Number number_value
Definition: scan.h:174
Structure containing information about a Token's position in the input.
Definition: scan.h:154
int line_number
Definition: scan.h:158
int char_number
Definition: scan.h:160
char filename[256]
Definition: scan.h:156