1. Trang chủ
  2. » Luận Văn - Báo Cáo

Môn chương trình dịch Viết trình biên dịch để dịch 1 đoạn chương trình

55 417 2

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 55
Dung lượng 2,57 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

LỜI NÓI ĐẦUChương trình dịch là một môn học của ngành khoa học máy tính.. Cùng với sự phát triển của các chuyên ngành : Lý thuyết ngôn ngữ hình thức & Ôtômat vàcác chuyên ngành khác, lý

Trang 1

LỜI NÓI ĐẦU

Chương trình dịch là một môn học của ngành khoa học máy tính Cùng với

sự phát triển của các chuyên ngành : Lý thuyết ngôn ngữ hình thức & Ôtômat vàcác chuyên ngành khác, lý thuyết thiết kế trình biên dịch ngày một hoàn thiện hơn

Ngày nay lý thuyết trình biên dịch đã được ứng dụng không những trongviệc thiết kế trình biên dịch cho ngôn ngữ lập trình mà còn trong lĩnh vực trí tuệnhân tạo - hiểu ngôn ngữ tự nhiên, dịch máy …

Đồ án môn học : CHƯƠNG TRÌNH DỊCH là dịp tốt để cho việc học tập

của sinh viên chuyên ngành tin học nắm vững lý thuyết và cách thiết kế trình biêndịch được tốt

Vì thế chúng em thực hiện đồ án, với đề tài 14:

Viết trình biên dịch để dịch 1 đoạn chương trình gồm các phát biểu sau:

- Phát biểu ghép, if trong C

- Các phát biểu kết thúc bằng dấu ;

- Các biểu thức trong các phát biểu là các biểu thức số học và logic, gồm các phép toán +, -, *, /, (?:), !, &&, || và các phép toán so sánh Toán hạng gồm các danh hiệu, hằng số thực và nguyên (kể cả biểu thức) và kiểu array Độ ưu tiên các phép toán tương tự C

- Thực hiện chuyển đổi kiểu từ nguyên sang thực khi cần thiết

Em xin chân thành cảm ơn sự hướng dẫn tận tình của cô Phan Thị Thu

Hồng và sự đóng góp ý kiến của các bạn, nhằm giúp đỡ cho đồ án hoàn thành đúng

yêu cầu Mặc dù đã cố gắng tham khảo nhiều tài liệu nhưng quá trình thực hiệnkhó tránh khỏi những thiếu sót và hạn chế Rất mong nhận được những ý kiến nhậnxét, đóng góp của thầy cô và các bạn

Nhóm sinh viên thực hiện

Nguyễn Thị Diệp Phạm Thị Định Nguyễn Thị Gấm Nguyễn Thị Nụ

Lớp : THC 52

Trang 3

II Các phát biểu kết thúc bằng dấu ;

Đa số các câu lệnh kết thúc bằng dấu ; dùng để ngăn cách các câu lệnh Ví

dụ như: Phát biểu gán (a=0, gán 0 cho biến a), khai báo biến, hằng (float a, khai báo biến a có kiểu số thực)…

Trang 4

4 Toán tử chọn theo điều kiện

(Điều kiện) ? biểu thức 1 : biểu thức 2

- Điều kiện đúng thì biểu thức nhận giá trị biểu thức 1, các trường hợp còn lại bằngbiểu thức 2

Kiểu tên_mảng [kích_thước_chiều1][kích_thước_chiều2]…[kích_thước_chiều_n]

6 Độ ưu tiên của phép toán

- Có 15 mức ưu tiên, thường thì các toán tử 1 ngôi có độ ưu tiên cao hơn 2 ngôi Thứ tự ưu tiên được chỉ rõ hơn trong dấu ()

7 Chuyển đổi kiểu nguyên sang kiểu số thực

int i;

Trang 5

- Chuyển kiểu: (float) i;

B Phân tích từ vựng

I Bảng token

