complement in 9.18

This commit is contained in:
2025-09-18 10:31:12 +09:00
parent b790a4faa0
commit 3acbb7e1e6
2 changed files with 56 additions and 1 deletions

View File

@@ -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

37
src/Makefile Normal file
View File

@@ -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 $@ $<