diff --git a/2.md b/2.md index eeca19e..a57f4ad 100644 --- a/2.md +++ b/2.md @@ -45,7 +45,11 @@ Lex라는 툴을 이용 ## Specification -Regular Expression +**Regular Expression** + +* 여러가지에 사용됨 `grep`, `find`, `sed`, `awk` + + Multiple Matches @@ -69,4 +73,48 @@ FSA를 이용함. DFA와 NFA의 표현력은 동일하나 DFA는 편하게 구현할 수 있다는 장점이 있음. NFA는 RE로부터 쉽게 변환가능하다는 장점이 있음. -**Lexical ANalysis** \ No newline at end of file +**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 + 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) \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..4de9713 --- /dev/null +++ b/docker-compose.yml @@ -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 \ No newline at end of file diff --git a/pdf/P0.pdf b/pdf/P0.pdf new file mode 100644 index 0000000..4b182e9 Binary files /dev/null and b/pdf/P0.pdf differ