From 3acbb7e1e6044e504b1246bc2b5243ecc184653e Mon Sep 17 00:00:00 2001 From: yenru0 Date: Thu, 18 Sep 2025 10:31:12 +0900 Subject: [PATCH] complement in 9.18 --- notes/3.md | 20 +++++++++++++++++++- src/Makefile | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 src/Makefile diff --git a/notes/3.md b/notes/3.md index 3546e1a..b9a43a0 100644 --- a/notes/3.md +++ b/notes/3.md @@ -16,8 +16,26 @@ An in-order traversal of the leaves is the original input. ### Ambiguity -should be resolved +should be removed for example: `A + B * C` should be resolved +**removing ambiguity** + +### AST (Abstract Syntax Tree) + + +### Error Handling + +One of the purposes of the compiler is error handling. +- to detect non-valid programs +- and to translate the non-valid to the valid + +## Parsing + +### Top-down Parsing + +**Recursive Descent Parsing** + +### Predictive Parsing \ No newline at end of file diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..22a8a79 --- /dev/null +++ b/src/Makefile @@ -0,0 +1,37 @@ +# Makefile for C-Minus Scanner +# ./lex/tiny.l --> ./cminus.l + +CC = gcc + +CFLAGS = -W -Wall + +OBJS = main.o util.o scan.o +OBJS_LEX = main.o util.o lex.yy.o + +.PHONY: all clean +all: cminus_cimpl cminus_lex + +clean: + -rm -vf cminus_cimpl cminus_lex *.o lex.yy.c + +cminus_cimpl: $(OBJS) + $(CC) $(CFLAGS) -o $@ $(OBJS) + +cminus_lex: $(OBJS_LEX) + $(CC) $(CFLAGS) -o $@ $(OBJS_LEX) -lfl + +main.o: main.c globals.h util.h scan.h + $(CC) $(CFLAGS) -c -o $@ $< + +scan.o: scan.c globals.h util.h scan.h + $(CC) $(CFLAGS) -c -o $@ $< + +util.o: util.c globals.h util.h + $(CC) $(CFLAGS) -c -o $@ $< + +lex.yy.o: lex.yy.c globals.h util.h scan.h + $(CC) $(CFLAGS) -c -o $@ $< + +lex.yy.c: cminus.l + flex -o $@ $< +