complement in 9.18
This commit is contained in:
20
notes/3.md
20
notes/3.md
@@ -16,8 +16,26 @@ An in-order traversal of the leaves is the original input.
|
|||||||
|
|
||||||
### Ambiguity
|
### Ambiguity
|
||||||
|
|
||||||
should be resolved
|
should be removed
|
||||||
|
|
||||||
for example: `A + B * C` should be resolved
|
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
37
src/Makefile
Normal 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 $@ $<
|
||||||
|
|
||||||
Reference in New Issue
Block a user