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) * *

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

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

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

橡Pro PDF

i


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

untitled

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

tuat1.dvi

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

‚æ4›ñ

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

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

untitled

lexex.dvi

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

/* 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



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


PowerPoint Presentation

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

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

ohp03.dvi

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

生活設計レジメ

I II III 28 29


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


II ( ) prog8-1.c s1542h017%./prog8-1 1 => 35 Hiroshi 2 => 23 Koji 3 => 67 Satoshi 4 => 87 Junko 5 => 64 Ichiro 6 => 89 Mari 7 => 73 D

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

10

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 >=

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

r07.dvi

ohp07.dvi

ex14.dvi

PowerPoint プレゼンテーション

untitled

プログラミング言語処理系論 (4) Design and Implementation of Programming Language Processors

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

超初心者用

r03.dvi

ii

A/B (2018/10/19) Ver kurino/2018/soft/soft.html A/B

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

untitled

i

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

Taro-リストⅢ(公開版).jtd

(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

AccessflÌfl—−ÇŠš1

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

卒 業 研 究 報 告.PDF

2

* ライブラリ関数 islower(),toupper() を使ったプログラム 1 /* 2 Program : trupper.c 3 Student-ID : K 4 Author : TOUME, Kouta 5 Comments : Used Library function i

ohp08.dvi


yacc.dvi

O(N) ( ) log 2 N

C B

kiso2-09.key


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

86 7 I ( 13 ) II ( )

r08.dvi

GPLとWordPress

入門ガイド

1 1.1 C 2 1 double a[ ][ ]; 1 3x x3 ( ) malloc() malloc 2 #include <stdio.h> #include

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

[ 1] 1 Hello World!! 1 #include <s t d i o. h> 2 3 int main ( ) { 4 5 p r i n t f ( H e l l o World!! \ n ) ; 6 7 return 0 ; 8 } 1:

SC-85X2取説


Taro-リストⅠ(公開版).jtd

joho07-1.ppt

[1] #include<stdio.h> main() { printf("hello, world."); return 0; } (G1) int long int float ± ±

1.ppt

WinHPC ppt

C 言語第 3 回 2 a と b? 関係演算子 a と b の関係 関係演算子 等しい a==b 等しくない a!=b より大きい a>b 以上 a>=b より小さい a<b 以下 a<=b 状態 真偽 値 条件が満たされた場合 TRUE( 真 ) 1(0 以外 ) 条件が満たされなかった場合 F

Taro-最大値探索法の開発(公開版

ポインタ変数

1 4 2 EP) (EP) (EP)

第1部 一般的コメント

o 2o 3o 3 1. I o 3. 1o 2o 31. I 3o PDF Adobe Reader 4o 2 1o I 2o 3o 4o 5o 6o 7o 2197/ o 1o 1 1o

プログラミング基礎

prog-text.dvi

ex12.dvi

untitled

表1票4.qx4

福祉行財政と福祉計画[第3版]

Prog1_15th

第1章 国民年金における無年金

8 / 0 1 i++ i 1 i-- i C !!! C 2

橡ミュラー列伝Ⅰ.PDF

Taro-再帰関数Ⅱ(公開版).jtd

main

Transcription:

2015 2015 07 30 10:30 12:00 I. I VI II. III. IV. a d V. VI. 80 100 60 1

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) * * x x + x x II. (yx x(yz)*)* yxxyzyzyyzxy yxxyzyz : yxxyzyzy, yxxyzyzyy,..., yxxyzyzyyzxy 7 (1) xyzyzyxyzyxy (2) xyzyzyxxyzyz (3) yxzxyzyxxyzx (4) xyzyxxyzyxxx III. (1) (4) C (A) (E) (1) (4) 2

(1) #include <stdio.h> int main(void) { /* printf("hello World!\n"); return 0; (2) ; #include <stdio.h> int main(void) { printf("hello World!\n") return 0 (3) #include <stdio.h> int main(void) { printf( Hello! World\n ); return 0; (4) " #include <stdio.h> int main(void) { printf(hello); return 0; (1) (4) (A) (B) (C) (D) (E) 3

IV. BNF E id E!! E E : E E == E ( E ) id 1!! : ==!! : : == (1) (5) 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) < > \!! : == ( ) id < < < < <!! (1) > > < > < > : < (2) > < > < > == < (3) (4) < > < > ( < < < < (5) < ) > > > > > id > > > > > 4

V. BNF L A L! A L ˆ A A N A & N N ( L ) id L, A, N!, ˆ, &, (, ), id start symbol L (1) A BNF A N A A ε & N A L L (2) (4) (1) L A BNF (2) Follow(L ) (3) Follow(A ) (4) A, A $ L L A A N id ( )! ˆ & $ (4) (A) N A (B) ε (C) & N A (D) (5) L, L1, A, A1, N A, A1, N L, L1, A, A1, N L, L, A, A, N : & 1 ASCII id C id ID yylex token eat token 5

reporterror #include <stdio.h> #include <stdlib.h> /* exit() */ #include <string.h> /* strcmp() */ #include <ctype.h> /* isalpha() */ /* */ #define ID 257 /* x */ int token; /* */ /* */ void reporterror(void); int yylex(void); void eat(int t); void L(void); void L1(void); void A(void); void A1(void); void N(void); /* **************************************************************** */ * L, L1, A, A1, N */ /* **************************************************************** */ /* */ void reporterror(void) { printf(" \n"); exit(0); /* */ int main() { /* main */ token = yylex(); /* */ L(); if (token == EOF) { printf("!\n"); else { reporterror(); int yylex(void) { /* */ int c; char buf[256]; do { /* */ c = getchar(); while (c == c == \t c == \n ); 6

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); return ID; else { /* */ return c; /* & */ void eat(int t) { /* token token */ if (token == t) { /* */ token = yylex(); return; else { reporterror(); 7

VI. LR I, II E id I { X II E { X III E # id IV X id = E V X ; id = E VI LR E, X id, {,, #, =, ; id 1 start symbol E bison LR : bison -v LR id { # = ; $ E X 0 shift 1 shift 2 goto 3 1 reduce I 2 shift 4 goto 5 3 shift 7 shift 8 shift 6 4 shift 9 5 shift 10 shift 11 6 accept 7 shift 4 goto 12 8 shift 13 9 shift 1 shift 2 goto 14 10 11 shift 15 reduce II 12 shift 16 shift 11 13 reduce IV 14 reduce V shift 7 reduce V shift 8 reduce V 15 16 reduce III shift 17 17 shift 1 shift 2 goto 18 18 reduce VI shift 7 reduce VI shift 8 reduce VI : shift s s goto s s reduce X X 8

? (1) {b=c;s=t{ x=y (2) a{b=c#x{s=t#y; u=v (3) {a={x=y;z=u# a (1) (3) (A). (B). (C). (D). (E). (F). (G). (H). (I). 0 E 3 { 7 id 4 0 E 3 # 8 id13 0 E 3 { 7 X12 ;11 id15 0 E 3 { 7 id 4 = 9 E14 ;11 id15 0 E 3 { 7 id 4 = 9 E14 # 8 id13 0 E 3 { 7 id 4 = 9 E14 16 { 7 id 4 0 E 3 { 7 X12 ;11 id 4 = 9 E14 ;11 id15 0 E 3 { 7 id 4 = 9 E14 ; id 11 4 = 9 E14 ;11 id15 0 E 3 { 7 id 4 = 9 E14 16 { 7 id 4 = 9 E14 16 { 7 id 4 9

2015 2015 07 30 I. Backus-Naur (1) (2) (3) (4) (3 4) II. (3 4) (1) (2) (3) (4) III. (3 4) (1) (2) (3) (4) IV. (1) (2) (3) (4) (5) (2 5) V. (3, 4, 4, 6, 5) L (1) L (2) { (3) {

(4) A A id ( )! ˆ & $ void A(void) { /* */ void A1(void) { /* */ (5) void N(void) { if (token == ID) { /* */ else if ( ) { /* */ eat( ( ); L(); eat( ) ); else reporterror(); VI. LR (1) (2) (3) (4 3)