Added universal OS support and version bump to 0.2.1 beta

This commit is contained in:
XOR 2023-09-25 18:43:53 +02:00
parent 9926b9da54
commit 19c0d887b5
3 changed files with 14 additions and 7 deletions

1
.gitignore vendored
View file

@ -60,6 +60,7 @@ dkms.conf
#Code editor
.vscode/*
.idea/*
compile_commands.json
.cache/*
.#*

View file

@ -25,7 +25,7 @@ Here, common macros are specified
#define VER_MAJOR "0"
#define VER_MINOR "2"
#define VER_PATCH "0"
#define VER_PATCH "1"
// alpha, beta or stable
#define TAG "beta"
@ -46,9 +46,6 @@ Here, common macros are specified
#define INSTR_JPU 0b1010
#define INSTR_EOJ 0b1011
// get the character which the next fgetc() call would return
#define PREFGETC(file) *file->_IO_read_ptr
// const char *argp_program_bug_address = "eipabugs@outlook.com";
#define EIPA_BUG_ADRESS "eipabugs@outlook.com"

View file

@ -10,6 +10,15 @@ This code contains the implementations of all functions related to the lexical a
#include "../header/common.h"
#include "../header/lexer.h"
// get the character which the next fgetc() call would return
static int prefgetc(FILE *fp)
{
long origin = ftell(fp);
int read = fgetc(fp);
fseek(fp, origin, SEEK_SET);
return read;
}
void lexer(FILE *input_file, dynamic_buffer_t *tokens)
{
// Stores the current character we are examining
@ -53,7 +62,7 @@ void lexer(FILE *input_file, dynamic_buffer_t *tokens)
// This is an indice of a new token begining, so we probably need to increase token_index
// Loop to the characters until the next character fgetc() would read is not space or tab
while (PREFGETC(input_file) == ASCII_SPACE || PREFGETC(input_file) == ASCII_TAB)
while (prefgetc(input_file) == ASCII_SPACE || prefgetc(input_file) == ASCII_TAB)
{
current_char = (char)fgetc(input_file);
}
@ -63,7 +72,7 @@ void lexer(FILE *input_file, dynamic_buffer_t *tokens)
However, there can also be a space between the Adress and the newline.
To not increase the token_index 2 times, we need to not increase it here if the next character is a \n
*/
if (PREFGETC(input_file) != ';' && PREFGETC(input_file) != ASCII_NEWLINE)
if (prefgetc(input_file) != ';' && prefgetc(input_file) != ASCII_NEWLINE)
{
token_index++;
}
@ -84,7 +93,7 @@ void lexer(FILE *input_file, dynamic_buffer_t *tokens)
break;
case ';':
// Loop over the comment
while (PREFGETC(input_file) != ASCII_NEWLINE && PREFGETC(input_file) != '\0')
while (prefgetc(input_file) != ASCII_NEWLINE && prefgetc(input_file) != '\0')
{
current_char = (char)fgetc(input_file);
}