:30 12:00 I. I VI II. III. IV. a d V. VI

Similar documents
I. Backus-Naur BNF : N N 0 N N N N N N 0, 1 BNF N N 0 11 (parse tree) 11 (1) (2) (3) (4) II. 0(0 101)* (

:30 12:00 I. I VI II. III. IV. a d V. VI

I. Backus-Naur BNF S + S S * S S x S +, *, x BNF S (parse tree) : * x + x x S * S x + S S S x x (1) * x x * x (2) * + x x x (3) + x * x + x x (4) * *

Minimum C Minimum C Minimum C BNF T okenseq W hite Any D

untitled

i

2

II 3 yacc (2) 2005 : Yacc 0 ~nakai/ipp2 1 C main main 1 NULL NULL for 2 (a) Yacc 2 (b) 2 3 y

<4D F736F F F696E74202D C835B B E B8CDD8AB B83685D>

SC-85X2取説




橡Pro PDF

untitled

‚æ4›ñ

II

これわかWord2010_第1部_ indd

パワポカバー入稿用.indd

これでわかるAccess2010

C言語によるアルゴリズムとデータ構造


平成18年版 男女共同参画白書

III


ii



C による数値計算法入門 ( 第 2 版 ) 新装版 サンプルページ この本の定価 判型などは, 以下の URL からご覧いただけます. このサンプルページの内容は, 新装版 1 刷発行時のものです.

PowerPoint Presentation

エクセルカバー入稿用.indd

i


Wide Scanner TWAIN Source ユーザーズガイド

lexex.dvi

PC Windows 95, Windows 98, Windows NT, Windows 2000, MS-DOS, UNIX CPU

01_.g.r..

untitled



/* do-while */ #include <stdio.h> #include <math.h> int main(void) double val1, val2, arith_mean, geo_mean; printf( \n ); do printf( ); scanf( %lf, &v



活用ガイド (ソフトウェア編)

困ったときのQ&A

ohp03.dvi

入門ガイド

ii

新・明解C言語 ポインタ完全攻略

Microsoft Word - Cプログラミング演習(8)

プログラミング基礎

I ASCII ( ) NUL 16 DLE SP P p 1 SOH 17 DC1! 1 A Q a q STX 2 18 DC2 " 2 B R b

活用ガイド (ソフトウェア編)

untitled

i

untitled

tuat1.dvi

‚æ2›ñ C„¾„ê‡Ìš|

r03.dvi

橡6.プログラム.doc

活用ガイド (ソフトウェア編)

パソコン機能ガイド

パソコン機能ガイド

はしがき・目次・事例目次・凡例.indd

Javaと.NET

卒 業 研 究 報 告.PDF

() / (front end) (back end) (phase) (pass) 1 2


2004年度日本経団連規制改革要望

r07.dvi

() () (parse tree) ( (( ) * 50) ) ( ( NUM 10 + NUM 30 ) * NUM 50 ) ( * ) ( + ) NUM 50 NUM NUM (abstract syntax tree, AST) ( (( ) * 5


ohp07.dvi

18 C ( ) hello world.c 1 #include <stdio.h> 2 3 main() 4 { 5 printf("hello World\n"); 6 } [ ] [ ] #include <stdio.h> % cc hello_world.c %./a.o

長崎県地域防災計画

ONLINE_MANUAL

ONLINE_MANUAL


£Ã¥×¥í¥°¥é¥ß¥ó¥°ÆþÌç (2018) - Â裵²ó ¨¡ À©¸æ¹½Â¤¡§¾ò·ïʬ´ô ¨¡

Microsoft Word - C.....u.K...doc

178 5 I 1 ( ) ( ) ( ) ( ) (1) ( 2 )


44 4 I (1) ( ) (10 15 ) ( 17 ) ( 3 1 ) (2)

生活設計レジメ

I II III 28 29


void hash1_init(int *array) int i; for (i = 0; i < HASHSIZE; i++) array[i] = EMPTY; /* i EMPTY */ void hash1_insert(int *array, int n) if (n < 0 n >=

™…

ex14.dvi


1 1.1 C 2 1 double a[ ][ ]; 1 3x x3 ( ) malloc() 2 double *a[ ]; double 1 malloc() dou

活用ガイド (ハードウェア編)

C B

PowerPoint プレゼンテーション

(ver. 1.3 (2018) ) yacc 1 1 yacc yacc (Yet Another Compiler Compiler) UNIX yacc yacc y *.y yacc ) yacc *.tab.h *.tab.c C C yacc yacc UNIX yacc bison 2

C¥×¥í¥°¥é¥ß¥ó¥° ÆþÌç



A/B (2018/06/08) Ver kurino/2018/soft/soft.html A/B

( ) ( ) lex LL(1) LL(1)

Transcription:

2018 2018 08 02 10:30 12:00 I. I VI II. III. IV. a d V. VI. 80 100 60 1

I. Backus-Naur BNF N N y N x N xy yx : yxxyxy N N x, y N (parse tree) (1) yxyyx (2) xyxyxy (3) yxxyxyy (4) yxxxyxxy N y N x N yx yx II. (wx*w)*w ( ) (L) (w xwwx)* ( ) (R) (B) (N) (1) wxwxxwxww (2) wxwwxwwww (3) wxwwxxwwx (4) wwwxxxxww III. (1) (4) C (A) (E) (1) (4) 2

(1) for ; : #include <stdio.h> int main(void) { int i; for (i = 0: i < 10: i++) { printf("hello!\n"); return 0; (2) #include <stdio.h> int main(void) { double *x; x = 3.14; printf("%f\n", x); return 0; (3) #include <stdio.h> int main(void) { printf("hello! \n"); return 0; (4) " #include <stdio.h> int main(void) { printf("hello!\n ); return 0; (1) (4) (A) (B) (C) (D) (E) 3

IV. BNF E id E ˆ E E == E E && E E > E ( E ) id 1 ˆ == && > ˆ == == && && > a ˆ b ˆ c a ˆ (b ˆ c) a && b && c (a && b) && c a == b == c a > b > c a ˆ b && c (a ˆ b) && c a && b ˆ c a && (b ˆ c) a ˆ b == c (a ˆ b) == c a == b ˆ c a == (b ˆ c) a ˆ b > c (a ˆ b) > c a > b ˆ c a > (b ˆ c) a == b && c (a == b) && c a && b == c a && (b == c) a && b > c (a && b) > c a > b && c a > (b && c) a == b > c (a == b) > c a > b == c a > (b == c) (1) (5) < > \ ˆ == && > ( ) id < < < < < < ˆ (1) > > > < > < > == < (2) > (3) < > < > && < < (4) > < > < > > < < < (5) < > < > ( < < < < < < ) > > > > > > id > > > > > > 4

V. BNF C begin L end I stmt II id = E ; III L L C C E E ( E ) E. id id ( E ) C, L, E begin, end, stmt, id, =, ;, (, ),. start symbol C I, II (1) L BNF L C L IV L ε V C L VI E E VII, VIII,... (2) (4) (1) L, E BNF $ (2) First(C) (3) Follow(L ) (4) Follow(E ) (5) C, L, L, I VI (6) E, E (1) BNF (VII, VIII,...) 5

C L L E E begin end stmt id = ; ( ). $ (7) C, L, L1, E, E1 C, E, E1 C, L, L1, E, E1 C, L, L, E, E reporterror :. 1 ASCII begin C begin BEGIN $ EOF yylex token eat token reporterror #include <stdio.h> /* printf(), EOF */ #include <stdlib.h> /* exit() */ #include <string.h> /* strcmp() */ #include <ctype.h> /* isalpha() */ /* */ #define BEGIN 257 /* begin */ #define END 258 /* end */ #define STMT 259 /* stmt */ #define ID 260 /* id */ int token; /* */ /* */ void reporterror(void); int yylex(void); void eat(int t); void C(void); void L(void); void L1(void); void E(void); void E1(void); 6

/* **************************************************************** */ * C, L, L1, E, E1 */ /* **************************************************************** */ /* */ void reporterror(void) { printf(" \n"); exit(0); /* */ int main() { /* main */ token = yylex(); /* */ C(); if (token == EOF) { printf("!\n"); else { reporterror(); int yylex(void) { /* */ int c; char buf[256]; do { /* */ c = getchar(); while (c == c == \t c == \n ); if (isalpha(c)) { /* */ char* ptr = buf; ungetc(c, stdin); while (1) { c = getchar(); if (!isalpha(c) &&!isdigit(c)) break; *ptr++ = c; *ptr = \0 ; ungetc(c, stdin); if (strcmp(buf, "begin") == 0) return BEGIN; if (strcmp(buf, "end") == 0) return END; if (strcmp(buf, "stmt") == 0) return STMT; if (strcmp(buf, "id") == 0) return ID; reporterror(); else { /* */ return c; /* ; */ void eat(int t) { /* token token */ if (token == t) { /* */ 7

token = yylex(); return; else { reporterror(); 8

VI. LR BNF S x I { B II B B S III ε IV LR I, II S, B {, x, (start symbol) S bison LR : bison -v LR $ x { S B 0 shift 1 shift 2 goto 3 1 reduce I 2 reduce IV goto 4 3 shift 5 4 shift 1 shift 2 shift 6 goto 7 5 6 7 accept reduce II reduce III : shift s s goto s s reduce X X 9

? (1) { { x x (2) { { x { x (3) { { x { x x x (1) (A). 0 { 2 B 4 x 1 (B). 0 { 2 B 4 { 2 6 x 1 (C). 0 { 2 B 4 S 7 x 1 (D). 0 { 2 B 4 { 2 B 4 6 x 1 (2) (A). 0 { 2 B 4 x 1 (B). 0 { 2 B 4 { 2 B 4 x 1 (C). 0 { 2 B 4 { 2 B 4 S 7 x 1 (D). 0 { 2 B 4 S 7 { 2 B 4 S 7 x 1 (3) (A). 0 { 2 { 2 B 4 { 2 B 4 6 (B). 0 { 2 { 2 x 1 { 2 x 1 x 1 6 (C). 0 { 2 B 4 { 2 B 4 { 2 B 4 6 (D). 0 { 2 B 4 { 2 B 4 { 2 B 4 x 1 6 10

2018 2018 08 02 I. Backus-Naur (1) (2) (3) (4) (3 4) II. (3 4) (1) (2) (3) (4) III. (2 4) (1) (2) (3) (4) IV. (1) (2) (3) (4) (5) (2 5) V. (3, 2, 3, 4, 3, 6, 5) E (1) E (2) { (3) { (4) {

(5) C L L (6) E E begin end stmt id = ; ( ). $ void C(void) { switch (token) { case BEGIN: /* */ case STMT: /* */ case ID: /* */ default: reporterror(); void E(void) { /* */ void E1(void) { /* */ (6) VI. LR (4 3) (1) (2) (3)