Compare commits

..

2 Commits

Author SHA1 Message Date
3acbb7e1e6 complement in 9.18 2025-09-18 10:31:12 +09:00
b790a4faa0 move *.md to notes/*.md and add lecture pdf 2025-09-18 09:35:37 +09:00
7 changed files with 82 additions and 1 deletions

View File

View File

@@ -117,4 +117,7 @@ main() {
### Handwork
* Thompson's construction (RE -> NFA)
* Subset Construction(NFA -> DFA)
* Subset Construction(NFA -> DFA)
DFA Optimization

41
notes/3.md Normal file
View File

@@ -0,0 +1,41 @@
# Syntax Analysis
## Context-Free Grammars (CFG)
## Parse Tree
A tree representation of the derivation
parse tree has `terminals` at the leaves, `non-terminals` at the interior.
An in-order traversal of the leaves is the original input.
* leftmost derivation
* rightmost derivation
### Ambiguity
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

BIN
pdf/L3.pdf Normal file

Binary file not shown.

BIN
pdf/P2.pdf Normal file

Binary file not shown.

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