Testing update with check.sh
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
/* Syntax Analyzer with Bison (3.8.1) */
|
||||
/* (referenced Bison manual for file boilerplate [3.1]) */
|
||||
/* Syntax Analyzer with Bison (3.8.1) */
|
||||
/* The Translators - Spring 2025 */
|
||||
|
||||
// Prologue
|
||||
%{
|
||||
|
@ -1,15 +1,17 @@
|
||||
/* Lexical Analyzer with Flex (1.6.0) */
|
||||
/* Lexical Analyzer with Flex (1.6.0) */
|
||||
/* The Translators - Spring 2025 */
|
||||
|
||||
%option noyywrap
|
||||
%option header-file="flex.h"
|
||||
|
||||
%{
|
||||
#include <stdbool.h>
|
||||
//#include "typedefs.h"
|
||||
#include "grammar.tab.h"
|
||||
int line_number = 1, column_number = 1;
|
||||
#ifndef DEBUG
|
||||
#define DEBUG 0
|
||||
#endif
|
||||
|
||||
int line_number = 1, column_number = 1;
|
||||
%}
|
||||
|
||||
STARCOM [^\*]|\*+[^\)\*]+
|
||||
|
32
src/runner.c
32
src/runner.c
@ -1,37 +1,32 @@
|
||||
// #include "symbol_table.h"
|
||||
/* Runner File - Compiles alpha Compiler */
|
||||
/* The Translators - Spring 2025 */
|
||||
|
||||
#include "runner.h"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
if (argc == 1) {
|
||||
fprintf(
|
||||
stderr,
|
||||
"INVALID INPUT: Include a .alpha file or use -help for more inputs \n");
|
||||
stderr, INVALID);
|
||||
return -1;
|
||||
} else if (argc == 2) {
|
||||
// can be either -help or .alpha file
|
||||
}
|
||||
|
||||
else if (argc == 2) {
|
||||
if (is_help(argv[1])) {
|
||||
return 0;
|
||||
} else if (is_alpha_file(argv[1], strlen(argv[1])) == 0) {
|
||||
// run flex for now
|
||||
no_flag = SET_FLAG; // no argument but valid input
|
||||
no_flag = SET_FLAG;
|
||||
alpha_file = fopen(argv[1], "r");
|
||||
|
||||
} else {
|
||||
fprintf(stderr,
|
||||
"INVALID INPUT: Include a .alpha file or use -help for more "
|
||||
"inputs\n");
|
||||
fprintf(stderr, INVALID);
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
// last input must be .alpha
|
||||
}
|
||||
|
||||
else {
|
||||
if (is_alpha_file(argv[argc - 1], strlen(argv[argc - 1])) != 0) {
|
||||
fprintf(stderr,
|
||||
"INVALID INPUT: Include a .alpha file at end of input or use "
|
||||
"-help for more inputs \n");
|
||||
fprintf(stderr, INVALID);
|
||||
return -1;
|
||||
} else {
|
||||
// now check that other args are valid (flags will not be null if flag is
|
||||
// present)
|
||||
for (int i = 1; i < argc - 1; i++) {
|
||||
if (check_flag(argv[i], argv[argc - 1]) != 0) {
|
||||
fprintf(stderr, "INVALID FLAG(S): Use -help to view valid inputs \n");
|
||||
@ -117,6 +112,7 @@ bool is_help(char *input) {
|
||||
printf("%s", HELP);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,6 @@
|
||||
/* Runner File - Compiles alpha Compiler */
|
||||
/* The Translators - Spring 2025 */
|
||||
|
||||
#define ALPHA_OFFSET 6
|
||||
#define TOK_LEN 3
|
||||
#define ST_LEN 2
|
||||
@ -7,8 +10,9 @@
|
||||
"number for each of the tokens to the .tok file\n-st output the symbol " \
|
||||
"table for the program to the .st file\n-help print this message and exit " \
|
||||
"the alpha compiler\n"
|
||||
// use to set flags for arg types
|
||||
#define SET_FLAG 1
|
||||
#define SET_FLAG 1 // Used to set flags for arg types
|
||||
#define INVALID \
|
||||
"INVALID INPUT: Include a .alpha file or use -help for more inputs \n"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
|
Reference in New Issue
Block a user