Commit 1f3906a4 authored by zygzagZ's avatar zygzagZ

fix makefile

parent f5cf7cdc
......@@ -2,4 +2,4 @@
*.l
*.y
/lat/
/TestGrammar
\ No newline at end of file
/latc
\ No newline at end of file
......@@ -3,7 +3,7 @@
#include "Parser.h"
#include "Printer.h"
#include "Absyn.h"
#include "Compiler.h"
// #include "Compiler.h"
#include <fstream>
#include <iostream>
#include <filesystem>
......@@ -63,7 +63,7 @@ int main(int argc, char ** argv)
binaryPath = argv[0];
std::filesystem::path file(filename ? filename : "Instant");
Compiler c(file);
/*Compiler c(file);
std::string out = c.compile(parse_tree);
if (!filename) {
......@@ -81,6 +81,6 @@ int main(int argc, char ** argv)
ll << out;
ll.close();
Compiler::externalCommand(file);
Compiler::externalCommand(file);*/
}
CC=g++
CCFLAGS=-g -W -Wall
CCFLAGS=-g -W -Wall -O3 -std=c++1z
FLEX=flex
FLEX_OPTS=-PGrammar
......@@ -11,17 +11,17 @@ OBJS=Absyn.o Lexer.o Parser.o Printer.o
.PHONY : clean distclean
all : TestGrammar
all : latc
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
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
# distclean : clean
# 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
@echo "Linking TestGrammar..."
${CC} ${CCFLAGS} ${OBJS} Test.o -o TestGrammar
latc : ${OBJS} Latte.o
@echo "Linking latc..."
${CC} ${CCFLAGS} ${OBJS} Latte.o -o latc
Absyn.o : Absyn.cpp Absyn.h
${CC} ${CCFLAGS} -c Absyn.cpp
......@@ -44,5 +44,5 @@ Printer.o : Printer.cpp Printer.h Absyn.h
Skeleton.o : Skeleton.cpp Skeleton.h Absyn.h
${CC} ${CCFLAGS} -Wno-unused-parameter -c Skeleton.cpp
Test.o : Test.cpp Parser.h Printer.h Absyn.h
${CC} ${CCFLAGS} -c Test.cpp
Latte.o : Latte.cpp Parser.h Printer.h Absyn.h
${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