Commit 1f3906a4 authored by zygzagZ's avatar zygzagZ

fix makefile

parent f5cf7cdc
...@@ -2,4 +2,4 @@ ...@@ -2,4 +2,4 @@
*.l *.l
*.y *.y
/lat/ /lat/
/TestGrammar /latc
\ No newline at end of file \ No newline at end of file
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#include "Parser.h" #include "Parser.h"
#include "Printer.h" #include "Printer.h"
#include "Absyn.h" #include "Absyn.h"
#include "Compiler.h" // #include "Compiler.h"
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include <filesystem> #include <filesystem>
...@@ -63,7 +63,7 @@ int main(int argc, char ** argv) ...@@ -63,7 +63,7 @@ int main(int argc, char ** argv)
binaryPath = argv[0]; binaryPath = argv[0];
std::filesystem::path file(filename ? filename : "Instant"); std::filesystem::path file(filename ? filename : "Instant");
Compiler c(file); /*Compiler c(file);
std::string out = c.compile(parse_tree); std::string out = c.compile(parse_tree);
if (!filename) { if (!filename) {
...@@ -81,6 +81,6 @@ int main(int argc, char ** argv) ...@@ -81,6 +81,6 @@ int main(int argc, char ** argv)
ll << out; ll << out;
ll.close(); ll.close();
Compiler::externalCommand(file); Compiler::externalCommand(file);*/
} }
CC=g++ CC=g++
CCFLAGS=-g -W -Wall CCFLAGS=-g -W -Wall -O3 -std=c++1z
FLEX=flex FLEX=flex
FLEX_OPTS=-PGrammar FLEX_OPTS=-PGrammar
...@@ -11,17 +11,17 @@ OBJS=Absyn.o Lexer.o Parser.o Printer.o ...@@ -11,17 +11,17 @@ OBJS=Absyn.o Lexer.o Parser.o Printer.o
.PHONY : clean distclean .PHONY : clean distclean
all : TestGrammar all : latc
clean : clean :
rm -f *.o TestGrammar Grammar.aux Grammar.log Grammar.pdf Grammar.dvi Grammar.ps Grammar rm -f *.o latc Grammar.aux Grammar.log Grammar.pdf Grammar.dvi Grammar.ps Grammar
distclean : clean # distclean : clean
rm -f Absyn.cpp Absyn.h Test.cpp Parser.cpp Parser.h Lexer.cpp Skeleton.cpp Skeleton.h Printer.cpp Printer.h Makefile Grammar.l Grammar.y Grammar.tex # rm -f Absyn.cpp Absyn.h Latte.cpp Parser.cpp Parser.h Lexer.cpp Skeleton.cpp Skeleton.h Printer.cpp Printer.h Makefile Grammar.l Grammar.y Grammar.tex
TestGrammar : ${OBJS} Test.o latc : ${OBJS} Latte.o
@echo "Linking TestGrammar..." @echo "Linking latc..."
${CC} ${CCFLAGS} ${OBJS} Test.o -o TestGrammar ${CC} ${CCFLAGS} ${OBJS} Latte.o -o latc
Absyn.o : Absyn.cpp Absyn.h Absyn.o : Absyn.cpp Absyn.h
${CC} ${CCFLAGS} -c Absyn.cpp ${CC} ${CCFLAGS} -c Absyn.cpp
...@@ -44,5 +44,5 @@ Printer.o : Printer.cpp Printer.h Absyn.h ...@@ -44,5 +44,5 @@ Printer.o : Printer.cpp Printer.h Absyn.h
Skeleton.o : Skeleton.cpp Skeleton.h Absyn.h Skeleton.o : Skeleton.cpp Skeleton.h Absyn.h
${CC} ${CCFLAGS} -Wno-unused-parameter -c Skeleton.cpp ${CC} ${CCFLAGS} -Wno-unused-parameter -c Skeleton.cpp
Test.o : Test.cpp Parser.h Printer.h Absyn.h Latte.o : Latte.cpp Parser.h Printer.h Absyn.h
${CC} ${CCFLAGS} -c Test.cpp ${CC} ${CCFLAGS} -c Latte.cpp
/*** Compiler Front-End Test automatically generated by the BNF Converter ***/
/* */
/* This test will parse a file, print the abstract syntax tree, and then */
/* pretty-print the result. */
/* */
/****************************************************************************/
#include <stdio.h>
#include <string.h>
#include "Parser.h"
#include "Printer.h"
#include "Absyn.h"
void usage() {
printf("usage: Call with one of the following argument combinations:\n");
printf("\t--help\t\tDisplay this help message.\n");
printf("\t(no arguments) Parse stdin verbosely.\n");
printf("\t(files)\t\tParse content of files verbosely.\n");
printf("\t-s (files)\tSilent mode. Parse content of files silently.\n");
}
int main(int argc, char ** argv)
{
FILE *input;
int quiet = 0;
char *filename = NULL;
if (argc > 1) {
if (strcmp(argv[1], "-s") == 0) {
quiet = 1;
if (argc > 2) {
filename = argv[2];
} else {
input = stdin;
}
} else {
filename = argv[1];
}
}
if (filename) {
input = fopen(filename, "r");
if (!input) {
usage();
exit(1);
}
} else input = stdin;
/* The default entry point is used. For other options see Parser.H */
Program *parse_tree = pProgram(input);
if (parse_tree)
{
printf("\nParse Successful!\n");
if (!quiet) {
printf("\n[Abstract Syntax]\n");
ShowAbsyn *s = new ShowAbsyn();
printf("%s\n\n", s->show(parse_tree));
printf("[Linearized Tree]\n");
PrintAbsyn *p = new PrintAbsyn();
printf("%s\n\n", p->print(parse_tree));
}
return 0;
}
return 1;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment