The Scanner has been refactored and some responsibilities were pulled from it. Confirmed working, the Parser still needs to be touched on however.
This commit is contained in:
@@ -1,41 +1,13 @@
|
||||
#ifndef SCANNER_H
|
||||
#define SCANNER_H
|
||||
|
||||
#include "token.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#define DEFAULT_TOKENLIST_SIZE 32
|
||||
#define KEYWORD_COUNT 16
|
||||
|
||||
typedef enum {
|
||||
//Single-character tokens
|
||||
LParen, RParen,
|
||||
LBrace, RBrace,
|
||||
Comma,
|
||||
Dot,
|
||||
Minus, Plus,
|
||||
Semicolon,
|
||||
Slash, Star,
|
||||
//One or two character tokens
|
||||
Bang, Bang_Equal,
|
||||
Equal, Equal_Equal,
|
||||
Greater, Greater_Equal,
|
||||
Less, Less_Equal,
|
||||
//Literals
|
||||
Identifier,
|
||||
String,
|
||||
Number,
|
||||
//Keywords
|
||||
AND, CLASS, ELSE, FALSE, FUN,
|
||||
FOR, IF, NIL, OR, PRINT, RETURN,
|
||||
SUPER, THIS, TRUE, VAR, WHILE,
|
||||
|
||||
EndOF
|
||||
} TokenType;
|
||||
|
||||
typedef struct {
|
||||
TokenType type;
|
||||
const char* lexeme;
|
||||
int line;
|
||||
int length;
|
||||
} Token;
|
||||
|
||||
typedef struct {
|
||||
Token** tokens;
|
||||
|
||||
Reference in New Issue
Block a user