9월 11일 보충
This commit is contained in:
52
2.md
52
2.md
@@ -45,7 +45,11 @@ Lex라는 툴을 이용
|
|||||||
|
|
||||||
## Specification
|
## Specification
|
||||||
|
|
||||||
Regular Expression
|
**Regular Expression**
|
||||||
|
|
||||||
|
* 여러가지에 사용됨 `grep`, `find`, `sed`, `awk`
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Multiple Matches
|
Multiple Matches
|
||||||
|
|
||||||
@@ -69,4 +73,48 @@ FSA를 이용함.
|
|||||||
DFA와 NFA의 표현력은 동일하나 DFA는 편하게 구현할 수 있다는 장점이 있음.
|
DFA와 NFA의 표현력은 동일하나 DFA는 편하게 구현할 수 있다는 장점이 있음.
|
||||||
NFA는 RE로부터 쉽게 변환가능하다는 장점이 있음.
|
NFA는 RE로부터 쉽게 변환가능하다는 장점이 있음.
|
||||||
|
|
||||||
**Lexical ANalysis**
|
**Lexical Analysis**
|
||||||
|
|
||||||
|
`Lexical Spec -> RE -> NFA -> DFA -> Table`
|
||||||
|
|
||||||
|
## Automation
|
||||||
|
|
||||||
|
* `Lex`(`Flex`: faster implementation of Lex)
|
||||||
|
* `Bison`
|
||||||
|
|
||||||
|
### Lex/Flex
|
||||||
|
|
||||||
|
* Definition Section
|
||||||
|
* can declear or include var, enumeration, using the code in between `%{`, `%}`
|
||||||
|
* provide names sub-rules for complex patterns used in **rules**
|
||||||
|
|
||||||
|
* Rules Section
|
||||||
|
* Lexical Pattern
|
||||||
|
|
||||||
|
|
||||||
|
* User Function Section
|
||||||
|
* Copied to the Lex Program
|
||||||
|
|
||||||
|
|
||||||
|
```c
|
||||||
|
// example.l
|
||||||
|
%{
|
||||||
|
#include <stdio.h>
|
||||||
|
int num_lines = 0;
|
||||||
|
%}
|
||||||
|
%%
|
||||||
|
[ \t] {}
|
||||||
|
a |
|
||||||
|
an |
|
||||||
|
the {printf("%s: is an article\n", yytext)}
|
||||||
|
[a-z]+ {printf("%s: ???\n", yytext)}
|
||||||
|
%%
|
||||||
|
main() {
|
||||||
|
yylex();1
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Handwork
|
||||||
|
|
||||||
|
* Thompson's construction (RE -> NFA)
|
||||||
|
* Subset Construction(NFA -> DFA)
|
||||||
12
docker-compose.yml
Normal file
12
docker-compose.yml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
version: '3.8'
|
||||||
|
|
||||||
|
services:
|
||||||
|
compiler2025:
|
||||||
|
build: .
|
||||||
|
image: cs-compiler-hw:1.0
|
||||||
|
container_name: compiler2025
|
||||||
|
stdin_open: true
|
||||||
|
tty: true
|
||||||
|
working_dir: /work
|
||||||
|
volumes:
|
||||||
|
- .:/work
|
||||||
BIN
pdf/P0.pdf
Normal file
BIN
pdf/P0.pdf
Normal file
Binary file not shown.
Reference in New Issue
Block a user