Initial Commit

This commit is contained in:
Garrett Dickinson 2022-02-09 13:11:01 -06:00
parent 8855b219eb
commit f014088199
10 changed files with 87 additions and 0 deletions

3
compile Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
g++ parser.cpp lexer.cpp main.cpp -o main

30
lexer.cpp Normal file
View File

@ -0,0 +1,30 @@
#include <stdio.h>
#include <iostream>
#include <fstream>
#include "lexer.h"
char c;
FILE* input_file;
Lexer::Lexer(std::string &file_name) {
input_file = fopen(file_name.c_str(),"r");
if(input_file == nullptr) {
std::cout << "[Error] Script " << input_file << " could not be read\n";
exit(1);
}
c = getc(input_file);
if (c == EOF) {
//do something related to eof here?
fclose(input_file);
}
}
char nextChar() {
if (c != EOF) {
c = getc(input_file);
} else {
c = EOF;
}
return c;
}

14
lexer.h Normal file
View File

@ -0,0 +1,14 @@
#include <iostream>
#ifndef LEXER_H
#define LEXER_H
class Lexer
{
private:
std::string extension = ".prog";
public:
Lexer(std::string &file_name);
};
#endif

BIN
main Executable file

Binary file not shown.

15
main.cpp Normal file
View File

@ -0,0 +1,15 @@
#include <stdio.h>
#include <iostream>
#include <vector>
#include "lexer.h"
int main(int argc, char *argv[]) {
if (argc > 1) {
std::string file_name(argv[1]);
Lexer lex(file_name);
} else {
std::cout << "[Error] No input file provided\n";
}
return 0;
}

8
parser.cpp Normal file
View File

@ -0,0 +1,8 @@
#include <stdio.h>
#include <iostream>
#include "parser.h"
Parser::Parser(std::string input_file) {
}

14
parser.h Normal file
View File

@ -0,0 +1,14 @@
#include <iostream>
#ifndef PARSER_H
#define PARSER_H
class Parser
{
private:
public:
Parser(std::string input_file);
};
#endif

3
script.prog Normal file
View File

@ -0,0 +1,3 @@
hello world, this is a lexer test
hello world
Kanye's new name is Ye

0
token.cpp Normal file
View File

0
token.h Normal file
View File