Skip to content

Fix: Makefile build patch not able to recognize tokens and create generated directory if not present #79

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: WorkingBranch
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions src/parser/lrparser.y
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
%define parse.trace
%{
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "includeHeader.hpp"
#include "../analyser/attachProp/attachPropAnalyser.h"
#include "../analyser/dataRace/dataRaceAnalyser.h"
Expand Down Expand Up @@ -68,6 +69,7 @@
%token <fval> FLOAT_NUM
%token <bval> BOOL_VAL
%token <cval> CHAR_VAL
%token return_func

%type <node> function_def function_data return_func function_body param
%type <pList> paramList
Expand Down Expand Up @@ -496,6 +498,23 @@ id : ID {

%%

void create_directory(const char *backendTarget) {
char directory_name[256];
snprintf(directory_name, sizeof(directory_name), "../graphcode/generated_%s", backendTarget);

// Check if directory already exists
struct stat st = {0};
if (stat(directory_name, &st) == -1) {
// Create the directory
if (mkdir(directory_name, 0700) == 0) {
printf("Directory created: %s\n", directory_name);
} else {
perror("mkdir failed");
}
} else {
printf("Directory already exists: %s\n", directory_name);
}
}

void yyerror(const char *s) {
fprintf(stderr, "%s\n", s);
Expand Down Expand Up @@ -582,7 +601,8 @@ int main(int argc,char **argv)




// only create a directory if the passed option is a valid option
create_directory(backendTarget);
yyin= fopen(fileName,"r");

if(!yyin) {
Expand Down