請問...........
像以下的程式
我要檢查文法要怎樣下手比較好呢?
至於變色 我是用richtextbox先把要變色的字選起來
然後在變色 有比較好的方法嗎?
因為我在這樣做時會一直反白說><
Subject : 製作一個可以檢查syntax正確與否的Editor
Requirement :
1. 一個text editor,具有可以輸入文字的區域,可以鍵入程式,進行文法檢查
2.Grammar: 如下
prog : PROGRAM prog_name VAR dec_list BEGIN stmt_list END DOT
prog_name : ID
dec_list : dec ! dec_list SEMICOLON dec
dec : id_list COLON type
type : INTEGER
id_list : ID ! id_list COMMA ID
stmt_list : stmt ! stmt_list SEMICOLON stmt
stmt : assign ! read ! write ! for
assign : ID ASSIGN exp
exp : term ! exp ADD term ! exp SUB term
term : factor ! term MUL factor ! term DIV factor
factor : ID ! INT ! LPAREN exp RPAREN
read : READ LPAREN id_list RPAREN
write : WRITE LPAREN id_list RPAREN
for : FOR index_exp DO body
index_exp : ID ASSIGN exp TO exp
body : stmt ! BEGIN stmt_list END
p.s. 大寫表示者,為程式系統關鍵字
3.syntax檢查必須要指出或標示出文法錯誤在哪一行
option requirement
1. 正確標示出錯在哪裡,並指出是哪一種錯誤
2.可以處理多個文法錯誤
3.不同的token予以顏色或是不同的標示,例如關鍵字,數字,運算子可以有不同顏色的標示
像以下的程式
我要檢查文法要怎樣下手比較好呢?
至於變色 我是用richtextbox先把要變色的字選起來
然後在變色 有比較好的方法嗎?
因為我在這樣做時會一直反白說><
Subject : 製作一個可以檢查syntax正確與否的Editor
Requirement :
1. 一個text editor,具有可以輸入文字的區域,可以鍵入程式,進行文法檢查
2.Grammar: 如下
prog : PROGRAM prog_name VAR dec_list BEGIN stmt_list END DOT
prog_name : ID
dec_list : dec ! dec_list SEMICOLON dec
dec : id_list COLON type
type : INTEGER
id_list : ID ! id_list COMMA ID
stmt_list : stmt ! stmt_list SEMICOLON stmt
stmt : assign ! read ! write ! for
assign : ID ASSIGN exp
exp : term ! exp ADD term ! exp SUB term
term : factor ! term MUL factor ! term DIV factor
factor : ID ! INT ! LPAREN exp RPAREN
read : READ LPAREN id_list RPAREN
write : WRITE LPAREN id_list RPAREN
for : FOR index_exp DO body
index_exp : ID ASSIGN exp TO exp
body : stmt ! BEGIN stmt_list END
p.s. 大寫表示者,為程式系統關鍵字
3.syntax檢查必須要指出或標示出文法錯誤在哪一行
option requirement
1. 正確標示出錯在哪裡,並指出是哪一種錯誤
2.可以處理多個文法錯誤
3.不同的token予以顏色或是不同的標示,例如關鍵字,數字,運算子可以有不同顏色的標示
全站熱搜
留言列表