hoặc dấu gạch chân theo sau là số hoặcchữ, dấu gạch chân và không trùng vớikhóa

Trang 8

7 6

1 0

‘E’|‘e’

‘E’|‘e’

*

Trang 9

Chú ý: Một số trạng thái có thêm một dấu * để chỉ ra đồ thị chuyển đã xử lý quá

một ký tự của phần khác Ký hiệu này được lưu và trả lại khi đoán nhận phần khác

Start

1

5 4 3

2 +

/

* -

*

Trang 10

C Phân tích cú pháp

I Định nghĩa văn phạm tổng quát

S → void main left right block

block → begin assign_list end

assign_list → assign assign_list |ε

assign → dec_var | begin assign_list end | pbif

7 8

6

] ) (

[

9 10

!

1 8

19

2 0

15

13 14 12

17

21

11

{ }

; :

? ,

16

=

Trang 11

dec_var → type id id1 semi dec_var

id1 → coma id1 | open num close id1 |ε

pbif → if expr pbif | if expr pbif else pbif | begin assign_list end |

id asg expr semiexpr → exp aws expr colon expr

exp → exp or exp1 | exp1

exp1 → exp1 and term | term

term → term relop1 term1 | term1

term1 → term1 relop2 term2 | term2

term2 → term2 op1 term3| term3

term3 → term3 op2 factor | factor

factor → not factor1

factor1 → left exp right| id | num | real

* Văn phạm tăng cường

S’ → S(1) S → dec_var void main left right block

(2) dec_var → type id id1 semi dec_var

(4) id1 → coma id id1

(5) id1 → open num close id1

(6) id1 →ε

(7) block → begin assign_list end

(8) assign_list → assign assign_list

(9) assign_list →ε

(10) assign → dec_var

(11) assign → if expr assign

(12) assign → if expr assign else assign

(13) assign → begin assign_list end

(14) assign → id asg expr semi

(15) expr → exp aws expr colon expr

(16) expr → exp

Trang 12

(17) exp → exp or exp1

(29) factor → not factor1

(30) factor1 → left expr right

(31) factor1 → id

(32) factor1 → num

(33) factor1 → real

(34) factor1 → left type right id

II Các ký hiệu kết thúc và chưa kết thúc

Trang 14

S → dec_var void main left right block, $

dec_var → type id id1 semi dec_var, void

dec_var → , void

goto(I0, S)

-I 1: S’→S., $

goto(I0, dec_var)

-I 2: S → dec_var void main left right block, $

goto(I0, type)

-I 3: dec_var → type id id1 semi dec_var, void

goto(I2, void)

-I 4: S → dec_var void main left right block, $

goto(I3, id)

-I 5: dec_var → type id id1 semi dec_var, void

id1 → coma id id1, semi

id1 → open num close id1, semi

id1 → , semi

goto(I4, main)

-I 6: S → dec_var void main left right block, $

Trang 15

-goto(I5, id1)

I 7: dec_var → type id id1 semi dec_var, void

goto(I5, coma)

-I 8: id1 → coma id id1, semi

goto(I5, open)

-I 9: id1 → open num close id1, semi

goto(I6, left)

-I 10: S → dec_var void main left right block, $

goto(I7, semi)

-I 11: dec_var → type id id1 semi dec_var, void

dec_var → type id id1 semi dec_var, void

goto(I8, id)

-I 12: id1 → coma id id1, semi

id1 → coma id id1, semi

id1 → open num close id1, semi

id1 → , semi

goto(I9, num)

-I 13: id1 → open num close id1, semi

goto(I10, right)

-I 14: S → dec_var void main left right block, $

block → begin assign_list end, $

goto(I11, dec_var)

-I 15: dec_var → type id id1 semi dec_var., void

goto(I11, type) ≡ I3

Trang 16

goto(I12, id1)

-I 16: id1 → coma id id1., semi

goto(I12, coma) ≡ I8, goto(I12, open) ≡ I9

goto(I13, close)

-I 17: id1 → open num close id1, semi

id1 → coma id id1, semi

id1 → open num close id1, semi

id1 → , semi

goto(I14, block)

-I 18: S → dec_var void main left right block., $

goto(I14, begin)

-I 19: block → begin assign_list end, $

assign_list → assign assign_list, end

assign_list → , end

assign → dec_var, type | begin | id | if |ε

dec_var → type id id1 semi dec_var, type | begin | id | if |εassign → if expr assign, type | begin | id | if |ε

assign → if expr assign else assign, type | begin | id | if |εassign → begin assign_list end, type | begin | id | if |εassign → id asg expr semi, type | begin | id | if |ε

goto(I17, id)

-I 20: id1 → open num close id1., semi

goto(I17, coma) ≡ I8, goto(I17, open) ≡ I9

goto(I19, assign_list)

Trang 17

-goto(I19, assign)

I 22: assign_list → assign assign_list, end

assign_list → assign assign_list, end

assign_list → , end

assign → dec_var, type | begin | id | if |ε

dec_var → type id id1 semi dec_var, type | begin | id | if |ε

assign → if expr assign, type | begin | id | if |ε

assign → if expr assign else assign, type | begin | id | if |ε

assign → begin assign_list end, type | begin | id | if |ε

assign → id asg expr semi, type | begin | id | if |ε

I 25: assign → if expr assign, type | begin | id | if |ε

assign → if expr assign else assign, type | begin | id | if |ε

expr → exp aws expr colon expr, type | begin | id | if |ε

expr → exp, type | begin | id | if |ε

exp → exp or exp1, type | begin | id | if | aws | or |ε

exp → exp1, type | begin | id | if | aws | or |ε

exp1 → exp1 and term, type | begin | id | if | aws | or | and |ε

exp1 → term, type | begin | id | if | aws | or | and |ε

term → term relop1 term1, type | begin | id | if | aws | or | and | relop1 |εterm → term1, type | begin | id | if | aws | or | and | relop1 |ε

term1 → term1 relop2 term2, type| begin| id| if| aws| or| and| relop1|relop2|εterm1 → term2, type| begin| id| if| aws| or| and| relop1|relop2|ε

term2 →.term2 op1 term3, type|begin|id|if|aws|or|and|relop1|relop2|op1|ε

Trang 18

term2 → term3, type|begin|id|if|aws|or|and|relop1|relop2|op1|ε

term3→.term3 op2 factor,type|begin|id|if|aws|or|and|relop1|relop2|op1|op2|εterm3 → factor, type|begin|id|if|aws|or|and|relop1|relop2|op1|op2|ε

factor → not factor1, type|begin|id|if|aws|or|and|relop1|relop2|op1|op2|ε -goto(I19, begin)

I 26: assign → begin assign_list end, type | begin | id | if |ε

assign_list → assign assign_list, end

assign_list → , end

assign → dec_var, type | begin | id | if |ε

dec_var → type id id1 semi dec_var, type | begin | id | if |ε

assign → if expr assign, type | begin | id | if |ε

assign → if expr assign else assign, type | begin | id | if |ε

assign → begin assign_list end, type | begin | id | if |ε

assign → id asg expr semi, type | begin | id | if |ε

I 29: assign_list → assign assign_list., end

goto(I22, assign) ≡ I22, goto(I22, dec_var) ≡ I23, goto(I22, type) ≡ I24

goto(I22, if) ≡ I25, goto(I22, begin) ≡ I26, goto(I22, id) ≡ I27

goto(I24, id)

I 30: dec_var → type id id1 semi dec_var, type | begin | id | if |ε

id1 → coma id id1, semi

id1 → open num close id1, semi

id1 → , semi

Trang 19

-goto(I25, expr)

I 31: assign → if expr assign, type | begin | id | if |ε

assign → if expr assign else assign, type | begin | id | if |ε

assign → dec_var, type | begin | id | if |ε | else

dec_var → type id id1 semi dec_var, type | begin | id | if |ε | else

assign → if expr assign, type | begin | id | if |ε | else

assign → if expr assign else assign, type | begin | id | if |ε | else

assign → begin assign_list end, type | begin | id | if |ε | esle

assign → id asg expr semi, type | begin | id | if |ε | else

-goto(I25, exp)

I 32: expr → exp aws expr colon expr, type | begin | id | if |ε

expr → exp., type | begin | id | if |ε

exp → exp or exp1, type | begin | id | if | aws | or |ε

-goto(I25, exp1)

I 33: exp → exp1., type | begin | id | if | aws | or |ε

exp1 → exp1 and term, type | begin | id | if | aws | or | and |ε

-goto(I25, term)

I 34: exp1 → term., type | begin | id | if | aws | or | and |ε

term → term relop1 term1, type | begin | id | if | aws | or | and | relop1 |ε -

goto(I25, term1)

I 35: term → term1., type | begin | id | if | aws | or | and | relop1 |ε

term1 → term1 relop2 term2, type| begin| id| if| aws| or| and| relop1|relop2|ε -

goto(I25, term2)

I 36: term1 → term2., type| begin| id| if| aws| or| and| relop1|relop2|ε

term2 →term2 op1 term3, type|begin|id|if|aws|or|and|relop1|relop2|op1|ε

Trang 20

-goto(I25, term3)

I 37: term2 → term3., type|begin|id|if|aws|or|and|relop1|relop2|op1|ε

term3→term3 op2 factor,type|begin|id|if|aws|or|and|relop1|relop2|op1|op2|ε -

goto(I25, factor)

I 38: term3 → factor., type|begin|id|if|aws|or|and|relop1|relop2|op1|op2|ε

-goto(I25, not)

I 39: factor → not factor1, type|begin|id|if|aws|or|and|relop1|relop2|op1|op2|ε

factor1 → left expr right,type|begin|id|if|aws|or|and|

relop1|relop2|op1|op2|εfactor1 → id, type|begin|id|if|aws|or|and|relop1|relop2|op1|op2|ε

factor1 → num, type|begin|id|if|aws|or|and|relop1|relop2|op1|op2|ε

factor1 → real, type|begin|id|if|aws|or|and|relop1|relop2|op1|op2|ε

factor1 → left type right id, type|begin|id|if|aws|or|and|

relop1|relop2|op1|op2|ε -

goto(I26, assign_list)

I 40: assign → begin assign_list end, type | begin | id | if |ε

goto(I26, assign) ≡ I22, goto(I26, dec_var) ≡ I23, goto(I26, type) ≡ I24

goto(I26, if) ≡ I25, goto(I26, begin) ≡ I26, goto(I26, id) ≡ I27

-goto(I27, asg)

I 41: assign → id asg expr semi, type | begin | id | if |ε

expr → exp aws expr colon expr, semi

expr → exp, semi

exp → exp or exp1, semi | aws | or

exp → exp1, semi | aws | or

exp1 → exp1 and term, semi | aws | or | and

Trang 21

exp1 → term, semi | aws | or | and

term → term relop1 term1, semi | aws | or | and | relop1

term → term1, semi | aws | or | and | relop1

term1 → term1 relop2 term2, semi | aws | or | and | relop1| relop2term1 → term2, semi | aws | or | and | relop1| relop2

term2 →.term2 op1 term3, semi | aws | or | and | relop1| relop2 | op1term2 → term3, semi | aws | or | and | relop1| relop2 | op1

term3→.term3 op2 factor, semi | aws | or | and | relop1| relop2 |op1|op2term3 → factor, semi | aws | or | and | relop1| relop2 |op1|op2

factor → not factor1, semi | aws | or | and | relop1| relop2 |op1|op2 -

goto(I30, id1)

I 42: dec_var → type id id1 semi dec_var, type | begin | id | if |ε

Goto(I30, coma) ≡ I8, goto(I30, open) ≡ I9

Goto(I31, assign)

I 43: assign → if expr assign., type | begin | id | if |ε

assign → if expr assign else assign, type | begin | id | if |ε

I 46: assign → if expr assign, type | begin | id | if |ε | else

assign → if expr assign else assign, type | begin | id | if |ε | else

expr → exp aws expr colon expr, type | begin | id | if |ε

expr → exp, type | begin | id | if |ε

exp → exp or exp1, type | begin | id | if | aws | or |ε

exp → exp1, type | begin | id | if | aws | or |ε

exp1 → exp1 and term, type | begin | id | if | aws | or | and |ε

Trang 22

exp1 → term, type | begin | id | if | aws | or | and |ε

term → term relop1 term1, type | begin | id | if | aws | or | and | relop1 |εterm → term1, type | begin | id | if | aws | or | and | relop1 |ε

term1 → term1 relop2 term2, type| begin| id| if| aws| or| and|

relop1|relop2|εterm1 → term2, type| begin| id| if| aws| or| and| relop1|relop2|ε

term2 →.term2 op1 term3, type|begin|id|if|aws|or|and|

relop1|relop2|op1|εterm2 → term3, type|begin|id|if|aws|or|and|relop1|relop2|op1|ε

term3→.term3 op2 factor,type|begin|id|if|aws|or|and|

relop1|relop2|op1|op2|εterm3 → factor, type|begin|id|if|aws|or|and|relop1|relop2|op1|op2|ε

factor → not factor1,type|begin|id|if|aws|or|and|relop1|relop2|op1|op2|εgoto(I31, begin)

I 47: assign → begin assign_list end, type | begin | id | if |ε | else

assign_list → assign assign_list, end

assign_list → , end

assign → dec_var, type | begin | id | if |ε

dec_var → type id id1 semi dec_var, type | begin | id | if |ε

assign → if expr assign, type | begin | id | if |ε

assign → if expr assign else assign, type | begin | id | if |ε

assign → begin assign_list end, type | begin | id | if |ε

assign → id asg expr semi, type | begin | id | if |ε

I 49: expr → exp aws expr colon expr, type | begin | id | if |ε

expr → exp aws expr colon expr, colon

expr → exp, colon

Trang 23

exp → exp or exp1, colon | aws | or

exp → exp1, colon | aws | or

exp1 → exp1 and term, colon | aws | and | or

exp1 → term, colon | aws | and | or

term → term relop1 term1, colon | aws | and | relop1 | or

term → term1, colon | aws | and | relop1 | or

term1 → term1 relop2 term2, colon | aws | and | relop1 | relop2 | or

term1 → term2, colon | aws | and | relop1 | relop2 | or

term2 →.term2 op1 term3, colon|aws|or|and|relop1|relop2|op1

term2 → term3, colon |aws|or|and|relop1|relop2|op1

term3→.term3 op2 factor,colon|aws|or|and|relop1|relop2|op1|op2

term3 → factor, colon|aws|or|and|relop1|relop2|op1|op2

factor → not factor1, colon|aws|or|and|relop1|relop2|op1|op2

Goto(I32, or)

I 50: exp → exp or exp1, type | begin | id | if | aws | or |ε

exp1 → exp1 and term, type | begin | id | if | aws | or |ε | and

exp1 → term, type | begin | id | if | aws | or |ε | and

term → term relop1 term1, type | begin | id | if | aws | or |ε | and | relop1term → term1, type | begin | id | if | aws | or |ε | and | relop1

term1 →.term1 relop2 term2, type| begin| id| if| aws| or|ε | and| relop1| relop2term1 → term2, type| begin| id| if| aws| or|ε | and| relop1| relop2

term2 →.term2 op1 term3, type|begin|id|if| aws| or|ε | and| relop1| relop2|op1term2 → term3, type| begin| id| if| aws| or|ε | and| relop1| relop2| op1

term3 → term3 op2 factor, type|begin|id|if|aws|or|ε |and|

relop1|relop2|op1|op2term3 → factor, type| begin| id| if| aws| or|ε | and| relop1| relop2|op1|op2factor →.not factor1, type|begin| id| if| aws| or|ε | and| relop1| relop2|op1|op2 -

Goto(I33, and)

I 51: exp1 → exp1 and term, type | begin | id | if | aws | or | and |ε

Trang 24

term → term relop1 term1, type | begin | id | if | aws | or |ε | and | relop1term → term1, type | begin | id | if | aws | or |ε | and | relop1

term1 →.term1 relop2 term2, type| begin| id| if| aws| or|ε | and| relop1| relop2term1 → term2, type| begin| id| if| aws| or|ε | and| relop1| relop2

term2 →.term2 op1 term3, type|begin|id|if| aws| or|ε | and| relop1| relop2|op1term2 → term3, type| begin| id| if| aws| or|ε | and| relop1| relop2| op1

term3 → term3 op2 factor, type|begin|id|if|aws|or|ε |and|

relop1|relop2|op1|op2term3 → factor, type| begin| id| if| aws| or|ε | and| relop1| relop2|op1|op2factor →.not factor1, type|begin| id| if| aws| or|ε | and| relop1| relop2|op1|op2 -

Goto(I34, relop1)

I 52: term → term relop1 term1, type | begin | id | if | aws | or | and | relop1 |ε

term1 →.term1 relop2 term2, type| begin| id| if| aws| or|ε | and| relop1| relop2term1 → term2, type| begin| id| if| aws| or|ε | and| relop1| relop2

term2 →.term2 op1 term3, type|begin|id|if| aws| or|ε | and| relop1| relop2|op1term2 → term3, type| begin| id| if| aws| or|ε | and| relop1| relop2| op1

term3 → term3 op2 factor, type|begin|id|if|aws|or|ε |and|

relop1|relop2|op1|op2term3 → factor, type| begin| id| if| aws| or|ε | and| relop1| relop2|op1|op2factor →.not factor1, type|begin| id| if| aws| or|ε | and| relop1| relop2|op1|op2 -Goto(I35, relop2)

I 53: term1 → term1 relop2 term2, type| begin| id| if| aws| or| and| relop1|relop2|ε

term2 →.term2 op1 term3, type|begin|id|if| aws| or|ε | and| relop1| relop2|op1term2 → term3, type| begin| id| if| aws| or|ε | and| relop1| relop2| op1

term3 → term3 op2 factor, type|begin|id|if|aws|or|ε |and|

relop1|relop2|op1|op2term3 → factor, type| begin| id| if| aws| or|ε | and| relop1| relop2|op1|op2factor →.not factor1, type|begin| id| if| aws| or|ε | and| relop1| relop2|op1|op2 -

Goto(I36, op1)

Trang 25

I 54: term2 →term2 op1 term3, type|begin|id|if|aws|or|and|relop1|relop2|op1|ε

term3 → term3 op2 factor, type|begin|id|if|aws|or|ε |and|

relop1|relop2|op1|op2term3 → factor, type| begin| id| if| aws| or|ε | and| relop1| relop2|op1|op2factor →.not factor1, type|begin| id| if| aws| or|ε | and| relop1| relop2|op1|op2 -

Goto(I37, op2)

I 55: term3→term3 op2 factor,type|begin|id|if|aws|or|and|relop1|relop2|op1|op2|ε

factor →.not factor1, type|begin| id| if| aws| or|ε | and| relop1| relop2|op1|op2 -

Goto(I39, factor1)

I 56: factor → not factor1., type|begin|id|if|aws|or|and|relop1|relop2|op1|op2|ε -

Goto(I39, left)

I 57: factor1 → left expr right, type | begin | id | if | aws | or | and |

relop1| relop2 |op1 |op2 |εexpr → exp aws expr colon expr, right

expr → exp, right

exp → exp or exp1, right | aws | or

exp → exp1, right | aws | or

exp1 → exp1 and term, right | aws | or | and

exp1 → term, right | aws | or | and

term → term relop1 term1, right | aws | or | and | relop1

term → term1, right | aws | or | and | relop1

term1 → term1 relop2 term2, right | aws | or | and | relop1 | relop2

term1 → term2, right | aws | or | and | relop1 | relop2

term2 →.term2 op1 term3, right | aws | or | and | relop1 | relop2 | op1

term2 → term3, right | aws | or | and | relop1 | relop2 | op1

term3→.term3 op2 factor, right | aws | or | and | relop1 | relop2 | op1| op2term3 → factor, right | aws | or | and | relop1 | relop2 | op1| op2

factor → not factor1, right | aws | or | and | relop1 | relop2 | op1| op2

factor1 → left type right id, type|begin|id|if|aws|or|and|

Trang 26

relop1|relop2|op1|op2|ε -Goto(I39, id)

I 58: factor1 → id., type|begin|id|if|aws|or|and|relop1|relop2|op1|op2|ε -

I 63: expr → exp aws expr colon expr, semi

expr → exp., semi

exp → exp or exp1, semi | aws | or

-Goto(I41, exp1)

I 64: exp → exp1., semi | aws | or

exp1 → exp1 and term, semi | aws | or | and

-Goto(I41, term)

I 65: exp1 → term., semi | aws | or | and

term → term relop1 term1, semi | aws | or | and | relop1

-Goto(I41, term1)

I 66: term → term1., semi | aws | or | and | relop1

term1 → term1 relop2 term2, semi | aws | or | and | relop1| relop2 -

Goto(I41, term2)

I 67: term1 → term2., semi | aws | or | and | relop1| relop2

Trang 27

term2 →term2 op1 term3, semi | aws | or | and | relop1| relop2 | op1 -

Goto(I41, term3)

I 68: term2 → term3., semi | aws | or | and | relop1| relop2 | op1

term3→term3 op2 factor, semi | aws | or | and | relop1| relop2 |op1|op2 -

Goto(I41, factor)

I 69: term3 → factor., semi | aws | or | and | relop1| relop2 |op1|op2

-Goto(I41, not)

I 70: factor → not factor1, semi | aws | or | and | relop1| relop2 |op1|op2

factor1 → left expr right, semi| aws| or| and| relop1| relop2|op1|op2factor1 → id, semi | aws | or | and | relop1| relop2 |op1|op2

factor1 → num, semi | aws | or | and | relop1| relop2 |op1|op2

factor1 → real, semi | aws | or | and | relop1| relop2 |op1|op2

factor1 → left type right id, semi | aws | or | and | relop1| relop2 |op1|op2 -

Goto(I42, semi)

I 71: dec_var → type id id1 semi dec_var, type | begin | id | if |ε

dec_var → type id id1 semi dec_var, type | begin | id | if |ε

dec_var → , type | begin | id | if |ε

-Goto(I43, else)

I 72: assign → if expr assign else assign, type | begin | id | if |ε

assign → dec_var, type | begin | id | if |ε

dec_var → type id id1 semi dec_var, type | begin | id | if |ε

assign → if expr assign, type | begin | id | if |ε

assign → if expr assign else assign, type | begin | id | if |ε

assign → begin assign_list end, type | begin | id | if |ε

assign → id asg expr semi, type | begin | id | if |ε

-Goto(I45, id)

I 73: dec_var → type id id1 semi dec_var, type | begin | id | if |ε | else

id1 → coma id id1, semi

Ngày đăng: 20/03/2015, 23:30

TỪ KHÓA LIÊN QUAN

🧩 Sản phẩm bạn có thể quan tâm

w