misc/kforth: Starting work on the parser.

This commit is contained in:
Kyle Isom 2018-02-23 09:07:12 -08:00
parent c4d78e17ff
commit 5bcc016246
5 changed files with 34 additions and 1 deletions

View File

@ -1,6 +1,7 @@
CXXSTD := c++11
CXXFLAGS := -std=$(CXXSTD) -Wall -Werror -g -O0
OBJS := linux/io.o \
parser.o \
kforth.o
TARGET := kforth

View File

@ -1,4 +1,5 @@
#include "io.h"
#include "parser.h"
#ifdef __linux__
#include "linux.h"

View File

@ -2,6 +2,6 @@
#define __KF_LINUX_DEFS_H__
#include <stddef.h>
#include <stdint.h>
#endif

17
parser.cc Normal file
View File

@ -0,0 +1,17 @@
#include "defs.h"
#include "parser.h"
int
parse_next(const char *buf, const size_t length, size_t *offset,
struct Token *token)
{
size_t start = *offset;
bool ok = false;
// TODO(skip past whitespace)
// TODO(find next EOC)
if (!ok) {
*offset = start;
}
return -1;
}

14
parser.h Normal file
View File

@ -0,0 +1,14 @@
#ifndef __KF_PARSER_H__
#define __KF_PARSER_H__
#include "defs.h"
struct Token {
char *token;
uint8_t length;
};
int parse_next(const char *, const size_t, size_t *, struct Token *);
#endif // __KF_PARSER_H__