璇嶆硶鍒嗘瀽绋嬪簭鐨勮璁′笌瀹炵幇
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了璇嶆硶鍒嗘瀽绋嬪簭鐨勮璁′笌瀹炵幇相关的知识,希望对你有一定的参考价值。
鏍囩锛?a href='http://www.mamicode.com/so/1/http' title='http'>http 缁撴灉 ++ 鏍囪瘑 缁撴瀯 ica txt ble das
璇嶆硶鍒嗘瀽绋嬪簭锛?em>Lexical Analyzer锛夎姹傦細
- 浠庡乏鑷冲彸鎵弿鏋勬垚婧愮▼搴忕殑瀛楃娴?/p>
- 璇嗗埆鍑烘湁璇嶆硶鎰忎箟鐨勫崟璇嶏紙Lexemes锛?/p>
- 杩斿洖鍗曡瘝璁板綍锛堝崟璇嶇被鍒紝鍗曡瘝鏈韩锛?/p>
- 婊ゆ帀绌烘牸
- 璺宠繃娉ㄩ噴
- 鍙戠幇璇嶆硶閿欒
绋嬪簭缁撴瀯锛?/p>
杈撳叆锛氬瓧绗︽祦锛堜粈涔堣緭鍏ユ柟寮忥紝浠€涔堟暟鎹粨鏋勪繚瀛橈級
澶勭悊锛?/p>
–閬嶅巻锛堜粈涔堥亶鍘嗘柟寮忥級
–璇嶆硶瑙勫垯
杈撳嚭锛氬崟璇嶆祦锛堜粈涔堣緭鍑哄舰寮忥級
–浜屽厓缁?/p>
婧愮▼搴忓涓嬶細
1 #include<stdio.h> 2 #include<conio.h> 3 #include<math.h> 4 #include<string.h> 5 #include<stdlib.h> 6 7 int i, row = 0, line = 0; 8 char test[1000]; //test鏂囦欢涓殑瀛楃 9 int number[100]; //甯告暟琛? 10 char mark[100][5]; //鏍囪瘑绗﹁〃 11 12 //璇嶆硶鍒嗘瀽 13 int wordanalysis() 14 { 15 //鏍囪瘑绗﹀拰淇濈暀瀛?/span> 16 if ((test[i] >= 鈥?/span>A鈥?/span>&&test[i] <= 鈥?/span>Z鈥?/span>)||(test[i]>=鈥?/span>a鈥?/span>&&test[i]<=鈥?/span>z鈥?/span>)) 17 { 18 char word[10]; 19 //淇濈暀瀛楄〃 20 char pro[100][100] = { "PROGRAM", "BEGIN", "END", "VAR", "INTEGER", "WHILE", 21 "IF", "THEN", "ELSE", "DO", "PROCEDURE" ,"char", 22 "int","if","else","var" ,"return","break", 23 "do","while","for","double","float","short"}; 24 25 int n = 0; 26 word[n++] = test[i++]; 27 while ((test[i] >= 鈥?/span>A鈥?/span>&&test[i] <= 鈥?/span>Z鈥?/span>) || (test[i] >= 鈥?/span>0鈥?/span> && test[i] <= 鈥?/span>9鈥?/span>)||(test[i]>=鈥?/span>a鈥?/span>&&test[i]<=鈥?/span>z鈥?/span>)) 28 { 29 word[n++] = test[i++]; 30 } 31 word[n] = 鈥?/span>