{"id":116,"date":"2002-08-15T09:22:00","date_gmt":"2002-08-15T01:22:00","guid":{"rendered":"http:\/\/www.freemindworld.com\/blog\/2002\/08\/0815_pl0%e8%af%ad%e8%a8%80%e7%bc%96%e8%af%91%e7%a8%8b%e5%ba%8f%e5%88%86%e6%9e%90.shtml"},"modified":"2012-01-30T16:58:33","modified_gmt":"2012-01-30T08:58:33","slug":"020815_pl0_analysis","status":"publish","type":"post","link":"https:\/\/www.freemindworld.com\/blog\/2002\/020815_pl0_analysis.shtml","title":{"rendered":"PL\/0\u8bed\u8a00\u7f16\u8bd1\u7a0b\u5e8f\u5206\u6790"},"content":{"rendered":"<p>PL\/0\u8bed\u8a00\u662fPascal\u8bed\u8a00\u7684\u4e00\u4e2a\u5b50\u96c6\uff0c\u6211\u4eec\u8fd9\u91cc\u5206\u6790\u7684PL\/0\u7684\u7f16\u8bd1\u7a0b\u5e8f\u5305\u62ec\u4e86\u5bf9PL\/0\u8bed\u8a00\u6e90\u7a0b\u5e8f\u8fdb\u884c\u5206\u6790\u5904\u7406\u3001\u7f16\u8bd1\u751f\u6210\u7c7bPCODE\u4ee3\u7801\uff0c\u5e76\u5728\u865a\u62df\u673a\u4e0a\u89e3\u91ca\u8fd0\u884c\u751f\u6210\u7684\u7c7bPCODE\u4ee3\u7801\u7684\u529f\u80fd\u3002<\/p>\n<p>PL\/0\u8bed\u8a00\u7f16\u8bd1\u7a0b\u5e8f\u91c7\u7528\u4ee5\u8bed\u6cd5\u5206\u6790\u4e3a\u6838\u5fc3\u3001\u4e00\u904d\u626b\u63cf\u7684\u7f16\u8bd1\u65b9\u6cd5\u3002\u8bcd\u6cd5\u5206\u6790\u548c\u4ee3\u7801\u751f\u6210\u4f5c\u4e3a\u72ec\u7acb\u7684\u5b50\u7a0b\u5e8f\u4f9b\u8bed\u6cd5\u5206\u6790\u7a0b\u5e8f\u8c03\u7528\u3002\u8bed\u6cd5\u5206\u6790\u7684\u540c\u65f6\uff0c\u63d0\u4f9b\u4e86\u51fa\u9519\u62a5\u544a\u548c\u51fa\u9519\u6062\u590d\u7684\u529f\u80fd\u3002\u5728\u6e90\u7a0b\u5e8f\u6ca1\u6709\u9519\u8bef\u7f16\u8bd1\u901a\u8fc7\u7684\u60c5\u51b5\u4e0b\uff0c\u8c03\u7528\u7c7bPCODE\u89e3\u91ca\u7a0b\u5e8f\u89e3\u91ca\u6267\u884c\u751f\u6210\u7684\u7c7bPCODE\u4ee3\u7801\u3002<\/p>\n<p><strong>\u8bcd\u6cd5\u5206\u6790\u5b50\u7a0b\u5e8f\u5206\u6790\uff1a<\/strong><\/p>\n<p>\u8bcd\u6cd5\u5206\u6790\u5b50\u7a0b\u5e8f\u540d\u4e3agetsym\uff0c\u529f\u80fd\u662f\u4ece\u6e90\u7a0b\u5e8f\u4e2d\u8bfb\u51fa\u4e00\u4e2a\u5355\u8bcd\u7b26\u53f7\uff08token\uff09\uff0c\u628a\u5b83\u7684\u4fe1\u606f\u653e\u5165\u5168\u5c40\u53d8\u91cfsym\u3001id\u548cnum\u4e2d\uff0c\u8bed\u6cd5\u5206\u6790\u5668\u9700\u8981\u5355\u8bcd\u65f6\uff0c\u76f4\u63a5\u4ece\u8fd9\u4e09\u4e2a\u53d8\u91cf\u4e2d\u83b7\u5f97\u3002\uff08\u6ce8\u610f\uff01\u8bed\u6cd5\u5206\u6790\u5668\u6bcf\u6b21\u7528\u5b8c\u8fd9\u4e09\u4e2a\u53d8\u91cf\u7684\u503c\u5c31\u7acb\u5373\u8c03\u7528getsym\u5b50\u7a0b\u5e8f\u83b7\u53d6\u65b0\u7684\u5355\u8bcd\u4f9b\u4e0b\u4e00\u6b21\u4f7f\u7528\u3002\u800c\u4e0d\u662f\u5728\u9700\u8981\u65b0\u5355\u8bcd\u65f6\u624d\u8c03\u7528getsym\u8fc7\u7a0b\u3002\uff09getsym\u8fc7\u7a0b\u901a\u8fc7\u53cd\u590d\u8c03\u7528getch\u5b50\u8fc7\u7a0b\u4ece\u6e90\u7a0b\u5e8f\u8fc7\u83b7\u53d6\u5b57\u7b26\uff0c\u5e76\u628a\u5b83\u4eec\u62fc\u6210\u5355\u8bcd\u3002getch\u8fc7\u7a0b\u4e2d\u4f7f\u7528\u4e86\u884c\u7f13\u51b2\u533a\u6280\u672f\u4ee5\u63d0\u9ad8\u7a0b\u5e8f\u8fd0\u884c\u6548\u7387\u3002<\/p>\n<p>\u8bcd\u6cd5\u5206\u6790\u5668\u7684\u5206\u6790\u8fc7\u7a0b\uff1a\u8c03\u7528getsym\u65f6\uff0c\u5b83\u901a\u8fc7getch\u8fc7\u7a0b\u4ece\u6e90\u7a0b\u5e8f\u4e2d\u83b7\u5f97\u4e00\u4e2a\u5b57\u7b26\u3002\u5982\u679c\u8fd9\u4e2a\u5b57\u7b26\u662f\u5b57\u6bcd\uff0c\u5219\u7ee7\u7eed\u83b7\u53d6\u5b57\u7b26\u6216\u6570\u5b57\uff0c\u6700\u7ec8\u53ef\u4ee5\u62fc\u6210\u4e00\u4e2a\u5355\u8bcd\uff0c\u67e5\u4fdd\u7559\u5b57\u8868\uff0c\u5982\u679c\u67e5\u5230\u4e3a\u4fdd\u7559\u5b57\uff0c\u5219\u628asym\u53d8\u91cf\u8d4b\u6210\u76f8\u5e94\u7684\u4fdd\u7559\u5b57\u7c7b\u578b\u503c\uff1b\u5982\u679c\u6ca1\u6709\u67e5\u5230\uff0c\u5219\u8fd9\u4e2a\u5355\u8bcd\u5e94\u662f\u4e00\u4e2a\u7528\u6237\u81ea\u5b9a\u4e49\u7684\u6807\u8bc6\u7b26\uff08\u53ef\u80fd\u662f\u53d8\u91cf\u540d\u3001\u5e38\u91cf\u540d\u6216\u662f\u8fc7\u7a0b\u7684\u540d\u5b57\uff09\uff0c\u628asym\u7f6e\u4e3aident\uff0c\u628a\u8fd9\u4e2a\u5355\u8bcd\u5b58\u5165id\u53d8\u91cf\u3002\u67e5\u4fdd\u7559\u5b57\u8868\u65f6\u4f7f\u7528\u4e86\u4e8c\u5206\u6cd5\u67e5\u627e\u4ee5\u63d0\u9ad8\u6548\u7387\u3002\u5982\u679cgetch\u83b7\u5f97\u7684\u5b57\u7b26\u662f\u6570\u5b57\uff0c\u5219\u7ee7\u7eed\u7528getch\u83b7\u53d6\u6570\u5b57\uff0c\u5e76\u628a\u5b83\u4eec\u62fc\u6210\u4e00\u4e2a\u6574\u6570\uff0c\u7136\u540e\u628asym\u7f6e\u4e3anumber\uff0c\u5e76\u628a\u62fc\u6210\u7684\u6570\u503c\u653e\u5165num\u53d8\u91cf\u3002\u5982\u679c\u8bc6\u522b\u51fa\u5176\u5b83\u5408\u6cd5\u7684\u7b26\u53f7\uff08\u6bd4\u5982\uff1a\u8d4b\u503c\u53f7\u3001\u5927\u4e8e\u53f7\u3001\u5c0f\u4e8e\u7b49\u4e8e\u53f7\u7b49\uff09\uff0c\u5219\u628asym\u5219\u6210\u76f8\u5e94\u7684\u7c7b\u578b\u3002\u5982\u679c\u9047\u5230\u4e0d\u5408\u6cd5\u7684\u5b57\u7b26\uff0c\u628asym\u7f6e\u6210nul\u3002<\/p>\n<p><strong>\u8bed\u6cd5\u5206\u6790\u5b50\u7a0b\u5e8f\u5206\u6790\uff1a<\/strong><\/p>\n<p>\u8bed\u6cd5\u5206\u6790\u5b50\u7a0b\u5e8f\u91c7\u7528\u4e86\u81ea\u9876\u5411\u4e0b\u7684\u9012\u5f52\u5b50\u7a0b\u5e8f\u6cd5\uff0c\u8bed\u6cd5\u5206\u6790\u540c\u65f6\u4e5f\u6839\u636e\u7a0b\u5e8f\u7684\u8bed\u610f\u751f\u6210\u76f8\u5e94\u7684\u4ee3\u7801\uff0c\u5e76\u63d0\u4f9b\u4e86\u51fa\u9519\u5904\u7406\u7684\u673a\u5236\u3002\u8bed\u6cd5\u5206\u6790\u4e3b\u8981\u7531\u5206\u7a0b\u5e8f\u5206\u6790\u8fc7\u7a0b\uff08block\uff09\u3001\u5e38\u91cf\u5b9a\u4e49\u5206\u6790\u8fc7\u7a0b\uff08constdeclaration\uff09\u3001\u53d8\u91cf\u5b9a\u4e49\u5206\u6790\u8fc7\u7a0b\uff08vardeclaration\uff09\u3001\u8bed\u53e5\u5206\u6790\u8fc7\u7a0b\uff08statement\uff09\u3001\u8868\u8fbe\u5f0f\u5904\u7406\u8fc7\u7a0b\uff08expression\uff09\u3001\u9879\u5904\u7406\u8fc7\u7a0b\uff08term\uff09\u3001\u56e0\u5b50\u5904\u7406\u8fc7\u7a0b\uff08factor\uff09\u548c\u6761\u4ef6\u5904\u7406\u8fc7\u7a0b\uff08condition\uff09\u6784\u6210\u3002\u8fd9\u4e9b\u8fc7\u7a0b\u5728\u7ed3\u6784\u4e0a\u6784\u6210\u4e00\u4e2a\u5d4c\u5957\u7684\u5c42\u6b21\u7ed3\u6784\u3002\u9664\u6b64\u4e4b\u5916\uff0c\u8fd8\u6709\u51fa\u9519\u62a5\u544a\u8fc7\u7a0b\uff08error\uff09\u3001\u4ee3\u7801\u751f\u6210\u8fc7\u7a0b\uff08gen\uff09\u3001\u6d4b\u8bd5\u5355\u8bcd\u5408\u6cd5\u6027\u53ca\u51fa\u9519\u6062\u590d\u8fc7\u7a0b\uff08test\uff09\u3001\u767b\u5f55\u540d\u5b57\u8868\u8fc7\u7a0b\uff08enter\uff09\u3001\u67e5\u8be2\u540d\u5b57\u8868\u51fd\u6570\uff08position\uff09\u4ee5\u53ca\u5217\u51fa\u7c7bPCODE\u4ee3\u7801\u8fc7\u7a0b\uff08listcode\uff09\u4f5c\u8fc7\u8bed\u6cd5\u5206\u6790\u7684\u8f85\u52a9\u8fc7\u7a0b\u3002<\/p>\n<p>\u7531PL\/0\u7684\u8bed\u6cd5\u56fe\u53ef\u77e5\uff1a\u4e00\u4e2a\u5b8c\u6574\u7684PL\/0\u7a0b\u5e8f\u662f\u7531\u5206\u7a0b\u5e8f\u548c\u53e5\u53f7\u6784\u6210\u7684\u3002\u56e0\u6b64\uff0c\u672c\u7f16\u8bd1\u7a0b\u5e8f\u5728\u8fd0\u884c\u7684\u65f6\u5019\uff0c\u901a\u8fc7\u4e3b\u7a0b\u5e8f\u4e2d\u8c03\u7528\u5206\u7a0b\u5e8f\u5904\u7406\u8fc7\u7a0bblock\u6765\u5206\u6790\u5206\u7a0b\u5e8f\u90e8\u5206\uff08\u5206\u7a0b\u5e8f\u5206\u6790\u8fc7\u7a0b\u4e2d\u8fd8\u53ef\u80fd\u4f1a\u9012\u5f52\u8c03\u7528block\u8fc7\u7a0b\uff09\uff0c\u7136\u540e\uff0c\u5224\u65ad\u6700\u540e\u8bfb\u5165\u7684\u7b26\u53f7\u662f\u5426\u4e3a\u53e5\u53f7\u3002\u5982\u679c\u662f\u53e5\u53f7\u4e14\u5206\u7a0b\u5e8f\u5206\u6790\u4e2d\u672a\u51fa\u9519\uff0c\u5219\u662f\u4e00\u4e2a\u5408\u6cd5\u7684PL\/0\u7a0b\u5e8f\uff0c\u53ef\u4ee5\u8fd0\u884c\u751f\u6210\u7684\u4ee3\u7801\uff0c\u5426\u5219\u5c31\u8bf4\u660e\u6e90PL\/0\u7a0b\u5e8f\u662f\u4e0d\u5408\u6cd5\u7684\uff0c\u8f93\u51fa\u51fa\u9519\u63d0\u793a\u5373\u53ef\u3002<\/p>\n<p>\u4e0b\u9762\u6309\u5404\u8bed\u6cd5\u5355\u5143\u5206\u6790PL\/0\u7f16\u8bd1\u7a0b\u5e8f\u7684\u8fd0\u884c\u673a\u5236\u3002<\/p>\n<p><strong>\u5206\u7a0b\u5e8f\u5904\u7406\u8fc7\u7a0b\uff1a<\/strong><\/p>\n<p>\u8bed\u6cd5\u5206\u6790\u5f00\u59cb\u540e\uff0c\u9996\u5148\u8c03\u7528\u5206\u7a0b\u5e8f\u5904\u7406\u8fc7\u7a0b\uff08block\uff09\u5904\u7406\u5206\u7a0b\u5e8f\u3002\u8fc7\u7a0b\u5165\u53e3\u53c2\u6570\u7f6e\u4e3a\uff1a0\u5c42\u3001\u7b26\u53f7\u8868\u4f4d\u7f6e0\u3001\u51fa\u9519\u6062\u590d\u5355\u8bcd\u96c6\u5408\u4e3a\u53e5\u53f7\u3001\u58f0\u660e\u7b26\u6216\u8bed\u53e5\u5f00\u59cb\u7b26\u3002\u8fdb\u5165block\u8fc7\u7a0b\u540e\uff0c\u9996\u5148\u628a\u5c40\u90e8\u6570\u636e\u6bb5\u5206\u914d\u6307\u9488\u8bbe\u4e3a3\uff0c\u51c6\u5907\u5206\u914d3\u4e2a\u5355\u5143\u4f9b\u8fd0\u884c\u671f\u5b58\u653e\u9759\u6001\u94feSL\u3001\u52a8\u6001\u94feDL\u548c\u8fd4\u56de\u5730\u5740RA\u3002\u7136\u540e\u7528tx0\u8bb0\u5f55\u4e0b\u5f53\u524d\u7b26\u53f7\u8868\u4f4d\u7f6e\u5e76\u4ea7\u751f\u4e00\u6761jmp\u6307\u4ee4\uff0c\u51c6\u5907\u8df3\u8f6c\u5230\u4e3b\u7a0b\u5e8f\u7684\u5f00\u59cb\u4f4d\u7f6e\uff0c\u7531\u4e8e\u5f53\u524d\u8fd8\u6ca1\u6709\u77e5\u5230\u4e3b\u7a0b\u5e8f\u7a76\u7adf\u5728\u4f55\u5904\u5f00\u59cb\uff0c\u6240\u4ee5jmp\u7684\u76ee\u6807\u6682\u65f6\u586b\u4e3a0\uff0c\u7a0d\u540e\u518d\u6539\u3002\u540c\u65f6\u5728\u7b26\u53f7\u8868\u7684\u5f53\u524d\u4f4d\u7f6e\u8bb0\u5f55\u4e0b\u8fd9\u4e2ajmp\u6307\u4ee4\u5728\u4ee3\u7801\u6bb5\u4e2d\u7684\u4f4d\u7f6e\u3002\u5728\u5224\u65ad\u4e86\u5d4c\u5957\u5c42\u6570\u6ca1\u6709\u8d85\u8fc7\u89c4\u5b9a\u7684\u5c42\u6570\u540e\uff0c\u5f00\u59cb\u5206\u6790\u6e90\u7a0b\u5e8f\u3002\u9996\u5148\u5224\u65ad\u662f\u5426\u9047\u5230\u4e86\u5e38\u91cf\u58f0\u660e\uff0c\u5982\u679c\u9047\u5230\u5219\u5f00\u59cb\u5e38\u91cf\u5b9a\u4e49\uff0c\u628a\u5e38\u91cf\u5b58\u5165\u7b26\u53f7\u8868\u3002\u63a5\u4e0b\u53bb\u7528\u540c\u6837\u7684\u65b9\u6cd5\u5206\u6790\u53d8\u91cf\u58f0\u660e\uff0c\u53d8\u91cf\u5b9a\u4e49\u8fc7\u7a0b\u4e2d\u4f1a\u7528dx\u53d8\u91cf\u8bb0\u5f55\u4e0b\u5c40\u90e8\u6570\u636e\u6bb5\u5206\u914d\u7684\u7a7a\u95f4\u4e2a\u6570\u3002\u7136\u540e\u5982\u679c\u9047\u5230procedure\u4fdd\u7559\u5b57\u5219\u8fdb\u884c\u8fc7\u7a0b\u58f0\u660e\u548c\u5b9a\u4e49\uff0c\u58f0\u660e\u7684\u65b9\u6cd5\u662f\u628a\u8fc7\u7a0b\u7684\u540d\u5b57\u548c\u6240\u5728\u7684\u5c42\u6b21\u8bb0\u5165\u7b26\u53f7\u8868\uff0c\u8fc7\u7a0b\u5b9a\u4e49\u7684\u65b9\u6cd5\u5c31\u662f\u901a\u8fc7\u9012\u5f52\u8c03\u7528block\u8fc7\u7a0b\uff0c\u56e0\u4e3a\u6bcf\u4e2a\u8fc7\u7a0b\u90fd\u662f\u4e00\u4e2a\u5206\u7a0b\u5e8f\u3002\u7531\u4e8e\u8fd9\u662f\u5206\u7a0b\u5e8f\u4e2d\u7684\u5206\u7a0b\u5e8f\uff0c\u56e0\u6b64\u8c03\u7528block\u65f6\u9700\u628a\u5f53\u524d\u7684\u5c42\u6b21\u53f7lev\u52a0\u4e00\u4f20\u9012\u7ed9block\u8fc7\u7a0b\u3002\u5206\u7a0b\u5e8f\u58f0\u660e\u90e8\u5206\u5b8c\u6210\u540e\uff0c\u5373\u5c06\u8fdb\u5165\u8bed\u53e5\u7684\u5904\u7406\uff0c\u8fd9\u65f6\u7684\u4ee3\u7801\u5206\u914d\u6307\u9488cx\u7684\u503c\u6b63\u597d\u6307\u5411\u8bed\u53e5\u7684\u5f00\u59cb\u4f4d\u7f6e\uff0c\u8fd9\u4e2a\u4f4d\u7f6e\u6b63\u662f\u524d\u9762\u7684jmp\u6307\u4ee4\u9700\u8981\u8df3\u8f6c\u5230\u7684\u4f4d\u7f6e\u3002\u4e8e\u662f\u901a\u8fc7\u524d\u9762\u8bb0\u5f55\u4e0b\u6765\u7684\u5730\u5740\u503c\uff0c\u628a\u8fd9\u4e2ajmp\u6307\u4ee4\u7684\u8df3\u8f6c\u4f4d\u7f6e\u6539\u6210\u5f53\u524dcx\u7684\u4f4d\u7f6e\u3002\u5e76\u5728\u7b26\u53f7\u8868\u4e2d\u8bb0\u5f55\u4e0b\u5f53\u524d\u7684\u4ee3\u7801\u6bb5\u5206\u914d\u5730\u5740\u548c\u5c40\u90e8\u6570\u636e\u6bb5\u8981\u5206\u914d\u7684\u5927\u5c0f\uff08dx\u7684\u503c\uff09\u3002\u751f\u6210\u4e00\u6761int\u6307\u4ee4\uff0c\u5206\u914ddx\u4e2a\u7a7a\u95f4\uff0c\u4f5c\u4e3a\u8fd9\u4e2a\u5206\u7a0b\u5e8f\u6bb5\u7684\u7b2c\u4e00\u6761\u6307\u4ee4\u3002\u4e0b\u9762\u5c31\u8c03\u7528\u8bed\u53e5\u5904\u7406\u8fc7\u7a0bstatement\u5206\u6790\u8bed\u53e5\u3002\u5206\u6790\u5b8c\u6210\u540e\uff0c\u751f\u6210\u64cd\u4f5c\u6570\u4e3a0\u7684opr\u6307\u4ee4\uff0c\u7528\u4e8e\u4ece\u5206\u7a0b\u5e8f\u8fd4\u56de\uff08\u5bf9\u4e8e0\u5c42\u7684\u4e3b\u7a0b\u5e8f\u6765\u8bf4\uff0c\u5c31\u662f\u7a0b\u5e8f\u8fd0\u884c\u5b8c\u6210\uff0c\u9000\u51fa\uff09\u3002<\/p>\n<p><strong>\u5e38\u91cf\u5b9a\u4e49\u8fc7\u7a0b\uff1a<\/strong><\/p>\n<p>\u901a\u8fc7\u5faa\u73af\uff0c\u53cd\u590d\u83b7\u5f97\u6807\u8bc6\u7b26\u548c\u5bf9\u5e94\u7684\u503c\uff0c\u5b58\u5165\u7b26\u53f7\u8868\u3002\u7b26\u53f7\u8868\u4e2d\u8bb0\u5f55\u4e0b\u6807\u8bc6\u7b26\u7684\u540d\u5b57\u548c\u5b83\u5bf9\u5e94\u7684\u503c\u3002<\/p>\n<p><strong>\u53d8\u91cf\u5b9a\u4e49\u8fc7\u7a0b\uff1a<\/strong><\/p>\n<p>\u4e0e\u5e38\u91cf\u5b9a\u4e49\u7c7b\u4f3c\uff0c\u901a\u8fc7\u5faa\u73af\uff0c\u53cd\u590d\u83b7\u5f97\u6807\u8bc6\u7b26\uff0c\u5b58\u5165\u7b26\u53f7\u8868\u3002\u7b26\u53f7\u8868\u4e2d\u8bb0\u5f55\u4e0b\u6807\u8bc6\u7b26\u7684\u540d\u5b57\u3001\u5b83\u6240\u5728\u7684\u5c42\u53ca\u5b83\u5728\u6240\u5728\u5c42\u4e2d\u7684\u504f\u79fb\u5730\u5740\u3002<\/p>\n<p><strong>\u8bed\u53e5\u5904\u7406\u8fc7\u7a0b\uff1a<\/strong><\/p>\n<p>\u8bed\u53e5\u5904\u7406\u8fc7\u7a0b\u662f\u4e00\u4e2a\u5d4c\u5957\u5b50\u7a0b\u5e8f\uff0c\u901a\u8fc7\u8c03\u7528\u8868\u8fbe\u5f0f\u5904\u7406\u3001\u9879\u5904\u7406\u3001\u56e0\u5b50\u5904\u7406\u7b49\u8fc7\u7a0b\u53ca\u9012\u5f52\u8c03\u7528\u81ea\u5df1\u6765\u5b9e\u73b0\u5bf9\u8bed\u53e5\u7684\u5206\u6790\u3002\u8bed\u53e5\u5904\u7406\u8fc7\u7a0b\u53ef\u4ee5\u8bc6\u522b\u7684\u8bed\u53e5\u5305\u62ec\u8d4b\u503c\u8bed\u53e5\u3001read\u8bed\u53e5\u3001write\u8bed\u53e5\u3001call\u8bed\u53e5\u3001if\u8bed\u53e5\u3001while\u8bed\u53e5\u3002\u5f53\u9047\u5230begin\/end\u8bed\u53e5\u65f6\uff0c\u5c31\u9012\u5f52\u8c03\u7528\u81ea\u5df1\u6765\u5206\u6790\u3002\u5206\u6790\u7684\u540c\u65f6\u751f\u6210\u76f8\u5e94\u7684\u7c7bPCODE\u6307\u4ee4\u3002<\/p>\n<p><strong>\u8d4b\u503c\u8bed\u53e5\u7684\u5904\u7406\uff1a<\/strong><\/p>\n<p>\u9996\u5148\u83b7\u53d6\u8d4b\u503c\u53f7\u5de6\u8fb9\u7684\u6807\u8bc6\u7b26\uff0c\u4ece\u7b26\u53f7\u8868\u4e2d\u627e\u5230\u5b83\u7684\u4fe1\u606f\uff0c\u5e76\u786e\u8ba4\u8fd9\u4e2a\u6807\u8bc6\u7b26\u786e\u4e3a\u53d8\u91cf\u540d\u3002\u7136\u540e\u901a\u8fc7\u8c03\u7528\u8868\u8fbe\u5f0f\u5904\u7406\u8fc7\u7a0b\u7b97\u5f97\u8d4b\u503c\u53f7\u53f3\u90e8\u7684\u8868\u8fbe\u5f0f\u7684\u503c\u5e76\u751f\u6210\u76f8\u5e94\u7684\u6307\u4ee4\u4fdd\u8bc1\u8fd9\u4e2a\u503c\u653e\u5728\u8fd0\u884c\u671f\u7684\u6570\u636e\u6808\u9876\u3002\u6700\u540e\u901a\u8fc7\u524d\u9762\u67e5\u5230\u7684\u5de6\u90e8\u53d8\u91cf\u7684\u4f4d\u7f6e\u4fe1\u606f\uff0c\u751f\u6210\u76f8\u5e94\u7684sto\u6307\u4ee4\uff0c\u628a\u6808\u9876\u503c\u5b58\u5165\u6307\u5b9a\u7684\u53d8\u91cf\u7684\u7a7a\u95f4\uff0c\u5b9e\u73b0\u4e86\u8d4b\u503c\u64cd\u4f5c\u3002<\/p>\n<p><strong>read\u8bed\u53e5\u7684\u5904\u7406\uff1a<\/strong><\/p>\n<p>\u786e\u5b9aread\u8bed\u53e5\u8bed\u6cd5\u5408\u7406\u7684\u524d\u63d0\u4e0b\uff08\u5426\u5219\u62a5\u9519\uff09\uff0c\u751f\u6210\u76f8\u5e94\u7684\u6307\u4ee4\uff1a\u7b2c\u4e00\u6761\u662f16\u53f7\u64cd\u4f5c\u7684opr\u6307\u4ee4\uff0c\u5b9e\u73b0\u4ece\u6807\u51c6\u8f93\u5165\u8bbe\u5907\u4e0a\u8bfb\u4e00\u4e2a\u6574\u6570\u503c\uff0c\u653e\u5728\u6570\u636e\u6808\u9876\u3002\u7b2c\u4e8c\u6761\u662fsto\u6307\u4ee4\uff0c\u628a\u6808\u9876\u7684\u503c\u5b58\u5165read\u8bed\u53e5\u62ec\u53f7\u4e2d\u7684\u53d8\u91cf\u6240\u5728\u7684\u5355\u5143\u3002<\/p>\n<p><strong>write\u8bed\u53e5\u7684\u5904\u7406\uff1a<\/strong><\/p>\n<p>\u4e0eread\u8bed\u53e5\u76f8\u4f3c\u3002\u5728\u8bed\u6cd5\u6b63\u786e\u7684\u524d\u63d0\u4e0b\uff0c\u751f\u6210\u6307\u4ee4\uff1a\u901a\u8fc7\u5faa\u73af\u8c03\u7528\u8868\u8fbe\u5f0f\u5904\u7406\u8fc7\u7a0b\u5206\u6790write\u8bed\u53e5\u62ec\u53f7\u4e2d\u7684\u6bcf\u4e00\u4e2a\u8868\u8fbe\u5f0f\uff0c\u751f\u6210\u76f8\u5e94\u6307\u4ee4\u4fdd\u8bc1\u628a\u8868\u8fbe\u5f0f\u7684\u503c\u7b97\u51fa\u5e76\u653e\u5230\u6570\u636e\u6808\u9876\u5e76\u751f\u621014\u53f7\u64cd\u4f5c\u7684opr\u6307\u4ee4\uff0c\u8f93\u51fa\u8868\u8fbe\u5f0f\u7684\u503c\u3002\u6700\u540e\u751f\u621015\u53f7\u64cd\u4f5c\u7684opr\u6307\u4ee4\u8f93\u51fa\u4e00\u4e2a\u6362\u884c\u3002<\/p>\n<p><strong>call\u8bed\u53e5\u7684\u5904\u7406\uff1a<\/strong><\/p>\n<p>\u4ece\u7b26\u53f7\u8868\u4e2d\u627e\u5230call\u8bed\u53e5\u53f3\u90e8\u7684\u6807\u8bc6\u7b26\uff0c\u83b7\u5f97\u5176\u6240\u5728\u5c42\u6b21\u548c\u504f\u79fb\u5730\u5740\u3002\u7136\u540e\u751f\u6210\u76f8\u5e94\u7684cal\u6307\u4ee4\u3002\u81f3\u4e8e\u8c03\u7528\u5b50\u8fc7\u7a0b\u6240\u9700\u7684\u4fdd\u62a4\u73b0\u573a\u7b49\u5de5\u4f5c\u662f\u7531\u7c7bPCODE\u89e3\u91ca\u7a0b\u5e8f\u5728\u89e3\u91ca\u6267\u884ccal\u6307\u4ee4\u65f6\u81ea\u52a8\u5b8c\u6210\u7684\u3002<\/p>\n<p><strong>if\u8bed\u53e5\u7684\u5904\u7406\uff1a<\/strong><\/p>\n<p>\u6309if\u8bed\u53e5\u7684\u8bed\u6cd5\uff0c\u9996\u5148\u8c03\u7528\u903b\u8f91\u8868\u8fbe\u5f0f\u5904\u7406\u8fc7\u7a0b\u5904\u7406if\u8bed\u53e5\u7684\u6761\u4ef6\uff0c\u628a\u76f8\u5e94\u7684\u771f\u5047\u503c\u653e\u5230\u6570\u636e\u6808\u9876\u3002\u63a5\u4e0b\u53bb\u8bb0\u5f55\u4e0b\u4ee3\u7801\u6bb5\u5206\u914d\u4f4d\u7f6e\uff08\u5373\u4e0b\u9762\u751f\u6210\u7684jpc\u6307\u4ee4\u7684\u4f4d\u7f6e\uff09\uff0c\u7136\u540e\u751f\u6210\u6761\u4ef6\u8f6c\u79fbjpc\u6307\u4ee4\uff08\u90470\u6216\u9047\u5047\u8f6c\u79fb\uff09\uff0c\u8f6c\u79fb\u5730\u5740\u672a\u77e5\u6682\u65f6\u586b0\u3002\u7136\u540e\u8c03\u7528\u8bed\u53e5\u5904\u7406\u8fc7\u7a0b\u5904\u7406then\u8bed\u53e5\u540e\u9762\u7684\u8bed\u53e5\u6216\u8bed\u53e5\u5757\u3002then\u540e\u7684\u8bed\u53e5\u5904\u7406\u5b8c\u540e\uff0c\u5f53\u524d\u4ee3\u7801\u6bb5\u5206\u914d\u6307\u9488\u7684\u4f4d\u7f6e\u5c31\u5e94\u8be5\u662f\u4e0a\u9762\u7684jpc\u6307\u4ee4\u7684\u8f6c\u79fb\u4f4d\u7f6e\u3002\u901a\u8fc7\u524d\u9762\u8bb0\u5f55\u4e0b\u7684jpc\u6307\u4ee4\u7684\u4f4d\u7f6e\uff0c\u628a\u5b83\u7684\u8df3\u8f6c\u4f4d\u7f6e\u6539\u6210\u5f53\u524d\u7684\u4ee3\u7801\u6bb5\u6307\u9488\u4f4d\u7f6e\u3002<\/p>\n<p><strong>begin\/end\u8bed\u53e5\u7684\u5904\u7406\uff1a<\/strong><\/p>\n<p>\u901a\u8fc7\u5faa\u73af\u904d\u5386begin\/end\u8bed\u53e5\u5757\u4e2d\u7684\u6bcf\u4e00\u4e2a\u8bed\u53e5\uff0c\u901a\u8fc7\u9012\u5f52\u8c03\u7528\u8bed\u53e5\u5206\u6790\u8fc7\u7a0b\u5206\u6790\u5e76\u751f\u6210\u76f8\u5e94\u4ee3\u7801\u3002<\/p>\n<p><strong>while\u8bed\u53e5\u7684\u5904\u7406\uff1a<\/strong><\/p>\n<p>\u9996\u5148\u7528cx1\u53d8\u91cf\u8bb0\u4e0b\u5f53\u524d\u4ee3\u7801\u6bb5\u5206\u914d\u4f4d\u7f6e\uff0c\u4f5c\u4e3a\u5faa\u73af\u7684\u5f00\u59cb\u4f4d\u7f6e\u3002\u7136\u540e\u5904\u7406while\u8bed\u53e5\u4e2d\u7684\u6761\u4ef6\u8868\u8fbe\u5f0f\u751f\u6210\u76f8\u5e94\u4ee3\u7801\u628a\u7ed3\u679c\u653e\u5728\u6570\u636e\u6808\u9876\uff0c\u518d\u7528cx2\u53d8\u91cf\u8bb0\u4e0b\u5f53\u524d\u4f4d\u7f6e\uff0c\u751f\u6210\u6761\u4ef6\u8f6c\u79fb\u6307\u4ee4\uff0c\u8f6c\u79fb\u4f4d\u7f6e\u672a\u77e5\uff0c\u586b0\u3002\u901a\u8fc7\u9012\u5f52\u8c03\u7528\u8bed\u53e5\u5206\u6790\u8fc7\u7a0b\u5206\u6790do\u8bed\u53e5\u540e\u7684\u8bed\u53e5\u6216\u8bed\u53e5\u5757\u5e76\u751f\u6210\u76f8\u5e94\u4ee3\u7801\u3002\u6700\u540e\u751f\u6210\u4e00\u6761\u65e0\u6761\u4ef6\u8df3\u8f6c\u6307\u4ee4jmp\uff0c\u8df3\u8f6c\u5230cx1\u6240\u6307\u4f4d\u7f6e\uff0c\u5e76\u628acx2\u6240\u6307\u7684\u6761\u4ef6\u8df3\u8f6c\u6307\u4ee4\u7684\u8df3\u8f6c\u4f4d\u7f6e\u6539\u6210\u5f53\u524d\u4ee3\u7801\u6bb5\u5206\u914d\u4f4d\u7f6e\u3002<\/p>\n<p><strong>\u8868\u8fbe\u5f0f\u3001\u9879\u3001\u56e0\u5b50\u5904\u7406\uff1a<\/strong><\/p>\n<p>\u6839\u636ePL\/0\u8bed\u6cd5\u53ef\u77e5\uff0c\u8868\u8fbe\u5f0f\u5e94\u8be5\u662f\u7531\u6b63\u8d1f\u53f7\u6216\u65e0\u7b26\u53f7\u5f00\u5934\u3001\u7531\u82e5\u5e72\u4e2a\u9879\u4ee5\u52a0\u51cf\u53f7\u8fde\u63a5\u800c\u6210\u3002\u800c\u9879\u662f\u7531\u82e5\u5e72\u4e2a\u56e0\u5b50\u4ee5\u4e58\u9664\u53f7\u8fde\u63a5\u800c\u6210\uff0c\u56e0\u5b50\u5219\u53ef\u80fd\u662f\u4e00\u4e2a\u6807\u8bc6\u7b26\u6216\u4e00\u4e2a\u6570\u5b57\uff0c\u6216\u662f\u4e00\u4e2a\u4ee5\u62ec\u53f7\u62ec\u8d77\u6765\u7684\u5b50\u8868\u8fbe\u5f0f\u3002\u6839\u636e\u8fd9\u6837\u7684\u7ed3\u6784\uff0c\u6784\u9020\u51fa\u76f8\u5e94\u7684\u8fc7\u7a0b\uff0c\u9012\u5f52\u8c03\u7528\u5c31\u5b8c\u6210\u4e86\u8868\u8fbe\u5f0f\u7684\u5904\u7406\u3002\u628a\u9879\u548c\u56e0\u5b50\u72ec\u7acb\u5f00\u5904\u7406\u89e3\u51b3\u4e86\u52a0\u51cf\u53f7\u4e0e\u4e58\u9664\u53f7\u7684\u4f18\u5148\u7ea7\u95ee\u9898\u3002\u5728\u8fd9\u51e0\u4e2a\u8fc7\u7a0b\u7684\u53cd\u590d\u8c03\u7528\u4e2d\uff0c\u59cb\u7ec8\u4f20\u9012fsys\u53d8\u91cf\u7684\u503c\uff0c\u4fdd\u8bc1\u53ef\u4ee5\u5728\u51fa\u9519\u7684\u60c5\u51b5\u4e0b\u8df3\u8fc7\u51fa\u9519\u7684\u7b26\u53f7\uff0c\u4f7f\u5206\u6790\u8fc7\u7a0b\u5f97\u4ee5\u8fdb\u884c\u4e0b\u53bb\u3002<\/p>\n<p><strong>\u903b\u8f91\u8868\u8fbe\u5f0f\u7684\u5904\u7406\uff1a<\/strong><\/p>\n<p>\u9996\u5148\u5224\u65ad\u662f\u5426\u4e3a\u4e00\u5143\u903b\u8f91\u8868\u8fbe\u5f0f\uff1a\u5224\u5947\u5076\u3002\u5982\u679c\u662f\uff0c\u5219\u901a\u8fc7\u8c03\u7528\u8868\u8fbe\u5f0f\u5904\u7406\u8fc7\u7a0b\u5206\u6790\u8ba1\u7b97\u8868\u8fbe\u5f0f\u7684\u503c\uff0c\u7136\u540e\u751f\u6210\u5224\u5947\u6307\u4ee4\u3002\u5982\u679c\u4e0d\u662f\uff0c\u5219\u80af\u5b9a\u662f\u4e8c\u5143\u903b\u8f91\u8fd0\u7b97\u7b26\uff0c\u901a\u8fc7\u8c03\u7528\u8868\u8fbe\u5f0f\u5904\u7406\u8fc7\u7a0b\u4f9d\u6b21\u5206\u6790\u8fd0\u7b97\u7b26\u5de6\u53f3\u4e24\u90e8\u5206\u7684\u503c\uff0c\u653e\u5728\u6808\u9876\u7684\u4e24\u4e2a\u7a7a\u95f4\u4e2d\uff0c\u7136\u540e\u4f9d\u4e0d\u540c\u7684\u903b\u8f91\u8fd0\u7b97\u7b26\uff0c\u751f\u6210\u76f8\u5e94\u7684\u903b\u8f91\u5224\u65ad\u6307\u4ee4\uff0c\u653e\u5165\u4ee3\u7801\u6bb5\u3002<\/p>\n<p><strong>\u5224\u65ad\u5355\u8bcd\u5408\u6cd5\u6027\u4e0e\u51fa\u9519\u6062\u590d\u8fc7\u7a0b\u5206\u6790\uff1a<\/strong><\/p>\n<p>\u672c\u8fc7\u7a0b\u6709\u4e09\u4e2a\u53c2\u6570\uff0cs1\u3001s2\u4e3a\u4e24\u4e2a\u7b26\u53f7\u96c6\u5408\uff0cn\u4e3a\u51fa\u9519\u4ee3\u7801\u3002\u672c\u8fc7\u7a0b\u7684\u529f\u80fd\u662f\uff1a\u6d4b\u8bd5\u5f53\u524d\u7b26\u53f7\uff08\u5373sym\u53d8\u91cf\u4e2d\u7684\u503c\uff09\u662f\u5426\u5728s1\u96c6\u5408\u4e2d\uff0c\u5982\u679c\u4e0d\u5728\uff0c\u5c31\u901a\u8fc7\u8c03\u7528\u51fa\u9519\u62a5\u544a\u8fc7\u7a0b\u8f93\u51fa\u51fa\u9519\u4ee3\u7801n\uff0c\u5e76\u653e\u5f03\u5f53\u524d\u7b26\u53f7\uff0c\u901a\u8fc7\u8bcd\u6cd5\u5206\u6790\u8fc7\u7a0b\u83b7\u53d6\u4e00\u4e0b\u5355\u8bcd\uff0c\u76f4\u5230\u8fd9\u4e2a\u5355\u8bcd\u51fa\u73b0\u5728s1\u6216s2\u96c6\u5408\u4e2d\u4e3a\u6b62\u3002<\/p>\n<p>\u8fd9\u4e2a\u8fc7\u7a0b\u5728\u5b9e\u9645\u4f7f\u7528\u4e2d\u5f88\u7075\u6d3b\uff0c\u4e3b\u8981\u6709\u4e24\u4e2a\u7528\u6cd5\uff1a<\/p>\n<p>\u5728\u8fdb\u5165\u67d0\u4e2a\u8bed\u6cd5\u5355\u4f4d\u65f6\uff0c\u8c03\u7528\u672c\u8fc7\u7a0b\uff0c\u68c0\u67e5\u5f53\u524d\u7b26\u53f7\u662f\u5426\u5c5e\u4e8e\u8be5\u8bed\u6cd5\u5355\u4f4d\u7684\u5f00\u59cb\u7b26\u53f7\u96c6\u5408\u3002\u82e5\u4e0d\u5c5e\u4e8e\uff0c\u5219\u6ee4\u53bb\u5f00\u59cb\u7b26\u53f7\u548c\u540e\u7ee7\u7b26\u53f7\u96c6\u5408\u5916\u7684\u6240\u6709\u7b26\u53f7\u3002<\/p>\n<p>\u5728\u8bed\u6cd5\u5355\u4f4d\u5206\u6790\u7ed3\u675f\u65f6\uff0c\u8c03\u7528\u672c\u8fc7\u7a0b\uff0c\u68c0\u67e5\u5f53\u524d\u7b26\u53f7\u662f\u5426\u5c5e\u4e8e\u8c03\u7528\u8be5\u8bed\u6cd5\u5355\u4f4d\u65f6\u5e94\u6709\u7684\u540e\u7ee7\u7b26\u53f7\u96c6\u5408\u3002\u82e5\u4e0d\u5c5e\u4e8e\uff0c\u5219\u6ee4\u53bb\u540e\u7ee7\u7b26\u53f7\u548c\u5f00\u59cb\u7b26\u53f7\u96c6\u5408\u5916\u7684\u6240\u6709\u7b26\u53f7\u3002<\/p>\n<p>\u901a\u8fc7\u8fd9\u6837\u7684\u673a\u5236\uff0c\u53ef\u4ee5\u5728\u6e90\u7a0b\u5e8f\u51fa\u73b0\u9519\u8bef\u65f6\uff0c\u53ca\u65f6\u8df3\u8fc7\u51fa\u9519\u7684\u90e8\u5206\uff0c\u4fdd\u8bc1\u8bed\u6cd5\u5206\u6790\u53ef\u4ee5\u7ee7\u7eed\u4e0b\u53bb\u3002<\/p>\n<p>\u8bed\u6cd5\u5206\u6790\u8fc7\u7a0b\u4e2d\u8c03\u7528\u7684\u5176\u5b83\u5b50\u8fc7\u7a0b\u76f8\u5bf9\u6bd4\u8f83\u7b80\u5355\uff0c\u8bf7\u53c2\u8003\u6e90\u7a0b\u5e8f\u7684\u6ce8\u91ca\u3002<\/p>\n<p><strong>\u7c7bPCODE\u4ee3\u7801\u89e3\u91ca\u6267\u884c\u8fc7\u7a0b\u5206\u6790<\/strong><\/p>\n<p>\u8fd9\u4e2a\u8fc7\u7a0b\u6a21\u62df\u4e86\u4e00\u53f0\u53ef\u4ee5\u8fd0\u884c\u7c7bPCODE\u6307\u4ee4\u7684\u6808\u5f0f\u8ba1\u7b97\u673a\u3002\u5b83\u62e5\u6709\u4e00\u4e2a\u6808\u5f0f\u6570\u636e\u6bb5\u7528\u4e8e\u5b58\u653e\u8fd0\u884c\u671f\u6570\u636e\u3001\u62e5\u6709\u4e00\u4e2a\u4ee3\u7801\u6bb5\u7528\u4e8e\u5b58\u653e\u7c7bPCODE\u7a0b\u5e8f\u4ee3\u7801\u3002\u540c\u65f6\u8fd8\u62e5\u7528\u6570\u636e\u6bb5\u5206\u914d\u6307\u9488\u3001\u6307\u4ee4\u6307\u9488\u3001\u6307\u4ee4\u5bc4\u5b58\u5668\u3001\u5c40\u90e8\u6bb5\u57fa\u5740\u6307\u9488\u7b49\u5bc4\u5b58\u5668\u3002<\/p>\n<p>\u89e3\u91ca\u6267\u884c\u7c7bPCODE\u4ee3\u7801\u65f6\uff0c\u6570\u636e\u6bb5\u5b58\u50a8\u5206\u914d\u65b9\u5f0f\u5982\u4e0b\uff1a<\/p>\n<p>\u5bf9\u4e8e\u6e90\u7a0b\u5e8f\u7684\u6bcf\u4e00\u4e2a\u8fc7\u7a0b\uff08\u5305\u62ec\u4e3b\u7a0b\u5e8f\uff09\uff0c\u5728\u88ab\u8c03\u7528\u65f6\uff0c\u9996\u5148\u5728\u6570\u636e\u6bb5\u4e2d\u5f00\u8f9f\u4e09\u4e2a\u7a7a\u95f4\uff0c\u5b58\u653e\u9759\u6001\u94feSL\u3001\u52a8\u6001\u94feDL\u548c\u8fd4\u56de\u5730\u5740RA\u3002\u9759\u6001\u94fe\u8bb0\u5f55\u4e86\u5b9a\u4e49\u8be5\u8fc7\u7a0b\u7684\u76f4\u63a5\u5916\u8fc7\u7a0b\uff08\u6216\u4e3b\u7a0b\u5e8f\uff09\u8fd0\u884c\u65f6\u6700\u65b0\u6570\u636e\u6bb5\u7684\u57fa\u5730\u5740\u3002\u52a8\u6001\u94fe\u8bb0\u5f55\u8c03\u7528\u8be5\u8fc7\u7a0b\u524d\u6b63\u5728\u8fd0\u884c\u7684\u8fc7\u7a0b\u7684\u6570\u636e\u6bb5\u57fa\u5740\u3002\u8fd4\u56de\u5730\u5740\u8bb0\u5f55\u4e86\u8c03\u7528\u8be5\u8fc7\u7a0b\u65f6\u7a0b\u5e8f\u8fd0\u884c\u7684\u65ad\u70b9\u4f4d\u7f6e\u3002\u5bf9\u4e8e\u4e3b\u7a0b\u5e8f\u6765\u8bf4\uff0cSL\u3001DL\u548cRA\u7684\u503c\u5747\u7f6e\u4e3a0\u3002\u9759\u6001\u94fe\u7684\u529f\u80fd\u662f\u5728\u4e00\u4e2a\u5b50\u8fc7\u7a0b\u8981\u5f15\u7528\u5b83\u7684\u76f4\u63a5\u6216\u95f4\u63a5\u7236\u8fc7\u7a0b\uff08\u8fd9\u91cc\u7684\u7236\u8fc7\u7a0b\u662f\u6309\u5b9a\u4e49\u8fc7\u7a0b\u65f6\u7684\u5d4c\u5957\u60c5\u51b5\u6765\u5b9a\u7684\uff0c\u800c\u4e0d\u662f\u6309\u6267\u884c\u65f6\u7684\u8c03\u7528\u987a\u5e8f\u5b9a\u7684\uff09\u7684\u53d8\u91cf\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7\u9759\u6001\u94fe\uff0c\u8df3\u8fc7\u4e2a\u6570\u4e3a\u5c42\u5dee\u7684\u6570\u636e\u6bb5\uff0c\u627e\u5230\u5305\u542b\u8981\u5f15\u7528\u7684\u53d8\u91cf\u6240\u5728\u7684\u6570\u636e\u6bb5\u57fa\u5740\uff0c\u7136\u540e\u901a\u8fc7\u504f\u79fb\u5730\u5740\u8bbf\u95ee\u5b83\u3002<\/p>\n<p>\u5728\u8fc7\u7a0b\u8fd4\u56de\u65f6\uff0c\u89e3\u91ca\u7a0b\u5e8f\u901a\u8fc7\u8fd4\u56de\u5730\u5740\u6062\u590d\u6307\u4ee4\u6307\u9488\u7684\u503c\u5230\u8c03\u7528\u524d\u7684\u5730\u5740\uff0c\u901a\u8fc7\u5f53\u524d\u6bb5\u57fa\u5740\u6062\u590d\u6570\u636e\u6bb5\u5206\u914d\u6307\u9488\uff0c\u901a\u8fc7\u52a8\u6001\u94fe\u6062\u590d\u5c40\u90e8\u6bb5\u57fa\u5740\u6307\u9488\u3002\u5b9e\u73b0\u5b50\u8fc7\u7a0b\u7684\u8fd4\u56de\u3002\u5bf9\u4e8e\u4e3b\u7a0b\u5e8f\u6765\u8bf4\uff0c\u89e3\u91ca\u7a0b\u5e8f\u4f1a\u9047\u5230\u8fd4\u56de\u5730\u5740\u4e3a0\u7684\u60c5\u51b5\uff0c\u8fd9\u65f6\u5c31\u8ba4\u4e3a\u7a0b\u5e8f\u8fd0\u884c\u7ed3\u675f\u3002<\/p>\n<p>\u89e3\u91ca\u7a0b\u5e8f\u8fc7\u7a0b\u4e2d\u7684base\u51fd\u6570\u7684\u529f\u80fd\uff0c\u5c31\u662f\u7528\u4e8e\u6cbf\u7740\u9759\u6001\u94fe\uff0c\u5411\u524d\u67e5\u627e\u76f8\u5dee\u6307\u5b9a\u5c42\u6570\u7684\u5c40\u90e8\u6570\u636e\u6bb5\u57fa\u5740\u3002\u8fd9\u5728\u4f7f\u7528sto\u3001lod\u7b49\u8bbf\u95ee\u5c40\u90e8\u53d8\u91cf\u7684\u6307\u4ee4\u4e2d\u4f1a\u7ecf\u5e38\u7528\u5230\u3002<\/p>\n<p>\u7c7bPCODE\u4ee3\u7801\u89e3\u91ca\u6267\u884c\u7684\u90e8\u5206\u901a\u8fc7\u5faa\u73af\u548c\u7b80\u5355\u7684case\u5224\u65ad\u4e0d\u540c\u7684\u6307\u4ee4\uff0c\u505a\u51fa\u76f8\u5e94\u7684\u52a8\u4f5c\u3002\u5f53\u9047\u5230\u4e3b\u7a0b\u5e8f\u4e2d\u7684\u8fd4\u56de\u6307\u4ee4\u65f6\uff0c\u6307\u4ee4\u6307\u9488\u4f1a\u6307\u52300\u4f4d\u7f6e\uff0c\u628a\u8fd9\u6837\u4e00\u4e2a\u6761\u4ef6\u4f5c\u4e3a\u7ec8\u81f3\u5faa\u73af\u7684\u6761\u4ef6\uff0c\u4fdd\u8bc1\u7a0b\u5e8f\u8fd0\u884c\u53ef\u4ee5\u6b63\u5e38\u7684\u7ed3\u675f\u3002<\/p>\n<p>\u4ee5\u4e0b\u6e90\u7a0b\u5e8f\u662f\u4ee5\u6e05\u534e\u5927\u5b66\u51fa\u7248\u793e\u300a\u7f16\u8bd1\u539f\u7406\u300b\u4e2d\u7684\u6e90\u4ee3\u7801\u4e3a\u57fa\u7840\u4f5c\u4e86\u5c11\u91cf\u6539\u52a8\u800c\u6210\u3002<\/p>\n<p>\u7a0b\u5e8f\u5728Turbo Pascal 7.0\u4e0a\u7f16\u8bd1\u8fd0\u884c\u901a\u8fc7\u3002<\/p>\n<pre>\r\n************************************************************************************\r\nprogram pl0(fa,fa1,fa2); (* PL\/0\u7f16\u8bd1\u7a0b\u5e8f\u4e0e\u4ee3\u7801\u751f\u6210\u89e3\u91ca\u8fd0\u884c\u7a0b\u5e8f *)\r\n(* PL\/0 compiler with code generation *)\r\nlabel 99; (* \u58f0\u660e\u51fa\u9519\u8df3\u8f6c\u6807\u8bb0 *)\r\n(* \u5728Turbo Pascal 7.0\u4e2d\u5df2\u4e0d\u5141\u8bb8\u8de8\u8fc7\u7a0b\u7684GOTO\u8f6c\u79fb\uff0c\u56e0\u6b64\u540e\u9762\u7684GOTO\u8bed\u53e5\u5747\u88ab\u6211\u53bb\u9664\u4e86\uff0c\u56e0\u6b64\u8fd9\u91cc\u7684label\u4e5f\u6ca1\u6709\u610f\u4e49\u4e86 *)\r\nconst (* \u5e38\u91cf\u5b9a\u4e49 *)\r\n  norw = 13;     (* of reserved words *) (* \u4fdd\u7559\u5b57\u7684\u4e2a\u6570 *)\r\n  txmax = 100;   (* length of identifier table *) (* \u6807\u8bc6\u7b26\u8868\u7684\u957f\u5ea6\uff08\u5bb9\u91cf\uff09 *)\r\n  nmax = 14;     (* max number of digits in numbers *) (* \u6570\u5b57\u5141\u8bb8\u7684\u6700\u957f\u4f4d\u6570 *)\r\n  al = 10;       (* length of identifiers *) (* \u6807\u8bc6\u7b26\u6700\u957f\u957f\u5ea6 *)\r\n  amax = 2047;   (* maximum address *) (* \u5bfb\u5740\u7a7a\u95f4 *)\r\n  levmax = 3;    (* max depth of block nesting *) (* \u6700\u5927\u5141\u8bb8\u7684\u5757\u5d4c\u5957\u5c42\u6570 *)\r\n  cxmax = 200;   (* size of code array *) (* \u7c7bPCODE\u76ee\u6807\u4ee3\u7801\u6570\u7ec4\u957f\u5ea6\uff08\u53ef\u5bb9\u7eb3\u4ee3\u7801\u884c\u6570\uff09 *)\r\ntype (* \u7c7b\u578b\u5b9a\u4e49 *)\r\n  symbol = (nul, ident, number, plus, minus, times, slash, oddsym,\r\n            eql, neq, lss, leq, gtr, geq, lparen, rparen, comma,\r\n            semicolon, period, becomes, beginsym, endsym, ifsym,\r\n            thensym, whilesym, writesym, readsym, dosym, callsym,\r\n            constsym, varsym, procsym); (* symobl\u7c7b\u578b\u6807\u8bc6\u4e86\u4e0d\u540c\u7c7b\u578b\u7684\u8bcd\u6c47 *)\r\n  alfa = packed array[1..al] of char; (* alfa\u7c7b\u578b\u7528\u4e8e\u6807\u8bc6\u7b26 *)\r\n  object1 = (constant, variable, procedur); (* object1\u4e3a\u4e09\u79cd\u6807\u8bc6\u7b26\u7684\u7c7b\u578b *)\r\n  (* \u539f\u7a0b\u5e8f\u5728\u6b64\u4f7f\u7528object\u4f5c\u4e3a\u7c7b\u578b\u540d\u79f0\uff0c\u5728\u652f\u6301\u9762\u5411\u5bf9\u8c61\u7684Turbo Pascal 7.0\u4e2d\u7f16\u8bd1\u4e0d\u80fd\u901a\u8fc7 *)\r\n  (* wirth used the word &quot;procedure&quot; there, whick won't work! *)\r\n  (* \u4e0a\u9762\u4e00\u884c\u662f\u8bfe\u672c\u4e0a\u7684\u7a0b\u5e8f\u6e05\u5355\u4e2d\u7684\u6ce8\u91ca\uff0c\u8bf4\u672c\u7a0b\u5e8f\u7684\u539f\u4f5c\u8005Wirth\u5728\u8fd9\u91cc\u7528\u4e86procedure\u8fd9\u4e2a\u8bcd\u4f5c\u4e3a\u6807\u8bc6\u7b26\u7c7b\u578b\uff0c\u662f\u4e0d\u53ef\u4ee5\u7684\u3002\r\n     \u4e8b\u5b9e\u4e0aWirth\u539f\u672c\u5728\u8fd9\u91cc\u7528\u7684\u8bcd\u662fprozedure\uff0c\u662f\u53ef\u4ee5\u7684\u3002 *)\r\n  symset = set of symbol; (* symset\u662fsymbol\u7c7b\u578b\u7684\u4e00\u4e2a\u96c6\u5408\u7c7b\u578b\uff0c\u53ef\u7528\u4e8e\u5b58\u653e\u4e00\u7ec4symbol *)\r\n  fct = (lit, opr, lod, sto, cal, int, jmp, jpc); (* fct\u7c7b\u578b\u5206\u522b\u6807\u8bc6\u7c7bPCODE\u7684\u5404\u6761\u6307\u4ee4 *)\r\n  instruction = packed record\r\n    f: fct;       (* function code *)\r\n    l: 0..levmax; (* level *)\r\n    a: 0..amax;   (* displacement addr *)\r\n  end; (* \u7c7bPCODE\u6307\u4ee4\u7c7b\u578b\uff0c\u5305\u542b\u4e09\u4e2a\u5b57\u6bb5\uff1a\u6307\u4ee4f\u3001\u5c42\u5deel\u548c\u53e6\u4e00\u4e2a\u64cd\u4f5c\u6570a *)\r\n  (* \r\n     lit 0, a  load constant a\r\n     opr 0, a  execute opr a\r\n     lod l, a  load variable l, a\r\n     sto l, a  store variable l, a\r\n     cal l, a  call procedure a at level l\r\n     int 0, a  increment t-register by a\r\n     jmp 0, a  jump to a\r\n     jpc 0, a  jump conditional to a \r\n  *)\r\nvar (* \u5168\u5c40\u53d8\u91cf\u5b9a\u4e49 *)\r\n  fa: text; (* \u6587\u672c\u6587\u4ef6fa\u7528\u4e8e\u5217\u51fa\u6e90\u7a0b\u5e8f *)\r\n  fa1, fa2: text; (* \u6587\u672c\u6587\u4ef6fa1\u7528\u4e8e\u5217\u51fa\u7c7bPCODE\u4ee3\u7801\u3001fa2\u7528\u4e8e\u8bb0\u5f55\u89e3\u91ca\u6267\u884c\u7c7bPCODE\u4ee3\u7801\u7684\u8fc7\u7a0b *)\r\n  listswitch: boolean; (* true set list object code *) (* \u5982\u679c\u672c\u53d8\u91cf\u7f6etrue\uff0c\u7a0b\u5e8f\u7f16\u8bd1\u540e\u5c06\u4e3a\u5217\u51fa\u7c7bPCODE\u4ee3\u7801\uff0c\r\n                                                          \u5426\u5219\u4e0d\u5217\u51fa\u7c7bPCODE\u4ee3\u7801 *)\r\n  ch: char; (* last char read *) (* \u4e3b\u8981\u7528\u4e8e\u8bcd\u6cd5\u5206\u6790\u5668\uff0c\u5b58\u653e\u6700\u8fd1\u4e00\u6b21\u4ece\u6587\u4ef6\u4e2d\u8bfb\u51fa\u7684\u5b57\u7b26 *)\r\n  sym: symbol; (* last symbol read *) (* \u8bcd\u6cd5\u5206\u6790\u5668\u8f93\u51fa\u7ed3\u679c\u4e4b\u7528\uff0c\u5b58\u653e\u6700\u8fd1\u4e00\u6b21\u8bc6\u522b\u51fa\u6765\u7684token\u7684\u7c7b\u578b *)\r\n  id: alfa;  (* last identifier read *) (* \u8bcd\u6cd5\u5206\u6790\u5668\u8f93\u51fa\u7ed3\u679c\u4e4b\u7528\uff0c\u5b58\u653e\u6700\u8fd1\u4e00\u6b21\u8bc6\u522b\u51fa\u6765\u7684\u6807\u8bc6\u7b26\u7684\u540d\u5b57 *)\r\n  num: integer; (* last number read *) (* \u8bcd\u6cd5\u5206\u6790\u5668\u8f93\u51fa\u7ed3\u679c\u4e4b\u7528\uff0c\u5b58\u653e\u6700\u8fd1\u4e00\u6b21\u8bc6\u522b\u51fa\u6765\u7684\u6570\u5b57\u7684\u503c *)\r\n  cc: integer;  (* character count *) (* \u884c\u7f13\u51b2\u533a\u6307\u9488 *) \r\n  ll: integer;  (* line length *) (* \u884c\u7f13\u51b2\u533a\u957f\u5ea6 *)\r\n  kk: integer;  (* \u5f15\u5165\u6b64\u53d8\u91cf\u662f\u51fa\u4e8e\u7a0b\u5e8f\u6027\u80fd\u8003\u8651\uff0c\u89c1getsym\u8fc7\u7a0b\u6ce8\u91ca *)\r\n  cx: integer;  (* code allocation index *) (* \u4ee3\u7801\u5206\u914d\u6307\u9488\uff0c\u4ee3\u7801\u751f\u6210\u6a21\u5757\u603b\u5728cx\u6240\u6307\u4f4d\u7f6e\u751f\u6210\u65b0\u7684\u4ee3\u7801 *)\r\n  line: array[1..81] of char; (* \u884c\u7f13\u51b2\u533a\uff0c\u7528\u4e8e\u4ece\u6587\u4ef6\u8bfb\u51fa\u4e00\u884c\uff0c\u4f9b\u8bcd\u6cd5\u5206\u6790\u83b7\u53d6\u5355\u8bcd\u65f6\u4e4b\u7528 *)\r\n  a: alfa; (* \u8bcd\u6cd5\u5206\u6790\u5668\u4e2d\u7528\u4e8e\u4e34\u65f6\u5b58\u653e\u6b63\u5728\u5206\u6790\u7684\u8bcd *)\r\n  code: array[0..cxmax] of instruction; (* \u751f\u6210\u7684\u7c7bPCODE\u4ee3\u7801\u8868\uff0c\u5b58\u653e\u7f16\u8bd1\u5f97\u5230\u7684\u7c7bPCODE\u4ee3\u7801 *)\r\n  word: array[1..norw] of alfa; (* \u4fdd\u7559\u5b57\u8868 *)\r\n  wsym: array[1..norw] of symbol; (* \u4fdd\u7559\u5b57\u8868\u4e2d\u6bcf\u4e00\u4e2a\u4fdd\u7559\u5b57\u5bf9\u5e94\u7684symbol\u7c7b\u578b *)\r\n  ssym: array[' '..'^'] of symbol; (* \u4e00\u4e9b\u7b26\u53f7\u5bf9\u5e94\u7684symbol\u7c7b\u578b\u8868 *)\r\n    (* wirth uses &quot;array[char]&quot; here *)\r\n  mnemonic: array[fct] of packed array[1..5] of char;(* \u7c7bPCODE\u6307\u4ee4\u52a9\u8bb0\u7b26\u8868 *)\r\n  declbegsys, statbegsys, facbegsys: symset; (* \u58f0\u660e\u5f00\u59cb\u3001\u8868\u8fbe\u5f0f\u5f00\u59cb\u548c\u9879\u5f00\u59cb\u7b26\u53f7\u96c6\u5408 *)\r\n  table: array[0..txmax] of record (* \u7b26\u53f7\u8868 *)\r\n    name: alfa; (* \u7b26\u53f7\u7684\u540d\u5b57 *)\r\n    case kind: object1 of (* \u7b26\u53f7\u7684\u7c7b\u578b *)\r\n      constant: (* \u5982\u679c\u662f\u5e38\u91cf\u540d *)\r\n        (val: integer); (* val\u4e2d\u653e\u5e38\u91cf\u7684\u503c *)\r\n      variable, procedur:  (* \u5982\u679c\u662f\u53d8\u91cf\u540d\u6216\u8fc7\u7a0b\u540d *)\r\n        (level, adr, size: integer) (* \u5b58\u653e\u5c42\u5dee\u3001\u504f\u79fb\u5730\u5740\u548c\u5927\u5c0f *)\r\n        (* &quot;size&quot; lacking in orginal. I think it belons here *)\r\n  end;\r\n  fin, fout: text; (* fin\u6587\u672c\u6587\u4ef6\u7528\u4e8e\u6307\u5411\u8f93\u5165\u7684\u6e90\u7a0b\u5e8f\u6587\u4ef6\uff0cfout\u7a0b\u5e8f\u4e2d\u6ca1\u6709\u7528\u5230 *)\r\n  fname: string; (* \u5b58\u653ePL\/0\u6e90\u7a0b\u5e8f\u6587\u4ef6\u7684\u6587\u4ef6\u540d *)\r\n  (* \u6211\u4fee\u6539\u7684\u4ee3\u7801\uff1a\u539f\u7a0b\u5e8f\u5728\u6b64\u5904\u4f7f\u7528alfa\u7c7b\u578b\uff0c\u65e0\u6cd5\u5728Turbo Pascal 7.0\u4e2d\u901a\u8fc7\uff0creadln\u51fd\u6570\u7684\u53c2\u6570\u4e0d\u80fd\u4e3aalfa\u578b *)\r\n  err: integer; (* \u51fa\u9519\u603b\u6b21\u6570 *)\r\n(* \u51fa\u9519\u5904\u7406\u8fc7\u7a0berror *)\r\n(* \u53c2\u6570\uff1an:\u51fa\u9519\u4ee3\u7801 *)\r\nprocedure error(n: integer);\r\nbegin\r\n  writeln('****', ' ': cc-1, '!', n:2); (* \u5728\u5c4f\u5e55cc-1\u4f4d\u7f6e\u663e\u793a!\u4e0e\u51fa\u9519\u4ee3\u7801\u63d0\u793a\uff0c\u7531\u4e8ecc\r\n                                           \u662f\u884c\u7f13\u51b2\u533a\u6307\u9488\uff0c\u6240\u4ee5!\u6240\u6307\u4f4d\u7f6e\u5373\u4e3a\u51fa\u9519\u4f4d\u7f6e *)\r\n  writeln(fa1, '****', ' ': cc-1, '!', n:2); (* \u5728\u6587\u4ef6cc-1\u4f4d\u7f6e\u8f93\u51fa!\u4e0e\u51fa\u9519\u4ee3\u7801\u63d0\u793a *)\r\n  err := err + 1 (* \u51fa\u9519\u603b\u6b21\u6570\u52a0\u4e00 *)\r\nend (* error *);\r\n(* \u8bcd\u6cd5\u5206\u6790\u8fc7\u7a0bgetsym *)\r\nprocedure getsym;\r\nvar \r\n  i, j, k: integer;\r\n  (* \u8bfb\u53d6\u539f\u7a0b\u5e8f\u4e2d\u4e0b\u4e00\u4e2a\u5b57\u7b26\u8fc7\u7a0bgetch *)\r\n  procedure getch;\r\n  begin\r\n    if cc = ll then (* \u5982\u679c\u884c\u7f13\u51b2\u533a\u6307\u9488\u6307\u5411\u884c\u7f13\u51b2\u533a\u6700\u540e\u4e00\u4e2a\u5b57\u7b26\u5c31\u4ece\u6587\u4ef6\u8bfb\u4e00\u884c\u5230\u884c\u7f13\u51b2\u533a *)\r\n    begin\r\n      if eof(fin) then (* \u5982\u679c\u5230\u8fbe\u6587\u4ef6\u672b\u5c3e *)\r\n      begin\r\n        write('Program incomplete'); (* \u51fa\u9519\uff0c\u9000\u51fa\u7a0b\u5e8f *)\r\n        close(fa);\r\n        close(fa1);\r\n        close(fin);\r\n        halt(0);        \r\n        {goto 99}\r\n        (* \u6211\u4fee\u6539\u7684\u4ee3\u7801\uff0c\u7531\u4e8eTurbo Pascal 7.0\u4e2d\u4e0d\u5141\u8bb8\u8de8\u8fc7\u7a0b\u7684goto\uff0c\u5c31\u53ea\u80fd\u7528\u4e0a\u9762\u7684\u65b9\u6cd5\u9000\u51fa\u7a0b\u5e8f\u4e86\u3002 *)\r\n      end;\r\n      ll := 0; (* \u884c\u7f13\u51b2\u533a\u957f\u5ea6\u7f6e0 *)\r\n      cc := 0; (* \u884c\u7f13\u51b2\u533a\u6307\u9488\u7f6e\u884c\u9996 *)\r\n      write(cx: 4, ' '); (* \u8f93\u51facx\u503c\uff0c\u5bbd\u5ea6\u4e3a4 *)\r\n      write(fa1, cx: 4, ' '); (* \u8f93\u51facx\u503c\uff0c\u5bbd\u5ea6\u4e3a4\u5230\u6587\u4ef6 *)\r\n      while not eoln(fin) do (* \u5f53\u672a\u5230\u884c\u672b\u65f6 *)\r\n      begin\r\n        ll := ll + 1; (* \u884c\u7f13\u51b2\u533a\u957f\u5ea6\u52a0\u4e00 *)\r\n        read(fin, ch); (* \u4ece\u6587\u4ef6\u8bfb\u5165\u4e00\u4e2a\u5b57\u7b26\u5230 ch *)\r\n        write(ch); (* \u5728\u5c4f\u5e55\u8f93\u51fach *)\r\n        write(fa1, ch); (* \u628ach\u8f93\u51fa\u5230\u6587\u4ef6 *)\r\n        line[ll] := ch; (* \u628a\u8bfb\u5230\u7684\u5b57\u7b26\u5b58\u5165\u884c\u7f13\u51b2\u533a\u76f8\u5e94\u7684\u4f4d\u7f6e *)\r\n      end;\r\n      (* \u53ef\u89c1\uff0cPL\/0\u6e90\u7a0b\u5e8f\u8981\u6c42\u6bcf\u884c\u7684\u957f\u5ea6\u90fd\u5c0f\u4e8e81\u4e2a\u5b57\u7b26 *)\r\n      writeln; \r\n      ll := ll + 1; (* \u884c\u7f13\u51b2\u533a\u957f\u5ea6\u52a0\u4e00\uff0c\u7528\u4e8e\u5bb9\u7eb3\u5373\u5c06\u8bfb\u5165\u7684\u56de\u8f66\u7b26CR *)\r\n      read(fin, line[ll]);(* \u628a#13(CR)\u8bfb\u5165\u884c\u7f13\u51b2\u533a\u5c3e\u90e8 *)\r\n      read(fin, ch); (* \u6211\u6dfb\u52a0\u7684\u4ee3\u7801\u3002\u7531\u4e8ePC\u4e0a\u6587\u672c\u6587\u4ef6\u6362\u884c\u662f\u4ee5#13#10(CR+LF)\u8868\u793a\u7684\uff0c\r\n                        \u6240\u4ee5\u8981\u628a\u591a\u4f59\u7684LF\u4ece\u6587\u4ef6\u8bfb\u51fa\uff0c\u8fd9\u91cc\u653e\u5728ch\u53d8\u91cf\u4e2d\u662f\u7531\u4e8ech\u53d8\u91cf\u7684\r\n                        \u503c\u5728\u4e0b\u9762\u5373\u5c06\u88ab\u6539\u53d8\uff0c\u628a\u8fd9\u4e2a\u591a\u4f59\u503c\u653e\u5728ch\u4e2d\u6ca1\u6709\u95ee\u9898 *)\r\n      writeln(fa1); \r\n    end;\r\n    cc := cc + 1; (* \u884c\u7f13\u51b2\u533a\u6307\u9488\u52a0\u4e00\uff0c\u6307\u5411\u5373\u5c06\u8bfb\u5230\u7684\u5b57\u7b26 *)\r\n    ch := line[cc] (* \u8bfb\u51fa\u5b57\u7b26\uff0c\u653e\u5165\u5168\u5c40\u53d8\u91cfch *)\r\n  end (* getch *); \r\nbegin (* getsym *)\r\n  while (ch = ' ') or (ch = #13) do (* \u6211\u4fee\u6539\u7684\u4ee3\u7801\uff1a\u8fd9\u53e5\u539f\u6765\u662f\u7528\u4e8e\u8bfb\u4e00\u4e2a\u6709\u6548\u7684\u5b57\u7b26\r\n                                       (\u8df3\u8fc7\u8bfb\u51fa\u7684\u5b57\u7b26\u4e2d\u591a\u4f59\u7684\u7a7a\u683c)\uff0c\u4f46\u5b9e\u9645\u4e0a\u8fd8\u8981\u8df3\r\n                                       \u8fc7\u591a\u4f59\u7684\u56de\u8f66 *)\r\n    getch; \r\n  if ch in ['a'..'z'] then (* \u5982\u679c\u8bfb\u51fa\u7684\u5b57\u7b26\u662f\u4e00\u4e2a\u5b57\u6bcd\uff0c\u8bf4\u660e\u662f\u4fdd\u7559\u5b57\u6216\u6807\u8bc6\u7b26 *)\r\n  begin\r\n    k := 0; (* \u6807\u8bc6\u7b26\u7f13\u51b2\u533a\u6307\u9488\u7f6e0 *)\r\n    repeat (* \u8fd9\u4e2a\u5faa\u73af\u7528\u4e8e\u4f9d\u6b21\u8bfb\u51fa\u6e90\u6587\u4ef6\u4e2d\u7684\u5b57\u7b26\u6784\u6210\u6807\u8bc6\u7b26 *)\r\n      if k &lt; al then (* \u5982\u679c\u6807\u8bc6\u7b26\u957f\u5ea6\u6ca1\u6709\u8d85\u8fc7\u6700\u5927\u6807\u8bc6\u7b26\u957f\u5ea6(\u5982\u679c\u8d85\u8fc7\uff0c\u5c31\u53d6\u524d\u9762\u4e00\u90e8\u5206\uff0c\u628a\u591a\u4f59\u7684\u629b\u5f03) *)\r\n      begin\r\n        k := k + 1; \r\n        a[k] := ch;\r\n      end;\r\n      getch (* \u8bfb\u4e0b\u4e00\u4e2a\u5b57\u7b26 *)\r\n    until not (ch in ['a'..'z','0'..'9']); (* \u76f4\u5230\u8bfb\u51fa\u7684\u4e0d\u662f\u5b57\u6bcd\u6216\u6570\u5b57\uff0c\u7531\u6b64\u53ef\u77e5PL\/0\u7684\u6807\u8bc6\u7b26\u6784\u6210\u89c4\u5219\u662f:\r\n                                              \u4ee5\u5b57\u6bcd\u5f00\u5934\uff0c\u540e\u9762\u8ddf\u82e5\u5e72\u4e2a\u5b57\u6bcd\u6216\u6570\u5b57 *)\r\n    if k &gt;= kk then (* \u5982\u679c\u5f53\u524d\u83b7\u5f97\u7684\u6807\u8bc6\u7b26\u957f\u5ea6\u5927\u4e8e\u7b49\u4e8ekk *)\r\n      kk := k (* \u4ee4kk\u4e3a\u5f53\u524d\u6807\u8bc6\u7b26\u957f\u5ea6 *)\r\n    else\r\n      repeat (* \u8fd9\u4e2a\u5faa\u73af\u7528\u4e8e\u628a\u6807\u8bc6\u7b26\u7f13\u51b2\u540e\u90e8\u6ca1\u6709\u586b\u5165\u76f8\u5e94\u5b57\u6bcd\u6216\u7a7a\u683c\u7684\u7a7a\u95f4\u7528\u7a7a\u683c\u8865\u8db3 *)\r\n        a[kk] := ' ';\r\n        kk := kk - 1\r\n      until kk = k;\r\n    (* \u5728\u7b2c\u4e00\u6b21\u8fd0\u884c\u8fd9\u4e2a\u8fc7\u7a0b\u65f6\uff0ckk\u7684\u503c\u4e3aal\uff0c\u5373\u6700\u5927\u6807\u8bc6\u7b26\u957f\u5ea6\uff0c\u5982\u679c\u8bfb\u5230\u7684\u6807\u8bc6\u7b26\u957f\u5ea6\u5c0f\u4e8ekk\uff0c\r\n       \u5c31\u628aa\u6570\u7ec4\u7684\u540e\u90e8\u6ca1\u6709\u5b57\u6bcd\u7684\u7a7a\u95f4\u7528\u7a7a\u683c\u8865\u8db3\u3002\r\n       \u8fd9\u65f6\uff0ckk\u7684\u503c\u5c31\u6210\u4e3aa\u6570\u7ec4\u524d\u90e8\u975e\u7a7a\u683c\u5b57\u7b26\u7684\u4e2a\u6570\u3002\u4ee5\u540e\u518d\u8fd0\u884cgetsym\u65f6\uff0c\u5982\u679c\u8bfb\u5230\u7684\u6807\u8bc6\u7b26\u957f\u5ea6\u5927\u4e8e\u7b49\u4e8ekk\uff0c\r\n       \u5c31\u628akk\u7684\u503c\u53d8\u6210\u5f53\u524d\u6807\u8bc6\u7b26\u7684\u957f\u5ea6\u3002\r\n       \u8fd9\u65f6\u5c31\u4e0d\u5fc5\u5728\u540e\u9762\u586b\u7a7a\u683c\u4e86\uff0c\u56e0\u4e3a\u5b83\u7684\u540e\u9762\u80af\u5b9a\u5168\u662f\u7a7a\u683c\u3002\u53cd\u4e4b\u5982\u679c\u6700\u8fd1\u8bfb\u5230\u7684\u6807\u8bc6\u7b26\u957f\u5ea6\u5c0f\u4e8ekk\uff0c\u90a3\u5c31\u9700\u8981\u4ecekk\u4f4d\u7f6e\u5411\u524d\uff0c\r\n       \u628a\u8d85\u8fc7\u5f53\u524d\u6807\u8bc6\u957f\u5ea6\u7684\u7a7a\u95f4\u586b\u6ee1\u7a7a\u683c\u3002\r\n       \u4ee5\u4e0a\u7684\u8fd9\u6837\u4e00\u4e2a\u903b\u8f91\uff0c\u5b8c\u5168\u662f\u51fa\u4e8e\u7a0b\u5e8f\u6027\u80fd\u7684\u4e0a\u8003\u8651\u3002\u5176\u5b9e\u5b8c\u5168\u53ef\u4ee5\u7b80\u5355\u7684\u628aa\u6570\u7ec4\u4e2da[k]\u5143\u7d20\u4ee5\u540e\u7684\u7a7a\u95f4\u4e0d\u7ba1\u4e09\u4e03\u4e8c\u5341\u4e00\u5168\u586b\u7a7a\u683c\u3002 \r\n    *)\r\n    (* \u4e0b\u9762\u5f00\u59cb\u4e8c\u5206\u6cd5\u67e5\u627e\u770b\u8bfb\u51fa\u7684\u6807\u8bc6\u7b26\u662f\u4e0d\u662f\u4fdd\u7559\u5b57\u4e4b\u4e00 *)\r\n    id := a; (* \u6700\u540e\u8bfb\u51fa\u6807\u8bc6\u7b26\u7b49\u4e8ea *)\r\n    i := 1; (* i\u6307\u5411\u7b2c\u4e00\u4e2a\u4fdd\u7559\u5b57 *)\r\n    j := norw; (* j\u6307\u5411\u6700\u540e\u4e00\u4e2a\u4fdd\u7559\u5b57 *)\r\n    repeat\r\n      k := (i + j) div 2; (* k\u6307\u5411\u4e2d\u95f4\u4e00\u4e2a\u4fdd\u7559\u5b57 *)\r\n      if id &lt;= word[k] then (* \u5982\u679c\u5f53\u524d\u7684\u6807\u8bc6\u7b26\u5c0f\u4e8ek\u6240\u6307\u7684\u4fdd\u7559\u5b57 *)\r\n        j := k - 1; (* \u79fb\u52a8j\u6307\u9488 *)\r\n      if id &gt;= word[k] then (* \u5982\u679c\u5f53\u524d\u7684\u6807\u8bc6\u7b26\u5927\u4e8ek\u6240\u6307\u7684\u4fdd\u7559\u5b57 *)\r\n        i := k + 1 (* \u79fb\u52a8i\u6307\u9488 *)\r\n    until i &gt; j; (* \u5faa\u73af\u76f4\u5230\u627e\u5b8c\u4fdd\u7559\u5b57\u8868 *)\r\n    if i - 1 &gt; j then (* \u5982\u679ci - 1 &gt; j\u8868\u660e\u5728\u4fdd\u7559\u5b57\u8868\u4e2d\u627e\u5230\u76f8\u5e94\u7684\u9879\uff0cid\u4e2d\u5b58\u7684\u662f\u4fdd\u7559\u5b57 *)\r\n      sym := wsym[k] (* \u627e\u5230\u4fdd\u7559\u5b57\uff0c\u628asym\u7f6e\u4e3a\u76f8\u5e94\u7684\u4fdd\u7559\u5b57\u503c *)\r\n    else\r\n      sym := ident (* \u672a\u627e\u5230\u4fdd\u7559\u5b57\uff0c\u628asym\u7f6e\u4e3aident\u7c7b\u578b\uff0c\u8868\u793a\u662f\u6807\u8bc6\u7b26 *)\r\n  end(* \u81f3\u6b64\u8bfb\u51fa\u5b57\u7b26\u4e3a\u5b57\u6bcd\u5373\u5bf9\u4fdd\u7559\u5b57\u6216\u6807\u8bc6\u7b26\u7684\u5904\u7406\u7ed3\u675f *)\r\n  else (* \u5982\u679c\u8bfb\u51fa\u5b57\u7b26\u4e0d\u662f\u5b57\u6bcd *)\r\n    if ch in ['0'..'9'] then (* \u5982\u679c\u8bfb\u51fa\u5b57\u7b26\u662f\u6570\u5b57 *)\r\n    begin (* number *) (* \u5f00\u59cb\u5bf9\u6570\u5b57\u8fdb\u884c\u5904\u7406 *)\r\n      k := 0; (* \u6570\u5b57\u4f4d\u6570 *)\r\n      num := 0; (* \u6570\u5b57\u7f6e\u4e3a0 *)\r\n      sym := number; (* \u7f6esym\u4e3anumber\uff0c\u8868\u793a\u8fd9\u4e00\u6b21\u8bfb\u5230\u7684\u662f\u6570\u5b57 *)\r\n      repeat (* \u8fd9\u4e2a\u5faa\u73af\u4f9d\u6b21\u4ece\u6e90\u6587\u4ef6\u4e2d\u8bfb\u51fa\u5b57\u7b26\uff0c\u7ec4\u6210\u6570\u5b57 *)\r\n        num := 10 * num + (ord(ch) - ord('0')); (* num * 10\u52a0\u4e0a\u6700\u8fd1\u8bfb\u51fa\u7684\u5b57\u7b26ASCII\u51cf'0'\u7684ASCII\u5f97\u5230\u76f8\u5e94\u7684\u6570\u503c *)\r\n        k := k + 1; (* \u6570\u5b57\u4f4d\u6570\u52a0\u4e00 *)\r\n        getch\r\n      until not (ch in ['0'..'9']); (* \u76f4\u5230\u8bfb\u51fa\u7684\u5b57\u7b26\u4e0d\u662f\u6570\u5b57\u4e3a\u6b62 *)\r\n      if k &gt; nmax then (* \u5982\u679c\u7ec4\u6210\u7684\u6570\u5b57\u4f4d\u6570\u5927\u4e8e\u6700\u5927\u5141\u8bb8\u7684\u6570\u5b57\u4f4d\u6570 *)\r\n        error(30) (* \u53d1\u51fa30\u53f7\u9519 *)\r\n    end(* \u81f3\u6b64\u5bf9\u6570\u5b57\u7684\u8bc6\u522b\u5904\u7406\u7ed3\u675f *)\r\n    else\r\n      if ch = ':' then (* \u5982\u679c\u8bfb\u51fa\u7684\u4e0d\u5b57\u6bcd\u4e5f\u4e0d\u662f\u6570\u5b57\u800c\u662f\u5192\u53f7 *)\r\n      begin\r\n        getch; (* \u518d\u8bfb\u4e00\u4e2a\u5b57\u7b26 *)\r\n        if ch = '=' then (* \u5982\u679c\u8bfb\u5230\u7684\u662f\u7b49\u53f7\uff0c\u6b63\u597d\u53ef\u4ee5\u4e0e\u5192\u53f7\u6784\u6210\u8d4b\u503c\u53f7 *)\r\n        begin\r\n          sym := becomes; (* sym\u7684\u7c7b\u578b\u8bbe\u4e3a\u8d4b\u503c\u53f7becomes *)\r\n          getch (* \u518d\u8bfb\u51fa\u4e0b\u4e00\u4e2a\u5b57 *)\r\n        end\r\n        else\r\n          sym := nul; (* \u5982\u679c\u4e0d\u662f\u8bfb\u5230\u7b49\u53f7\uff0c\u90a3\u5355\u72ec\u7684\u4e00\u4e2a\u5192\u53f7\u5c31\u4ec0\u4e48\u4e5f\u4e0d\u662f *)\r\n      end(* \u4ee5\u4e0a\u5b8c\u6210\u5bf9\u8d4b\u503c\u53f7\u7684\u5904\u7406 *)\r\n    else (* \u5982\u679c\u8bfb\u5230\u4e0d\u662f\u5b57\u6bcd\u4e5f\u4e0d\u662f\u6570\u5b57\u4e5f\u4e0d\u662f\u5192\u53f7 *)\r\n      if ch = '&lt;' then (* \u5982\u679c\u8bfb\u5230\u5c0f\u4e8e\u53f7 *)\r\n      begin\r\n        getch; (* \u518d\u8bfb\u4e00\u4e2a\u5b57\u7b26 *)\r\n        if ch = '=' then (* \u5982\u679c\u8bfb\u5230\u7b49\u53f7 *)\r\n        begin\r\n          sym := leq; (* \u8d2d\u6210\u4e00\u4e2a\u5c0f\u4e8e\u7b49\u4e8e\u53f7 *)\r\n          getch (* \u8bfb\u4e00\u4e2a\u5b57\u7b26 *)\r\n        end\r\n        else (* \u5982\u679c\u5c0f\u4e8e\u53f7\u540e\u4e0d\u662f\u8ddf\u7684\u7b49\u53f7 *)\r\n          sym := lss (* \u90a3\u5c31\u662f\u4e00\u4e2a\u5355\u72ec\u7684\u5c0f\u4e8e\u53f7 *)\r\n      end\r\n      else (* \u5982\u679c\u8bfb\u5230\u4e0d\u662f\u5b57\u6bcd\u4e5f\u4e0d\u662f\u6570\u5b57\u4e5f\u4e0d\u662f\u5192\u53f7\u4e5f\u4e0d\u662f\u5c0f\u4e8e\u53f7 *)\r\n        if ch = '&gt;' then (* \u5982\u679c\u8bfb\u5230\u5927\u4e8e\u53f7\uff0c\u5904\u7406\u8fc7\u7a0b\u7c7b\u4f3c\u4e8e\u5904\u7406\u5c0f\u4e8e\u53f7 *)\r\n        begin\r\n          getch; (* \u518d\u8bfb\u4e00\u4e2a\u5b57\u7b26 *)\r\n          if ch = '=' then (* \u5982\u679c\u8bfb\u5230\u7b49\u53f7 *)\r\n          begin\r\n            sym := geq; (* \u8d2d\u6210\u4e00\u4e2a\u5927\u4e8e\u7b49\u4e8e\u53f7 *)\r\n            getch (* \u8bfb\u4e00\u4e2a\u5b57\u7b26 *)\r\n          end\r\n          else (* \u5982\u679c\u5927\u4e8e\u53f7\u540e\u4e0d\u662f\u8ddf\u7684\u7b49\u53f7 *)\r\n            sym := gtr (* \u90a3\u5c31\u662f\u4e00\u4e2a\u5355\u72ec\u7684\u5927\u4e8e\u53f7 *)\r\n        end\r\n        else(* \u5982\u679c\u8bfb\u5230\u4e0d\u662f\u5b57\u6bcd\u4e5f\u4e0d\u662f\u6570\u5b57\u4e5f\u4e0d\u662f\u5192\u53f7\u4e5f\u4e0d\u662f\u5c0f\u4e8e\u53f7\u4e5f\u4e0d\u662f\u5927\u4e8e\u53f7 *)\r\n        begin (* \u90a3\u5c31\u8bf4\u660e\u5b83\u4e0d\u662f\u6807\u8bc6\u7b26\/\u4fdd\u7559\u5b57\uff0c\u4e5f\u4e0d\u662f\u590d\u6742\u7684\u53cc\u5b57\u8282\u64cd\u4f5c\u7b26\uff0c\u5e94\u8be5\u662f\u4e00\u4e2a\u666e\u901a\u7684\u7b26\u53f7 *)\r\n          sym := ssym[ch]; (* \u76f4\u63a5\u6210\u7b26\u53f7\u8868\u4e2d\u67e5\u5230\u5b83\u7684\u7c7b\u578b\uff0c\u8d4b\u7ed9sym *)\r\n          getch (* \u8bfb\u4e0b\u4e00\u4e2a\u5b57\u7b26 *)\r\n        end \r\n  (* \u6574\u4e2aif\u8bed\u53e5\u5224\u65ad\u7ed3\u675f *)\r\nend (* getsym *);\r\n(* \u8bcd\u6cd5\u5206\u6790\u8fc7\u7a0bgetsym\u603b\u7ed3\uff1a\u4ece\u6e90\u6587\u4ef6\u4e2d\u8bfb\u51fa\u82e5\u5e72\u6709\u6548\u5b57\u7b26\uff0c\u7ec4\u6210\u4e00\u4e2atoken\u4e32\uff0c\u8bc6\u522b\u5b83\u7684\u7c7b\u578b\r\n   \u4e3a\u4fdd\u7559\u5b57\/\u6807\u8bc6\u7b26\/\u6570\u5b57\u6216\u662f\u5176\u5b83\u7b26\u53f7\u3002\u5982\u679c\u662f\u4fdd\u7559\u5b57\uff0c\u628asym\u7f6e\u6210\u76f8\u5e94\u7684\u4fdd\u7559\u5b57\u7c7b\u578b\uff0c\u5982\u679c\u662f\r\n   \u6807\u8bc6\u7b26\uff0c\u628asym\u7f6e\u6210ident\u8868\u793a\u662f\u6807\u8bc6\u7b26\uff0c\u4e8e\u6b64\u540c\u65f6\uff0cid\u53d8\u91cf\u4e2d\u5b58\u653e\u7684\u5373\u4e3a\u4fdd\u7559\u5b57\u5b57\u7b26\u4e32\u6216\u6807\u8bc6\r\n   \u7b26\u540d\u5b57\u3002\u5982\u679c\u662f\u6570\u5b57\uff0c\u628asym\u7f6e\u4e3anumber,\u540c\u65f6num\u53d8\u91cf\u4e2d\u5b58\u653e\u8be5\u6570\u5b57\u7684\u503c\u3002\u5982\u679c\u662f\u5176\u5b83\u7684\u64cd\u4f5c\u7b26\uff0c\r\n   \u5219\u76f4\u63a5\u628asym\u7f6e\u6210\u76f8\u5e94\u7c7b\u578b\u3002\u7ecf\u8fc7\u672c\u8fc7\u7a0b\u540ech\u53d8\u91cf\u4e2d\u5b58\u653e\u7684\u662f\u4e0b\u4e00\u4e2a\u5373\u5c06\u88ab\u8bc6\u522b\u7684\u5b57\u7b26 *)\r\n(* \u76ee\u6807\u4ee3\u7801\u751f\u6210\u8fc7\u7a0bgen *)\r\n(* \u53c2\u6570\uff1ax:\u8981\u751f\u6210\u7684\u4e00\u884c\u4ee3\u7801\u7684\u52a9\u8bb0\u7b26 *)\r\n(*       y, z:\u4ee3\u7801\u7684\u4e24\u4e2a\u64cd\u4f5c\u6570 *)\r\n(* \u672c\u8fc7\u7a0b\u7528\u4e8e\u628a\u751f\u6210\u7684\u76ee\u6807\u4ee3\u7801\u5199\u5165\u76ee\u6807\u4ee3\u7801\u6570\u7ec4\uff0c\u4f9b\u540e\u9762\u7684\u89e3\u91ca\u5668\u89e3\u91ca\u6267\u884c *)\r\nprocedure gen(x: fct; y, z: integer);\r\nbegin\r\n  if cx &gt; cxmax then (* \u5982\u679ccx&gt;cxmax\u8868\u793a\u5f53\u524d\u751f\u6210\u7684\u4ee3\u7801\u884c\u53f7\u5927\u4e8e\u5141\u8bb8\u7684\u6700\u5927\u4ee3\u7801\u884c\u6570 *)\r\n  begin\r\n    write('program too long'); (* \u8f93\u51fa&quot;\u7a0b\u5e8f\u592a\u957f&quot;\uff0c\u9000\u51fa *)\r\n    close(fa);\r\n    close(fa1);\r\n    close(fin);\r\n    halt(0)       \r\n    {goto 99}\r\n    (* \u6211\u4fee\u6539\u7684\u4ee3\u7801\uff0c\u7531\u4e8eTurbo Pascal 7.0\u4e2d\u4e0d\u5141\u8bb8\u8de8\u8fc7\u7a0b\u7684goto\uff0c\u5c31\u53ea\u80fd\u7528\u4e0a\u9762\u7684\u65b9\u6cd5\u9000\u51fa\u7a0b\u5e8f\u4e86\u3002 *)\r\n  end;\r\n  with code[cx] do (* \u628a\u4ee3\u7801\u5199\u5165\u76ee\u6807\u4ee3\u7801\u6570\u7ec4\u7684\u5f53\u524dcx\u6240\u6307\u4f4d\u7f6e *)\r\n  begin\r\n    f := x;\r\n    l := y;\r\n    a := z;\r\n  end;\r\n  cx := cx + 1 (* \u79fb\u52a8cx\u6307\u9488\u6307\u5411\u4e0b\u4e00\u4e2a\u7a7a\u4f4d *)\r\nend (* gen *);\r\n(* \u6d4b\u8bd5\u5f53\u524d\u5355\u8bcd\u662f\u5426\u5408\u6cd5\u8fc7\u7a0btest *)\r\n(* \u53c2\u6570\uff1as1:\u5f53\u8bed\u6cd5\u5206\u6790\u8fdb\u5165\u6216\u9000\u51fa\u67d0\u4e00\u8bed\u6cd5\u5355\u5143\u65f6\u5f53\u524d\u5355\u8bcd\u7b26\u5408\u5e94\u5c5e\u4e8e\u7684\u96c6\u5408 *)\r\n(*       s2:\u5728\u67d0\u4e00\u51fa\u9519\u72b6\u6001\u4e0b\uff0c\u53ef\u6062\u590d\u8bed\u6cd5\u5206\u6790\u6b63\u5e38\u5de5\u4f5c\u7684\u8865\u5145\u5355\u8bcd\u96c6\u5408 *)\r\n(*       n:\u51fa\u9519\u4fe1\u606f\u7f16\u53f7\uff0c\u5f53\u5f53\u524d\u7b26\u53f7\u4e0d\u5c5e\u4e8e\u5408\u6cd5\u7684s1\u96c6\u5408\u65f6\u53d1\u51fa\u7684\u51fa\u9519\u4fe1\u606f *)\r\nprocedure test(s1, s2: symset; n: integer);\r\nbegin\r\n  if not (sym in s1) then (* \u5982\u679c\u5f53\u524d\u7b26\u53f7\u4e0d\u5728s1\u4e2d *)\r\n  begin\r\n    error(n); (* \u53d1\u51fan\u53f7\u9519\u8bef *)\r\n    s1 := s1 + s2; (* \u628as2\u96c6\u5408\u8865\u5145\u8fdbs1\u96c6\u5408 *)\r\n    while not (sym in s1) do (* \u901a\u8fc7\u5faa\u73af\u627e\u5230\u4e0b\u4e00\u4e2a\u5408\u6cd5\u7684\u7b26\u53f7\uff0c\u4ee5\u6062\u590d\u8bed\u6cd5\u5206\u6790\u5de5\u4f5c *)\r\n      getsym\r\n  end\r\nend (* test *);\r\n(* \u8bed\u6cd5\u5206\u6790\u8fc7\u7a0bblock *)\r\n(* \u53c2\u6570\uff1alev:\u8fd9\u4e00\u6b21\u8bed\u6cd5\u5206\u6790\u6240\u5728\u7684\u5c42\u6b21 *)\r\n(*       tx:\u7b26\u53f7\u8868\u6307\u9488 *)\r\n(*       fsys:\u7528\u4e8e\u51fa\u9519\u6062\u590d\u7684\u5355\u8bcd\u96c6\u5408 *)\r\nprocedure block(lev, tx: integer; fsys: symset);\r\nvar \r\n  dx: integer; (* data allocation index *) (* \u6570\u636e\u6bb5\u5185\u5b58\u5206\u914d\u6307\u9488\uff0c\u6307\u5411\u4e0b\u4e00\u4e2a\u88ab\u5206\u914d\u7a7a\u95f4\u5728\u6570\u636e\u6bb5\u4e2d\u7684\u504f\u79fb\u4f4d\u7f6e *)\r\n  tx0: integer;  (* initial table index *) (* \u8bb0\u5f55\u672c\u5c42\u5f00\u59cb\u65f6\u7b26\u53f7\u8868\u4f4d\u7f6e *)\r\n  cx0: integer;  (* initial code index *) (* \u8bb0\u5f55\u672c\u5c42\u5f00\u59cb\u65f6\u4ee3\u7801\u6bb5\u5206\u914d\u4f4d\u7f6e *)\r\n  (* \u767b\u9646\u7b26\u53f7\u8868\u8fc7\u7a0benter *)\r\n  (* \u53c2\u6570\uff1ak:\u6b32\u767b\u9646\u5230\u7b26\u53f7\u8868\u7684\u7b26\u53f7\u7c7b\u578b *)\r\n  procedure enter(k: object1);\r\n  begin (* enter object into table *)\r\n    tx := tx + 1; (* \u7b26\u53f7\u8868\u6307\u9488\u6307\u5411\u4e00\u4e2a\u65b0\u7684\u7a7a\u4f4d *)\r\n    with table[tx] do (* \u5f00\u59cb\u767b\u5f55 *)\r\n    begin\r\n      name := id; (* name\u662f\u7b26\u53f7\u7684\u540d\u5b57\uff0c\u5bf9\u4e8e\u6807\u8bc6\u7b26\uff0c\u8fd9\u91cc\u5c31\u662f\u6807\u8bc6\u7b26\u7684\u540d\u5b57 *)\r\n      kind := k; (* \u7b26\u53f7\u7c7b\u578b\uff0c\u53ef\u80fd\u662f\u5e38\u91cf\u3001\u53d8\u91cf\u6216\u8fc7\u7a0b\u540d *)\r\n      case k of (* \u6839\u636e\u4e0d\u540c\u7684\u7c7b\u578b\u8fdb\u884c\u4e0d\u540c\u7684\u64cd\u4f5c *)\r\n        constant: (* \u5982\u679c\u662f\u5e38\u91cf\u540d *)\r\n        begin\r\n          if num &gt; amax then (* \u5728\u5e38\u91cf\u7684\u6570\u503c\u5927\u4e8e\u5141\u8bb8\u7684\u6700\u5927\u503c\u7684\u60c5\u51b5\u4e0b *)\r\n          begin\r\n            error(31); (* \u629b\u51fa31\u53f7\u9519\u8bef *)\r\n            num := 0; (* \u5b9e\u9645\u767b\u9646\u7684\u6570\u5b57\u4ee50\u4ee3\u66ff *)\r\n          end;\r\n          val := num (* \u5982\u662f\u5408\u6cd5\u7684\u6570\u503c\uff0c\u5c31\u767b\u9646\u5230\u7b26\u53f7\u8868 *)\r\n        end;\r\n        variable: (* \u5982\u679c\u662f\u53d8\u91cf\u540d *)\r\n        begin\r\n          level := lev; (* \u8bb0\u4e0b\u5b83\u6240\u5c5e\u7684\u5c42\u6b21\u53f7 *)\r\n          adr := dx; (* \u8bb0\u4e0b\u5b83\u5728\u5f53\u524d\u5c42\u4e2d\u7684\u504f\u79fb\u91cf *)\r\n          dx := dx+1; (* \u504f\u79fb\u91cf\u81ea\u589e\u4e00\uff0c\u4e3a\u4e0b\u4e00\u6b21\u505a\u597d\u51c6\u5907 *)\r\n        end;\r\n        procedur: (* \u5982\u679c\u8981\u767b\u9646\u7684\u662f\u8fc7\u7a0b\u540d *)\r\n          level := lev (* \u8bb0\u5f55\u4e0b\u8fd9\u4e2a\u8fc7\u7a0b\u6240\u5728\u5c42\u6b21 *)\r\n      end\r\n    end\r\n  end (* enter *);\r\n  (* \u767b\u5f55\u7b26\u53f7\u8fc7\u7a0b\u6ca1\u6709\u8003\u8651\u5230\u91cd\u590d\u7684\u5b9a\u4e49\u7684\u95ee\u9898\u3002\u5982\u679c\u51fa\u73b0\u91cd\u590d\u5b9a\u4e49\uff0c\u5219\u4ee5\u6700\u540e\u4e00\u6b21\u7684\u5b9a\u4e49\u4e3a\u51c6\u3002 *)\r\n  \r\n  (* \u5728\u7b26\u53f7\u8868\u4e2d\u67e5\u627e\u6307\u5b9a\u7b26\u53f7\u6240\u5728\u4f4d\u7f6e\u7684\u51fd\u6570position *)\r\n  (* \u53c2\u6570\uff1aid:\u8981\u627e\u7684\u7b26\u53f7 *)\r\n  (* \u8fd4\u56de\u503c\uff1a\u8981\u627e\u7684\u7b26\u53f7\u5728\u7b26\u53f7\u8868\u4e2d\u7684\u4f4d\u7f6e\uff0c\u5982\u679c\u627e\u4e0d\u5230\u5c31\u8fd4\u56de0 *)\r\n  function position (id: alfa): integer;\r\n  var \r\n    i: integer;\r\n  begin (* find identifier in table *)\r\n    table[0].name := id; (* \u5148\u628aid\u653e\u5165\u7b26\u53f7\u88680\u53f7\u4f4d\u7f6e *)\r\n    i := tx; (* \u4ece\u7b26\u53f7\u8868\u4e2d\u5f53\u524d\u4f4d\u7f6e\u4e5f\u5373\u6700\u540e\u4e00\u4e2a\u7b26\u53f7\u5f00\u59cb\u627e *)\r\n    while table[i].name &lt;&gt; id do (* \u5982\u679c\u5f53\u524d\u7684\u7b26\u53f7\u4e0e\u8981\u627e\u7684\u4e0d\u4e00\u81f4 *)\r\n      i := i - 1; (* \u627e\u524d\u9762\u4e00\u4e2a *)\r\n    position := i (* \u8fd4\u56de\u627e\u5230\u7684\u4f4d\u7f6e\u53f7\uff0c\u5982\u679c\u6ca1\u627e\u5230\u5219\u4e00\u5b9a\u6b63\u597d\u4e3a0 *)\r\n  end(* position *);\r\n  (* \u5e38\u91cf\u58f0\u660e\u5904\u7406\u8fc7\u7a0bconstdeclaration *)\r\n  procedure constdeclaration;\r\n  begin\r\n    if sym = ident then (* \u5e38\u91cf\u58f0\u660e\u8fc7\u7a0b\u5f00\u59cb\u9047\u5230\u7684\u7b2c\u4e00\u4e2a\u7b26\u53f7\u5fc5\u7136\u5e94\u4e3a\u6807\u8bc6\u7b26 *)\r\n    begin\r\n      getsym; (* \u83b7\u53d6\u4e0b\u4e00\u4e2atoken *)\r\n      if sym in [eql, becomes] then (* \u5982\u679c\u662f\u7b49\u53f7\u6216\u8d4b\u503c\u53f7 *)\r\n      begin\r\n        if sym = becomes then (* \u5982\u679c\u662f\u8d4b\u503c\u53f7(\u5e38\u91cf\u751f\u660e\u4e2d\u5e94\u8be5\u662f\u7b49\u53f7) *)\r\n          error(1); (* \u629b\u51fa1\u53f7\u9519\u8bef *)\r\n        (* \u8fd9\u91cc\u5176\u5b9e\u81ea\u52a8\u8fdb\u884c\u4e86\u9519\u8bef\u7ea0\u6b63\u4f7f\u7f16\u8bd1\u7ee7\u7eed\u8fdb\u884c\uff0c\u628a\u8d4b\u503c\u53f7\u5f53\u4f5c\u7b49\u53f7\u5904\u7406 *)\r\n        getsym; (* \u83b7\u53d6\u4e0b\u4e00\u4e2atoken\uff0c\u7b49\u53f7\u6216\u8d4b\u503c\u53f7\u540e\u5e94\u63a5\u4e0a\u6570\u5b57 *)\r\n        if sym = number then (* \u5982\u679c\u7684\u786e\u662f\u6570\u5b57 *) \r\n        begin\r\n          enter(constant); (* \u628a\u8fd9\u4e2a\u5e38\u91cf\u767b\u9646\u5230\u7b26\u53f7\u8868 *)\r\n          getsym (* \u83b7\u53d6\u4e0b\u4e00\u4e2atoken\uff0c\u4e3a\u540e\u9762\u4f5c\u51c6\u5907 *)\r\n        end\r\n        else\r\n          error(2) (* \u5982\u679c\u7b49\u53f7\u540e\u63a5\u7684\u4e0d\u662f\u6570\u5b57\uff0c\u629b\u51fa2\u53f7\u9519\u8bef *)\r\n      end\r\n      else\r\n        error(3) (* \u5982\u679c\u5e38\u91cf\u6807\u8bc6\u7b26\u540e\u63a5\u7684\u4e0d\u662f\u7b49\u53f7\u6216\u8d4b\u503c\u53f7\uff0c\u629b\u51fa3\u53f7\u9519\u8bef *)\r\n    end\r\n    else\r\n      error(4) (* \u5982\u679c\u5e38\u91cf\u58f0\u660e\u8fc7\u7a0b\u9047\u5230\u7684\u7b2c\u4e00\u4e2a\u7b26\u53f7\u4e0d\u4e3a\u6807\u8bc6\u7b26\uff0c\u629b\u51fa4\u53f7\u9519\u8bef *)\r\n  end(* constdeclaration *);\r\n  (* \u53d8\u91cf\u58f0\u660e\u8fc7\u7a0bvardeclaration *)  \r\n  procedure vardeclaration;\r\n  begin\r\n    if sym = ident then (* \u53d8\u91cf\u58f0\u660e\u8fc7\u7a0b\u5f00\u59cb\u9047\u5230\u7684\u7b2c\u4e00\u4e2a\u7b26\u53f7\u5fc5\u7136\u5e94\u4e3a\u6807\u8bc6\u7b26 *)\r\n    begin\r\n      enter(variable); (* \u5c06\u6807\u8bc6\u7b26\u767b\u9646\u5230\u7b26\u53f7\u8868\u4e2d *)\r\n      getsym (* \u83b7\u53d6\u4e0b\u4e00\u4e2atoken\uff0c\u4e3a\u540e\u9762\u4f5c\u51c6\u5907 *)\r\n    end\r\n    else\r\n      error(4) (* \u5982\u679c\u53d8\u91cf\u58f0\u660e\u8fc7\u7a0b\u9047\u5230\u7684\u7b2c\u4e00\u4e2a\u7b26\u53f7\u4e0d\u662f\u6807\u8bc6\u7b26\uff0c\u629b\u51fa4\u53f7\u9519\u8bef *)\r\n  end(* vardeclaration *);\r\n  (* \u5217\u51fa\u5f53\u524d\u4e00\u5c42\u7c7bPCODE\u76ee\u6807\u4ee3\u7801\u8fc7\u7a0blistcode *) \r\n  procedure listcode;\r\n  var \r\n    i: integer;\r\n  begin (* list code generated for this block *)\r\n    if listswitch then (* \u5982\u679c\u7528\u6237\u9009\u62e9\u662f\u8981\u5217\u51fa\u4ee3\u7801\u7684\u60c5\u51b5\u4e0b\u624d\u5217\u51fa\u4ee3\u7801 *)\r\n    begin\r\n      for i := cx0 to cx - 1 do (* \u4ece\u5f53\u524d\u5c42\u4ee3\u7801\u5f00\u59cb\u4f4d\u7f6e\u5230\u5f53\u524d\u4ee3\u7801\u4f4d\u7f6e-1\u5904\uff0c\u5373\u4e3a\u672c\u5206\u7a0b\u5e8f\u5757 *)\r\n        with code[i] do\r\n        begin\r\n          writeln(i: 4, mnemonic[f]: 5, l: 3, a: 5); (* \u663e\u793a\u51fa\u7b2ci\u884c\u4ee3\u7801\u7684\u52a9\u8bb0\u7b26\u548cL\u4e0eA\u64cd\u4f5c\u6570 *)\r\n          (* \u6211\u4fee\u6539\u7684\u4ee3\u7801\uff1a\u539f\u7a0b\u5e8f\u6b64\u5904\u5728\u8f93\u51fai\u65f6\uff0c\u6ca1\u6709\u6307\u5b9a\u53604\u4e2a\u5b57\u7b26\u5bbd\u5ea6\uff0c\u4e0d\u7f8e\u89c2\u4e5f\u4e0e\u4e0b\u9762\u4e00\u53e5\u4e0d\u914d\u5957\u3002 *)\r\n          writeln(fa, i: 4, mnemonic[f]: 5, l: 3, a: 5) (* \u540c\u65f6\u628a\u5c4f\u663e\u6253\u5370\u5230\u6587\u4ef6 *)\r\n        end;\r\n    end\r\n  end(* listcode *);\r\n  (* \u8bed\u53e5\u5904\u7406\u8fc7\u7a0bstatement *)\r\n  (* \u53c2\u6570\u8bf4\u660e\uff1afsys: \u5982\u679c\u51fa\u9519\u53ef\u7528\u6765\u6062\u590d\u8bed\u6cd5\u5206\u6790\u7684\u7b26\u53f7\u96c6\u5408 *)\r\n  procedure statement(fsys: symset);\r\n  var \r\n    i, cx1, cx2: integer;\r\n    (* \u8868\u8fbe\u5f0f\u5904\u7406\u8fc7\u7a0bexpression *)\r\n    (* \u53c2\u6570\u8bf4\u660e\uff1afsys: \u5982\u679c\u51fa\u9519\u53ef\u7528\u6765\u6062\u590d\u8bed\u6cd5\u5206\u6790\u7684\u7b26\u53f7\u96c6\u5408 *)\r\n    procedure expression(fsys: symset);\r\n    var \r\n      addop: symbol;\r\n      (* \u9879\u5904\u7406\u8fc7\u7a0bterm *)\r\n      (* \u53c2\u6570\u8bf4\u660e\uff1afsys: \u5982\u679c\u51fa\u9519\u53ef\u7528\u6765\u6062\u590d\u8bed\u6cd5\u5206\u6790\u7684\u7b26\u53f7\u96c6\u5408 *)\r\n      procedure term(fsys: symset);\r\n      var \r\n        mulop: symbol;\r\n        (* \u56e0\u5b50\u5904\u7406\u8fc7\u7a0bfactor *)\r\n        (* \u53c2\u6570\u8bf4\u660e\uff1afsys: \u5982\u679c\u51fa\u9519\u53ef\u7528\u6765\u6062\u590d\u8bed\u6cd5\u5206\u6790\u7684\u7b26\u53f7\u96c6\u5408 *)\r\n        procedure factor(fsys: symset);\r\n        var \r\n          i: integer;\r\n        begin\r\n          test(facbegsys, fsys, 24); (* \u5f00\u59cb\u56e0\u5b50\u5904\u7406\u524d\uff0c\u5148\u68c0\u67e5\u5f53\u524dtoken\u662f\u5426\u5728facbegsys\u96c6\u5408\u4e2d\u3002 *)\r\n                                     (* \u5982\u679c\u4e0d\u662f\u5408\u6cd5\u7684token\uff0c\u629b24\u53f7\u9519\u8bef\uff0c\u5e76\u901a\u8fc7fsys\u96c6\u6062\u590d\u4f7f\u8bed\u6cd5\u5904\u7406\u53ef\u4ee5\u7ee7\u7eed\u8fdb\u884c *)         \r\n          while sym in facbegsys do (* \u5faa\u73af\u5904\u7406\u56e0\u5b50 *)\r\n          begin\r\n            if sym = ident then (* \u5982\u679c\u9047\u5230\u7684\u662f\u6807\u8bc6\u7b26 *)\r\n            begin\r\n              i := position(id); (* \u67e5\u7b26\u53f7\u8868\uff0c\u627e\u5230\u5f53\u524d\u6807\u8bc6\u7b26\u5728\u7b26\u53f7\u8868\u4e2d\u7684\u4f4d\u7f6e *)\r\n              if i = 0 then (* \u5982\u679c\u67e5\u7b26\u53f7\u8868\u8fd4\u56de\u4e3a0\uff0c\u8868\u793a\u6ca1\u6709\u627e\u5230\u6807\u8bc6\u7b26 *)\r\n                error(11) (* \u629b\u51fa11\u53f7\u9519\u8bef *)\r\n              else\r\n                with table[i] do (* \u5982\u679c\u5728\u7b26\u53f7\u8868\u4e2d\u627e\u5230\u4e86\u5f53\u524d\u6807\u8bc6\u7b26\u7684\u4f4d\u7f6e\uff0c\u5f00\u59cb\u751f\u6210\u76f8\u5e94\u4ee3\u7801 *)\r\n                  case kind of\r\n                    constant: gen(lit, 0, val); (* \u5982\u679c\u8fd9\u4e2a\u6807\u8bc6\u7b26\u5bf9\u5e94\u7684\u662f\u5e38\u91cf\uff0c\u503c\u4e3aval\uff0c\u751f\u6210lit\u6307\u4ee4\uff0c\u628aval\u653e\u5230\u6808\u9876 *)\r\n                    variable: gen(lod, lev - level, adr); (* \u5982\u679c\u6807\u8bc6\u7b26\u662f\u53d8\u91cf\u540d\uff0c\u751f\u6210lod\u6307\u4ee4\uff0c *)\r\n                                                          (* \u628a\u4f4d\u4e8e\u8ddd\u79bb\u5f53\u524d\u5c42level\u7684\u5c42\u7684\u504f\u79fb\u5730\u5740\u4e3aadr\u7684\u53d8\u91cf\u653e\u5230\u6808\u9876 *)\r\n                    procedur: error(21) (* \u5982\u679c\u5728\u56e0\u5b50\u5904\u7406\u4e2d\u9047\u5230\u7684\u6807\u8bc6\u7b26\u662f\u8fc7\u7a0b\u540d\uff0c\u51fa\u9519\u4e86\uff0c\u629b21\u53f7\u9519 *)\r\n                  end;\r\n              getsym (* \u83b7\u53d6\u4e0b\u4e00token\uff0c\u7ee7\u7eed\u5faa\u73af\u5904\u7406 *)\r\n            end\r\n            else\r\n              if sym = number then (* \u5982\u679c\u56e0\u5b50\u5904\u7406\u65f6\u9047\u5230\u6570\u5b57 *)\r\n              begin\r\n                if num &gt; amax then (* \u5982\u679c\u6570\u5b57\u7684\u5927\u5c0f\u8d85\u8fc7\u5141\u8bb8\u6700\u5927\u503camax *)\r\n                begin\r\n                  error(31); (* \u629b\u51fa31\u53f7\u9519 *)\r\n                  num := 0 (* \u628a\u6570\u5b57\u63090\u503c\u5904\u7406 *)\r\n                end;\r\n                gen(lit, 0, num); (* \u751f\u6210lit\u6307\u4ee4\uff0c\u628a\u8fd9\u4e2a\u6570\u503c\u5b57\u9762\u5e38\u91cf\u653e\u5230\u6808\u9876 *)\r\n                getsym (* \u83b7\u53d6\u4e0b\u4e00token *)\r\n              end\r\n              else\r\n                if sym = lparen then (* \u5982\u679c\u9047\u5230\u7684\u662f\u5de6\u62ec\u53f7 *)\r\n                begin\r\n                  getsym; (* \u83b7\u53d6\u4e00\u4e2atoken *)\r\n                  expression( [rparen] + fsys ); (* \u9012\u5f52\u8c03\u7528expression\u5b50\u7a0b\u5e8f\u5206\u6790\u4e00\u4e2a\u5b50\u8868\u8fbe\u5f0f *)\r\n                  if sym = rparen then (* \u5b50\u8868\u8fbe\u5f0f\u5206\u6790\u5b8c\u540e\uff0c\u5e94\u9047\u5230\u53f3\u62ec\u53f7 *)\r\n                    getsym (* \u5982\u679c\u7684\u786e\u9047\u5230\u53f3\u62ec\u53f7\uff0c\u8bfb\u53d6\u4e0b\u4e00\u4e2atoken *)\r\n                  else\r\n                    error(22) (* \u5426\u5219\u629b\u51fa22\u53f7\u9519\u8bef *)\r\n                end;\r\n            test(fsys, facbegsys, 23) (* \u4e00\u4e2a\u56e0\u5b50\u5904\u7406\u5b8c\u6bd5\uff0c\u9047\u5230\u7684token\u5e94\u5728fsys\u96c6\u5408\u4e2d *)\r\n                                      (* \u5982\u679c\u4e0d\u662f\uff0c\u629b23\u53f7\u9519\uff0c\u5e76\u627e\u5230\u4e0b\u4e00\u4e2a\u56e0\u5b50\u7684\u5f00\u59cb\uff0c\u4f7f\u8bed\u6cd5\u5206\u6790\u53ef\u4ee5\u7ee7\u7eed\u8fd0\u884c\u4e0b\u53bb *)\r\n          end\r\n        end(* factor *);\r\n      begin (* term *)\r\n        factor([times, slash] + fsys); (* \u6bcf\u4e00\u4e2a\u9879\u90fd\u5e94\u8be5\u7531\u56e0\u5b50\u5f00\u59cb\uff0c\u56e0\u6b64\u8c03\u7528factor\u5b50\u7a0b\u5e8f\u5206\u6790\u56e0\u5b50 *)\r\n        while sym in [times, slash] do (* \u4e00\u4e2a\u56e0\u5b50\u540e\u5e94\u5f53\u9047\u5230\u4e58\u53f7\u6216\u9664\u53f7 *)\r\n        begin\r\n          mulop := sym; (* \u4fdd\u5b58\u5f53\u524d\u8fd0\u7b97\u7b26 *)\r\n          getsym; (* \u83b7\u53d6\u4e0b\u4e00\u4e2atoken *)\r\n          factor(fsys + [times, slash]); (* \u8fd0\u7b97\u7b26\u540e\u5e94\u662f\u4e00\u4e2a\u56e0\u5b50\uff0c\u6545\u8c03factor\u5b50\u7a0b\u5e8f\u5206\u6790\u56e0\u5b50 *)\r\n          if mulop = times then (* \u5982\u679c\u521a\u624d\u9047\u5230\u4e58\u53f7 *)\r\n            gen(opr, 0, 4) (* \u751f\u6210\u4e58\u6cd5\u6307\u4ee4 *)\r\n          else\r\n            gen(opr, 0, 5) (* \u4e0d\u662f\u4e58\u53f7\u4e00\u5b9a\u662f\u9664\u53f7\uff0c\u751f\u6210\u9664\u6cd5\u6307\u4ee4 *)\r\n        end\r\n      end (* term *);\r\n    begin (* expression *)\r\n      if sym in [plus, minus] then (* \u4e00\u4e2a\u8868\u8fbe\u5f0f\u53ef\u80fd\u4f1a\u7531\u52a0\u53f7\u6216\u51cf\u53f7\u5f00\u59cb\uff0c\u8868\u793a\u6b63\u8d1f\u53f7 *)\r\n      begin\r\n        addop := sym; (* \u628a\u5f53\u524d\u7684\u6b63\u53f7\u6216\u8d1f\u53f7\u4fdd\u5b58\u8d77\u6765\uff0c\u4ee5\u4fbf\u4e0b\u9762\u751f\u6210\u76f8\u5e94\u4ee3\u7801 *)\r\n        getsym; (* \u83b7\u53d6\u4e00\u4e2atoken *)\r\n        term(fsys + [plus, minus]); (* \u6b63\u8d1f\u53f7\u540e\u9762\u5e94\u8be5\u662f\u4e00\u4e2a\u9879\uff0c\u8c03term\u5b50\u7a0b\u5e8f\u5206\u6790 *)\r\n        if addop = minus then (* \u5982\u679c\u4fdd\u5b58\u4e0b\u6765\u7684\u7b26\u53f7\u662f\u8d1f\u53f7 *)\r\n          gen(opr, 0, 1) (* \u751f\u6210\u4e00\u67611\u53f7\u64cd\u4f5c\u6307\u4ee4\uff1a\u53d6\u53cd\u8fd0\u7b97 *)\r\n        (* \u5982\u679c\u4e0d\u662f\u8d1f\u53f7\u5c31\u662f\u6b63\u53f7\uff0c\u4e0d\u9700\u751f\u6210\u76f8\u5e94\u7684\u6307\u4ee4 *)\r\n      end\r\n      else (* \u5982\u679c\u4e0d\u662f\u7531\u6b63\u8d1f\u53f7\u5f00\u5934\uff0c\u5c31\u5e94\u662f\u4e00\u4e2a\u9879\u5f00\u5934 *)\r\n        term(fsys + [plus, minus]); (* \u8c03\u7528term\u5b50\u7a0b\u5e8f\u5206\u6790\u9879 *) \r\n      while sym in [plus, minus] do (* \u9879\u540e\u5e94\u662f\u52a0\u8fd0\u7b97\u6216\u51cf\u8fd0\u7b97 *)\r\n      begin\r\n        addop := sym; (* \u628a\u8fd0\u7b97\u7b26\u4fdd\u5b58\u4e0b\u6765 *)\r\n        getsym; (* \u83b7\u53d6\u4e0b\u4e00\u4e2atoken\uff0c\u52a0\u51cf\u8fd0\u7b97\u7b26\u540e\u5e94\u8ddf\u7684\u662f\u4e00\u4e2a\u9879 *)\r\n        term(fsys + [plus, minus]); (* \u8c03term\u5b50\u7a0b\u5e8f\u5206\u6790\u9879 *)\r\n        if addop = plus then (* \u5982\u679c\u9879\u4e0e\u9879\u4e4b\u95f4\u7684\u8fd0\u7b97\u7b26\u662f\u52a0\u53f7 *)\r\n          gen(opr, 0, 2) (* \u751f\u62102\u53f7\u64cd\u4f5c\u6307\u4ee4\uff1a\u52a0\u6cd5 *)\r\n        else (* \u5426\u5219\u662f\u51cf\u6cd5 *)\r\n          gen(opr, 0, 3) (* \u751f\u62103\u53f7\u64cd\u4f5c\u6307\u4ee4\uff1a\u51cf\u6cd5 *)\r\n      end\r\n    end (* expression *);\r\n    (* \u6761\u4ef6\u5904\u7406\u8fc7\u7a0bcondition *)\r\n    (* \u53c2\u6570\u8bf4\u660e\uff1afsys: \u5982\u679c\u51fa\u9519\u53ef\u7528\u6765\u6062\u590d\u8bed\u6cd5\u5206\u6790\u7684\u7b26\u53f7\u96c6\u5408 *)\r\n    procedure condition(fsys: symset);\r\n    var \r\n      relop: symbol; (* \u7528\u4e8e\u4e34\u65f6\u8bb0\u5f55token(\u8fd9\u91cc\u4e00\u5b9a\u662f\u4e00\u4e2a\u4e8c\u5143\u903b\u8f91\u8fd0\u7b97\u7b26)\u7684\u5185\u5bb9 *)\r\n    begin\r\n      if sym = oddsym then (* \u5982\u679c\u662fodd\u8fd0\u7b97\u7b26(\u4e00\u5143) *)\r\n      begin\r\n        getsym; (* \u83b7\u53d6\u4e0b\u4e00\u4e2atoken *)\r\n        expression(fsys); (* \u5bf9odd\u7684\u8868\u8fbe\u5f0f\u8fdb\u884c\u5904\u7406\u8ba1\u7b97 *)\r\n        gen(opr, 0, 6); (* \u751f\u62106\u53f7\u64cd\u4f5c\u6307\u4ee4\uff1a\u5947\u5076\u5224\u65ad\u8fd0\u7b97 *)\r\n      end\r\n      else (* \u5982\u679c\u4e0d\u662fodd\u8fd0\u7b97\u7b26(\u90a3\u5c31\u4e00\u5b9a\u662f\u4e8c\u5143\u903b\u8f91\u8fd0\u7b97\u7b26) *)\r\n      begin\r\n        expression([eql, neq, lss, leq, gtr, geq] + fsys); (* \u5bf9\u8868\u8fbe\u5f0f\u5de6\u90e8\u8fdb\u884c\u5904\u7406\u8ba1\u7b97 *)\r\n        if not (sym in [eql, neq, lss, leq, gtr, geq]) then (* \u5982\u679ctoken\u4e0d\u662f\u903b\u8f91\u8fd0\u7b97\u7b26\u4e2d\u7684\u4e00\u4e2a *)\r\n          error(20) (* \u629b\u51fa20\u53f7\u9519\u8bef *)\r\n        else\r\n        begin\r\n          relop := sym; (* \u8bb0\u5f55\u4e0b\u5f53\u524d\u7684\u903b\u8f91\u8fd0\u7b97\u7b26 *)\r\n          getsym; (* \u83b7\u53d6\u4e0b\u4e00\u4e2atoken *)\r\n          expression(fsys); (* \u5bf9\u8868\u8fbe\u5f0f\u53f3\u90e8\u8fdb\u884c\u5904\u7406\u8ba1\u7b97 *)\r\n          case relop of (* \u5982\u679c\u521a\u624d\u7684\u8fd0\u7b97\u7b26\u662f\u4e0b\u9762\u7684\u4e00\u79cd *)\r\n            eql: gen(opr, 0, 8); (* \u7b49\u53f7\uff1a\u4ea7\u751f8\u53f7\u5224\u7b49\u6307\u4ee4 *)\r\n            neq: gen(opr, 0, 9); (* \u4e0d\u7b49\u53f7\uff1a\u4ea7\u751f9\u53f7\u5224\u4e0d\u7b49\u6307\u4ee4 *)\r\n            lss: gen(opr, 0, 10); (* \u5c0f\u4e8e\u53f7\uff1a\u4ea7\u751f10\u53f7\u5224\u5c0f\u6307\u4ee4 *)\r\n            geq: gen(opr, 0, 11); (* \u5927\u4e8e\u7b49\u53f7\u53f7\uff1a\u4ea7\u751f11\u53f7\u5224\u4e0d\u5c0f\u4e8e\u6307\u4ee4 *)\r\n            gtr: gen(opr, 0, 12); (* \u5927\u4e8e\u53f7\uff1a\u4ea7\u751f12\u53f7\u5224\u5927\u4e8e\u6307\u4ee4 *)\r\n            leq: gen(opr, 0, 13); (* \u5c0f\u4e8e\u7b49\u4e8e\u53f7\uff1a\u4ea7\u751f13\u53f7\u5224\u4e0d\u5927\u4e8e\u6307\u4ee4 *)\r\n          end\r\n        end\r\n      end\r\n    end (* condition *);\r\n  begin (* statement *)\r\n    if sym = ident then (* \u6240\u8c13&quot;\u8bed\u53e5&quot;\u53ef\u80fd\u662f\u8d4b\u503c\u8bed\u53e5\uff0c\u4ee5\u6807\u8bc6\u7b26\u5f00\u5934 *)\r\n    begin\r\n      i := position(id); (* \u5728\u7b26\u53f7\u8868\u4e2d\u67e5\u5230\u8be5\u6807\u8bc6\u7b26\u6240\u5728\u4f4d\u7f6e *)\r\n      if i = 0 then (* \u5982\u679c\u6ca1\u627e\u5230 *)\r\n        error(11) (* \u629b\u51fa11\u53f7\u9519\u8bef *)\r\n      else\r\n        if table[i].kind &lt;&gt; variable then (* \u5982\u679c\u5728\u7b26\u53f7\u8868\u4e2d\u627e\u5230\u8be5\u6807\u8bc6\u7b26\uff0c\u4f46\u8be5\u6807\u8bc6\u7b26\u4e0d\u662f\u53d8\u91cf\u540d *) \r\n        begin\r\n          error(12); (* \u629b\u51fa12\u53f7\u9519\u8bef *)\r\n          i := 0 (* i\u7f6e0\u4f5c\u4e3a\u9519\u8bef\u6807\u5fd7 *)\r\n        end;\r\n      getsym; (* \u83b7\u5f97\u4e0b\u4e00\u4e2atoken\uff0c\u6b63\u5e38\u5e94\u4e3a\u8d4b\u503c\u53f7 *)\r\n      if sym = becomes then (* \u5982\u679c\u7684\u786e\u4e3a\u8d4b\u503c\u53f7 *)\r\n        getsym (* \u83b7\u53d6\u4e0b\u4e00\u4e2atoken\uff0c\u6b63\u5e38\u5e94\u4e3a\u4e00\u4e2a\u8868\u8fbe\u5f0f *)\r\n      else\r\n        error(13); (* \u5982\u679c\u8d4b\u503c\u8bed\u53e5\u7684\u5de6\u90e8\u6807\u8bc6\u7b26\u53f7\u540e\u6240\u63a5\u4e0d\u662f\u8d4b\u503c\u53f7\uff0c\u629b\u51fa13\u53f7\u9519\u8bef *)\r\n      expression(fsys); (* \u5904\u7406\u8868\u8fbe\u5f0f *)\r\n      if i &lt;&gt; 0 then (* \u5982\u679c\u4e0d\u66fe\u51fa\u9519\uff0ci\u5c06\u4e0d\u4e3a0\uff0ci\u6240\u6307\u4e3a\u5f53\u524d\u8bed\u540d\u5de6\u90e8\u6807\u8bc6\u7b26\u5728\u7b26\u53f7\u8868\u4e2d\u7684\u4f4d\u7f6e *)\r\n        with table[i] do\r\n          gen(sto, lev - level, adr) (* \u4ea7\u751f\u4e00\u884c\u628a\u8868\u8fbe\u5f0f\u503c\u5199\u5f80\u6307\u5b9a\u5185\u5b58\u7684sto\u76ee\u6807\u4ee3\u7801 *)\r\n    end\r\n    else\r\n      if sym = readsym then (* \u5982\u679c\u4e0d\u662f\u8d4b\u503c\u8bed\u53e5\uff0c\u800c\u662f\u9047\u5230\u4e86read\u8bed\u53e5 *)\r\n      begin\r\n        getsym; (* \u83b7\u5f97\u4e0b\u4e00token\uff0c\u6b63\u5e38\u60c5\u51b5\u4e0b\u5e94\u4e3a\u5de6\u62ec\u53f7 *)\r\n        if sym &lt;&gt; lparen then (* \u5982\u679cread\u8bed\u53e5\u540e\u8ddf\u7684\u4e0d\u662f\u5de6\u62ec\u53f7 *)\r\n          error(34) (* \u629b\u51fa34\u53f7\u9519\u8bef *)\r\n        else\r\n          repeat (* \u5faa\u73af\u5f97\u5230read\u8bed\u53e5\u62ec\u53f7\u4e2d\u7684\u53c2\u6570\u8868\uff0c\u4f9d\u6b21\u4ea7\u751f\u76f8\u5e94\u7684&ldquo;\u4ece\u952e\u76d8\u8bfb\u5165&rdquo;\u76ee\u6807\u4ee3\u7801 *)\r\n            getsym; (* \u83b7\u5f97\u4e00\u4e2atoken\uff0c\u6b63\u5e38\u5e94\u662f\u4e00\u4e2a\u53d8\u91cf\u540d *)\r\n            if sym = ident then (* \u5982\u679c\u786e\u4e3a\u4e00\u4e2a\u6807\u8bc6\u7b26 *) \r\n            (* \u8fd9\u91cc\u7565\u6709\u95ee\u9898\uff0c\u8fd8\u5e94\u5224\u65ad\u4e00\u4e0b\u8fd9\u4e2a\u6807\u8bc6\u7b26\u662f\u4e0d\u662f\u53d8\u91cf\u540d\uff0c\u5982\u679c\u662f\u5e38\u91cf\u540d\u6216\u8fc7\u7a0b\u540d\u5e94\u51fa\u9519 *)\r\n              i := position(id) (* \u67e5\u7b26\u53f7\u8868\uff0c\u627e\u5230\u5b83\u6240\u5728\u4f4d\u7f6e\u7ed9i\uff0c\u627e\u4e0d\u5230\u65f6i\u4f1a\u4e3a0 *)\r\n            else\r\n              i := 0; (* \u4e0d\u662f\u6807\u8bc6\u7b26\u5219\u6709\u95ee\u9898\uff0ci\u7f6e0\u4f5c\u4e3a\u51fa\u9519\u6807\u5fd7 *)\r\n            if i = 0 then (* \u5982\u679c\u6709\u9519\u8bef *)\r\n              error(35) (* \u629b\u51fa35\u53f7\u9519\u8bef *)\r\n            else (* \u5426\u5219\u751f\u6210\u76f8\u5e94\u7684\u76ee\u6807\u4ee3\u7801 *)\r\n              with table[i] do\r\n              begin\r\n                gen(opr, 0, 16); (* \u751f\u621016\u53f7\u64cd\u4f5c\u6307\u4ee4:\u4ece\u952e\u76d8\u8bfb\u5165\u6570\u5b57 *)\r\n                gen(sto, lev - level, adr) (* \u751f\u6210sto\u6307\u4ee4\uff0c\u628a\u8bfb\u5165\u7684\u503c\u5b58\u5165\u6307\u5b9a\u53d8\u91cf\u6240\u5728\u7684\u7a7a\u95f4 *)\r\n              end;\r\n            getsym (* \u83b7\u53d6\u4e0b\u4e00\u4e2atoken\uff0c\u5982\u679c\u662f\u9017\u53f7\uff0c\u5219read\u8bed\u8fd8\u6ca1\u5b8c\uff0c\u5426\u5219\u5e94\u5f53\u662f\u53f3\u62ec\u53f7 *)\r\n          until sym &lt;&gt; comma; (* \u4e0d\u65ad\u751f\u6210\u4ee3\u7801\u76f4\u5230read\u8bed\u53e5\u7684\u53c2\u6570\u8868\u4e2d\u7684\u53d8\u91cf\u904d\u5386\u5b8c\u4e3a\u6b62\uff0c\u8fd9\u91cc\u9047\u5230\u4e0d\u662f\u9017\u53f7\uff0c\u5e94\u4e3a\u53f3\u62ec\u53f7 *)\r\n        if sym &lt;&gt; rparen then (* \u5982\u679c\u4e0d\u662f\u6211\u4eec\u9884\u60f3\u4e2d\u7684\u53f3\u62ec\u53f7 *)\r\n        begin\r\n          error(33); (* \u629b\u51fa33\u53f7\u9519\u8bef *)\r\n          while not (sym in fsys) do (* \u4f9d\u9760fsys\u96c6\uff0c\u627e\u5230\u4e0b\u4e00\u4e2a\u5408\u6cd5\u7684token\uff0c\u6062\u590d\u8bed\u6cd5\u5206\u6790 *)\r\n            getsym\r\n        end\r\n        else\r\n          getsym (* \u5982\u679cread\u8bed\u53e5\u6b63\u5e38\u7ed3\u675f\uff0c\u5f97\u5230\u4e0b\u4e00\u4e2atoken\uff0c\u4e00\u822c\u4e3a\u5206\u53f7\u6216end *)\r\n      end\r\n      else\r\n        if sym = writesym then (* \u5982\u679c\u9047\u5230\u4e86write\u8bed\u53e5 *)\r\n        begin\r\n          getsym; (* \u83b7\u53d6\u4e0b\u4e00token\uff0c\u5e94\u4e3a\u5de6\u62ec\u53f7 *)\r\n          if sym = lparen then (* \u5982\u786e\u4e3a\u5de6\u62ec\u53f7 *)\r\n          begin\r\n            repeat (* \u4f9d\u6b21\u83b7\u53d6\u62ec\u53f7\u4e2d\u7684\u6bcf\u4e00\u4e2a\u503c\uff0c\u8fdb\u884c\u8f93\u51fa *)\r\n              getsym; (* \u83b7\u5f97\u4e00\u4e2atoken\uff0c\u8fd9\u91cc\u5e94\u662f\u4e00\u4e2a\u6807\u8bc6\u7b26 *)\r\n              expression([rparen, comma] + fsys); (* \u8c03\u7528expression\u8fc7\u7a0b\u5206\u6790\u8868\u8fbe\u5f0f\uff0c\u7528\u4e8e\u51fa\u9519\u6062\u590d\u7684\u96c6\u5408\u4e2d\u52a0\u4e0a\u53f3\u62ec\u53f7\u548c\u9017\u53f7 *)\r\n              gen(opr, 0, 14) (* \u751f\u621014\u53f7\u6307\u4ee4\uff1a\u5411\u5c4f\u5e55\u8f93\u51fa *)\r\n            until sym &lt;&gt; comma; (* \u5faa\u73af\u76f4\u5230\u9047\u5230\u7684\u4e0d\u518d\u662f\u9017\u53f7\uff0c\u8fd9\u65f6\u5e94\u662f\u53f3\u62ec\u53f7 *)\r\n            if sym &lt;&gt; rparen then (* \u5982\u679c\u4e0d\u662f\u53f3\u62ec\u53f7 *)\r\n              error(33) (* \u629b\u51fa33\u53f7\u9519\u8bef *)\r\n            else\r\n              getsym (* \u6b63\u5e38\u60c5\u51b5\u4e0b\u8981\u83b7\u53d6\u4e0b\u4e00\u4e2atoken\uff0c\u4e3a\u540e\u9762\u51c6\u5907\u597d *)\r\n          end;\r\n          gen(opr, 0, 15) (* \u751f\u6210\u4e00\u4e2a15\u53f7\u64cd\u4f5c\u7684\u76ee\u6807\u4ee3\u7801\uff0c\u529f\u80fd\u662f\u8f93\u51fa\u4e00\u4e2a\u6362\u884c *)\r\n          (* \u7531\u6b64\u53ef\u77e5PL\/0\u4e2d\u7684write\u8bed\u53e5\u4e0ePascal\u4e2d\u7684writeln\u8bed\u53e5\u7c7b\u4f3c\uff0c\u662f\u5e26\u6709\u8f93\u51fa\u6362\u884c\u7684 *)\r\n        end\r\n        else\r\n          if sym = callsym then (* \u5982\u679c\u662fcall\u8bed\u53e5 *)\r\n          begin\r\n            getsym; (* \u83b7\u53d6token\uff0c\u5e94\u662f\u8fc7\u7a0b\u540d\u578b\u6807\u8bc6\u7b26 *)\r\n            if sym &lt;&gt; ident then (* \u5982\u679ccall\u540e\u8ddf\u7684\u4e0d\u662f\u6807\u8bc6\u7b26 *)\r\n              error(14) (* \u629b\u51fa14\u53f7\u9519\u8bef *)\r\n            else\r\n            begin\r\n              i := position(id); (* \u4ece\u7b26\u53f7\u8868\u4e2d\u627e\u51fa\u76f8\u5e94\u7684\u6807\u8bc6\u7b26 *)\r\n              if i = 0 then (* \u5982\u679c\u6ca1\u627e\u5230 *)\r\n                error(11) (* \u629b\u51fa11\u53f7\u9519\u8bef *)\r\n              else\r\n                with table[i] do (* \u5982\u679c\u627e\u5230\u6807\u8bc6\u7b26\u4f4d\u4e8e\u7b26\u53f7\u8868\u7b2ci\u4f4d\u7f6e *)\r\n                  if kind = procedur then (* \u5982\u679c\u8fd9\u4e2a\u6807\u8bc6\u7b26\u4e3a\u4e00\u4e2a\u8fc7\u7a0b\u540d *)\r\n                    gen(cal,lev-level,adr) (* \u751f\u6210cal\u76ee\u6807\u4ee3\u7801\uff0c\u547c\u53eb\u8fd9\u4e2a\u8fc7\u7a0b *)\r\n                  else\r\n                    error(15); (* \u5982\u679ccall\u540e\u8ddf\u7684\u4e0d\u662f\u8fc7\u7a0b\u540d\uff0c\u629b\u51fa15\u53f7\u9519\u8bef *)\r\n              getsym (* \u83b7\u53d6\u4e0b\u4e00token\uff0c\u4e3a\u540e\u9762\u4f5c\u51c6\u5907 *)\r\n            end\r\n          end\r\n        else\r\n          if sym = ifsym then (* \u5982\u679c\u662fif\u8bed\u53e5 *)\r\n          begin\r\n            getsym; (* \u83b7\u53d6\u4e00token\u5e94\u662f\u4e00\u4e2a\u903b\u8f91\u8868\u8fbe\u5f0f *)\r\n            condition([thensym, dosym] + fsys); (* \u5bf9\u903b\u8f91\u8868\u8fbe\u5f0f\u8fdb\u884c\u5206\u6790\u8ba1\u7b97\uff0c\u51fa\u9519\u6062\u590d\u96c6\u4e2d\u52a0\u5165then\u548cdo\u8bed\u53e5 *)\r\n            if sym = thensym then (* \u8868\u8fbe\u5f0f\u540e\u5e94\u9047\u5230then\u8bed\u53e5 *)\r\n              getsym (* \u83b7\u53d6then\u540e\u7684token\uff0c\u5e94\u662f\u4e00\u8bed\u53e5 *)\r\n            else\r\n              error(16); (* \u5982\u679cif\u540e\u6ca1\u6709then\uff0c\u629b\u51fa16\u53f7\u9519\u8bef *)\r\n            cx1 := cx; (* \u8bb0\u4e0b\u5f53\u524d\u4ee3\u7801\u5206\u914d\u6307\u9488\u4f4d\u7f6e *)\r\n            gen(jpc, 0, 0); (* \u751f\u6210\u6761\u4ef6\u8df3\u8f6c\u6307\u4ee4\uff0c\u8df3\u8f6c\u4f4d\u7f6e\u6682\u65f6\u586b0\uff0c\u5206\u6790\u5b8c\u8bed\u53e5\u540e\u518d\u586b\u5199 *)\r\n            statement(fsys); (* \u5206\u6790then\u540e\u7684\u8bed\u53e5 *)\r\n            code[cx1].a:=cx (* \u4e0a\u4e00\u884c\u6307\u4ee4(cx1\u6240\u6307\u7684)\u7684\u8df3\u8f6c\u4f4d\u7f6e\u5e94\u4e3a\u5f53\u524dcx\u6240\u6307\u4f4d\u7f6e *)\r\n          end\r\n          else\r\n            if sym = beginsym then (* \u5982\u679c\u9047\u5230begin *)\r\n            begin\r\n              getsym; (* \u83b7\u53d6\u4e0b\u4e00\u4e2atoken *)\r\n              statement([semicolon, endsym] + fsys);(* \u5bf9begin\u4e0eend\u4e4b\u95f4\u7684\u8bed\u53e5\u8fdb\u884c\u5206\u6790\u5904\u7406 *)\r\n              while sym in [semicolon] + statbegsys do (* \u5982\u679c\u5206\u6790\u5b8c\u4e00\u53e5\u540e\u9047\u5230\u5206\u53f7\u6216\u8bed\u53e5\u5f00\u59cb\u7b26\u5faa\u73af\u5206\u6790\u4e0b\u4e00\u53e5\u8bed\u53e5 *)\r\n              begin\r\n                if sym = semicolon then (* \u5982\u679c\u8bed\u53e5\u662f\u5206\u53f7\uff08\u53ef\u80fd\u662f\u7a7a\u8bed\u53e5\uff09 *)\r\n                  getsym (* \u83b7\u53d6\u4e0b\u4e00token\u7ee7\u7eed\u5206\u6790 *)\r\n                else\r\n                  error(10); (* \u5982\u679c\u8bed\u53e5\u4e0e\u8bed\u53e5\u95f4\u6ca1\u6709\u5206\u53f7\uff0c\u51fa10\u53f7\u9519 *)\r\n                statement([semicolon, endsym] + fsys) (* \u5206\u6790\u4e00\u4e2a\u8bed\u53e5 *)\r\n              end;\r\n              if sym = endsym then (* \u5982\u679c\u8bed\u53e5\u5168\u5206\u6790\u5b8c\u4e86\uff0c\u5e94\u8be5\u9047\u5230end *)\r\n                getsym (* \u7684\u786e\u662fend\uff0c\u8bfb\u4e0b\u4e00token *)\r\n              else\r\n                error(17) (* \u5982\u679c\u4e0d\u662fend\uff0c\u629b\u51fa17\u53f7\u9519 *)\r\n            end\r\n            else\r\n              if sym = whilesym then (* \u5982\u679c\u9047\u5230while\u8bed\u53e5 *)\r\n              begin\r\n                cx1 := cx; (* \u8bb0\u4e0b\u5f53\u524d\u4ee3\u7801\u5206\u914d\u4f4d\u7f6e\uff0c\u8fd9\u662fwhile\u5faa\u73af\u7684\u5f00\u59cb\u4f4d\u7f6e *)\r\n                getsym; (* \u83b7\u53d6\u4e0b\u4e00token\uff0c\u5e94\u4e3a\u4e00\u903b\u8f91\u8868\u8fbe\u5f0f *)\r\n                condition([dosym] + fsys); (* \u5bf9\u8fd9\u4e2a\u903b\u8f91\u8868\u8fbe\u5f0f\u8fdb\u884c\u5206\u6790\u8ba1\u7b97 *)\r\n                cx2 := cx; (* \u8bb0\u4e0b\u5f53\u524d\u4ee3\u7801\u5206\u914d\u4f4d\u7f6e\uff0c\u8fd9\u662fwhile\u7684do\u4e2d\u7684\u8bed\u53e5\u7684\u5f00\u59cb\u4f4d\u7f6e *)\r\n                gen(jpc, 0, 0); (* \u751f\u6210\u6761\u4ef6\u8df3\u8f6c\u6307\u4ee4\uff0c\u8df3\u8f6c\u4f4d\u7f6e\u6682\u65f6\u586b0 *)\r\n                if sym = dosym then (* \u903b\u8f91\u8868\u8fbe\u5f0f\u540e\u5e94\u4e3ado\u8bed\u53e5 *)\r\n                  getsym (* \u83b7\u53d6\u4e0b\u4e00token *)\r\n                else\r\n                  error(18); (* if\u540e\u7f3a\u5c11then\uff0c\u629b\u51fa18\u53f7\u9519\u8bef *)\r\n                statement(fsys); (* \u5206\u6790do\u540e\u7684\u8bed\u53e5\u5757 *)\r\n                gen(jmp, 0, cx1); (* \u5faa\u73af\u8df3\u8f6c\u5230cx1\u4f4d\u7f6e\uff0c\u5373\u518d\u6b21\u8fdb\u884c\u903b\u8f91\u5224\u65ad *)\r\n                code[cx2].a := cx (* \u628a\u521a\u624d\u586b0\u7684\u8df3\u8f6c\u4f4d\u7f6e\u6539\u6210\u5f53\u524d\u4f4d\u7f6e\uff0c\u5b8c\u6210while\u8bed\u53e5\u7684\u5904\u7406 *)\r\n              end;\r\n    test(fsys, [], 19) (* \u81f3\u6b64\u4e00\u4e2a\u8bed\u53e5\u5904\u7406\u5b8c\u6210\uff0c\u4e00\u5b9a\u4f1a\u9047\u5230fsys\u96c6\u4e2d\u7684\u7b26\u53f7\uff0c\u5982\u679c\u6ca1\u6709\u9047\u5230\uff0c\u5c31\u629b19\u53f7\u9519 *)\r\n  end(* statement *);\r\nbegin (* block *)\r\n  dx := 3; (* \u5730\u5740\u6307\u793a\u5668\u7ed9\u51fa\u6bcf\u5c42\u5c40\u90e8\u91cf\u5f53\u524d\u5df2\u5206\u914d\u5230\u7684\u76f8\u5bf9\u4f4d\u7f6e\u3002\r\n              \u7f6e\u521d\u59cb\u503c\u4e3a3\u7684\u539f\u56e0\u662f\uff1a\u6bcf\u4e00\u5c42\u6700\u5f00\u59cb\u7684\u4f4d\u7f6e\u6709\u4e09\u4e2a\u7a7a\u95f4\u7528\u4e8e\u5b58\u653e\u9759\u6001\u94feSL\u3001\u52a8\u6001\u94feDL\u548c\u8fd4\u56de\u5730\u5740RA *)\r\n  tx0 := tx; (* \u521d\u59cb\u7b26\u53f7\u8868\u6307\u9488\u6307\u5411\u5f53\u524d\u5c42\u7684\u7b26\u53f7\u5728\u7b26\u53f7\u8868\u4e2d\u7684\u5f00\u59cb\u4f4d\u7f6e *)\r\n  table[tx].adr := cx; (* \u7b26\u53f7\u8868\u5f53\u524d\u4f4d\u7f6e\u8bb0\u4e0b\u5f53\u524d\u5c42\u4ee3\u7801\u7684\u5f00\u59cb\u4f4d\u7f6e *)\r\n  gen(jmp, 0, 0); (* \u4ea7\u751f\u4e00\u884c\u8df3\u8f6c\u6307\u4ee4\uff0c\u8df3\u8f6c\u4f4d\u7f6e\u6682\u65f6\u672a\u77e5\u586b0 *)\r\n  if lev &gt; levmax then (* \u5982\u679c\u5f53\u524d\u8fc7\u7a0b\u5d4c\u5957\u5c42\u6570\u5927\u4e8e\u6700\u5927\u5141\u8bb8\u7684\u5957\u5c42\u6570 *)\r\n    error(32); (* \u53d1\u51fa32\u53f7\u9519\u8bef *)\r\n  repeat (* \u5f00\u59cb\u5faa\u73af\u5904\u7406\u6e90\u7a0b\u5e8f\u4e2d\u6240\u6709\u7684\u58f0\u660e\u90e8\u5206 *)\r\n    if sym = constsym then (* \u5982\u679c\u5f53\u524dtoken\u662fconst\u4fdd\u7559\u5b57\uff0c\u5f00\u59cb\u8fdb\u884c\u5e38\u91cf\u58f0\u660e *)\r\n    begin\r\n      getsym; (* \u83b7\u53d6\u4e0b\u4e00\u4e2atoken\uff0c\u6b63\u5e38\u5e94\u4e3a\u7528\u4f5c\u5e38\u91cf\u540d\u7684\u6807\u8bc6\u7b26 *)\r\n      repeat (* \u53cd\u590d\u8fdb\u884c\u5e38\u91cf\u58f0\u660e *)\r\n        constdeclaration; (* \u58f0\u660e\u4ee5\u5f53\u524dtoken\u4e3a\u6807\u8bc6\u7b26\u7684\u5e38\u91cf *)\r\n        while sym = comma do (* \u5982\u679c\u9047\u5230\u4e86\u9017\u53f7\u5219\u53cd\u590d\u58f0\u660e\u4e0b\u4e00\u4e2a\u5e38\u91cf *)\r\n        begin\r\n          getsym; (* \u83b7\u53d6\u4e0b\u4e00\u4e2atoken\uff0c\u8fd9\u91cc\u6b63\u597d\u5e94\u8be5\u662f\u6807\u8bc6\u7b26 *)\r\n          constdeclaration (* \u58f0\u660e\u4ee5\u5f53\u524dtoken\u4e3a\u6807\u8bc6\u7b26\u7684\u5e38\u91cf *)\r\n        end;\r\n        if sym = semicolon then (* \u5982\u679c\u5e38\u91cf\u58f0\u660e\u7ed3\u675f\uff0c\u5e94\u9047\u5230\u5206\u53f7 *)\r\n          getsym (* \u83b7\u53d6\u4e0b\u4e00\u4e2atoken\uff0c\u4e3a\u4e0b\u4e00\u8f6e\u5faa\u73af\u505a\u597d\u51c6\u5907 *)\r\n        else\r\n          error(5) (* \u5982\u679c\u5e38\u91cf\u58f0\u660e\u8bed\u53e5\u7ed3\u675f\u540e\u6ca1\u6709\u9047\u5230\u5206\u53f7\u5219\u53d1\u51fa5\u53f7\u9519\u8bef *)\r\n      until sym &lt;&gt; ident (* \u5982\u679c\u9047\u5230\u975e\u6807\u8bc6\u7b26\uff0c\u5219\u5e38\u91cf\u58f0\u660e\u7ed3\u675f *)\r\n    end;\r\n    (* \u6b64\u5904\u7684\u5e38\u91cf\u58f0\u660e\u7684\u8bed\u6cd5\u4e0e\u8bfe\u672c\u4e0a\u7684EBNF\u8303\u5f0f\u6709\u4e0d\u540c\u4e4b\u5904\uff1a\r\n       \u5b83\u53ef\u4ee5\u63a5\u53d7\u50cf\u4e0b\u9762\u7684\u58f0\u660e\u65b9\u6cd5\uff0c\u800c\u6839\u636e\u8bfe\u672c\u4e0a\u7684EBNF\u8303\u5f0f\u4e0d\u53ef\u5f97\u51fa\u4e0b\u9762\u7684\u8bed\u6cd5\uff1a\r\n       const a = 3, b = 3; c = 6; d = 7, e = 8; \r\n       \u5373\u5b83\u53ef\u4ee5\u63a5\u53d7\u5206\u53f7\u6216\u9017\u53f7\u9694\u5f00\u7684\u5e38\u91cf\u58f0\u660e\uff0c\u800c\u6839\u636eEBNF\u8303\u5f0f\u53ea\u53ef\u63a5\u53d7\u7528\u9017\u53f7\u9694\u5f00\u7684\u58f0\u660e *)\r\n    if sym = varsym then (* \u5982\u679c\u5f53\u524dtoken\u662fvar\u4fdd\u7559\u5b57\uff0c\u5f00\u59cb\u8fdb\u884c\u53d8\u91cf\u58f0\u660e,\u4e0e\u5e38\u91cf\u58f0\u660e\u7c7b\u4f3c *)\r\n    begin\r\n      getsym; (* \u83b7\u53d6\u4e0b\u4e00\u4e2atoken\uff0c\u6b64\u5904\u6b63\u5e38\u5e94\u4e3a\u7528\u4f5c\u53d8\u91cf\u540d\u7684\u4e00\u4e2a\u6807\u8bc6\u7b26 *)\r\n      repeat (* \u53cd\u590d\u8fdb\u884c\u53d8\u91cf\u58f0\u660e *)\r\n        vardeclaration; (* \u4ee5\u5f53\u524dtoken\u4e3a\u6807\u8bc6\u7b26\u58f0\u660e\u4e00\u4e2a\u53d8\u91cf *)\r\n        while sym = comma do (* \u5982\u679c\u9047\u5230\u4e86\u9017\u53f7\u5219\u53cd\u590d\u58f0\u660e\u4e0b\u4e00\u4e2a\u53d8\u91cf *)\r\n        begin\r\n          getsym; (* \u83b7\u53d6\u4e0b\u4e00\u4e2atoken\uff0c\u8fd9\u91cc\u6b63\u597d\u5e94\u8be5\u662f\u6807\u8bc6\u7b26 *)\r\n          vardeclaration; (* \u58f0\u660e\u4ee5\u5f53\u524dtoken\u4e3a\u6807\u8bc6\u7b26\u7684\u53d8\u91cf *)\r\n        end;\r\n        if sym = semicolon then (* \u5982\u679c\u53d8\u91cf\u58f0\u660e\u7ed3\u675f\uff0c\u5e94\u9047\u5230\u5206\u53f7 *)\r\n          getsym (* \u83b7\u53d6\u4e0b\u4e00\u4e2atoken\uff0c\u4e3a\u4e0b\u4e00\u8f6e\u5faa\u73af\u505a\u597d\u51c6\u5907 *)\r\n        else\r\n          error(5) (* \u5982\u679c\u53d8\u91cf\u58f0\u660e\u8bed\u53e5\u7ed3\u675f\u540e\u6ca1\u6709\u9047\u5230\u5206\u53f7\u5219\u53d1\u51fa5\u53f7\u9519\u8bef *)\r\n      until sym &lt;&gt; ident; (* \u5982\u679c\u9047\u5230\u975e\u6807\u8bc6\u7b26\uff0c\u5219\u53d8\u91cf\u58f0\u660e\u7ed3\u675f *)\r\n      (* \u8fd9\u91cc\u4e5f\u5b58\u5728\u4e0e\u4e0a\u9762\u7684\u5e38\u91cf\u58f0\u660e\u4e00\u6837\u7684\u6bdb\u75c5\uff1a\u4e0ePL\/0\u7684\u8bed\u6cd5\u89c4\u8303\u6709\u51b2\u7a81\u3002 *)\r\n    end;\r\n    while sym = procsym do (* \u5faa\u73af\u58f0\u660e\u5404\u5b50\u8fc7\u7a0b *)\r\n    begin\r\n      getsym; (* \u83b7\u53d6\u4e0b\u4e00\u4e2atoken\uff0c\u6b64\u5904\u6b63\u5e38\u5e94\u4e3a\u4f5c\u4e3a\u8fc7\u7a0b\u540d\u7684\u6807\u8bc6\u7b26 *)\r\n      if sym = ident then (* \u5982\u679ctoken\u786e\u4e3a\u6807\u8bc6\u7b26 *)\r\n      begin\r\n        enter(procedur); (* \u628a\u8fd9\u4e2a\u8fc7\u7a0b\u767b\u5f55\u5230\u540d\u5b57\u8868\u4e2d *)\r\n        getsym (* \u83b7\u53d6\u4e0b\u4e00\u4e2atoken\uff0c\u6b63\u5e38\u60c5\u51b5\u5e94\u4e3a\u5206\u53f7 *)\r\n      end\r\n      else\r\n        error(4); (* \u5426\u5219\u629b\u51fa4\u53f7\u9519\u8bef *)\r\n      if sym = semicolon then (* \u5982\u679c\u5f53\u524dtoken\u4e3a\u5206\u53f7 *)\r\n        getsym (* \u83b7\u53d6\u4e0b\u4e00\u4e2atoken\uff0c\u51c6\u5907\u8fdb\u884c\u8bed\u6cd5\u5206\u6790\u7684\u9012\u5f52\u8c03\u7528 *)\r\n      else\r\n        error(5); (* \u5426\u5219\u629b\u51fa5\u53f7\u9519\u8bef *)\r\n      block(lev + 1, tx, [semicolon] + fsys); (* \u9012\u5f52\u8c03\u7528\u8bed\u6cd5\u5206\u6790\u8fc7\u7a0b\uff0c\u5f53\u524d\u5c42\u6b21\u52a0\u4e00\uff0c\u540c\u65f6\u4f20\u9012\u8868\u5934\u7d22\u5f15\u3001\u5408\u6cd5\u5355\u8bcd\u7b26 *)\r\n      if sym = semicolon then (* \u9012\u5f52\u8fd4\u56de\u540e\u5f53\u524dtoken\u5e94\u4e3a\u9012\u5f52\u8c03\u7528\u65f6\u7684\u6700\u540e\u4e00\u4e2aend\u540e\u7684\u5206\u53f7 *)\r\n      begin\r\n        getsym; (* \u83b7\u53d6\u4e0b\u4e00\u4e2atoken *)\r\n        test(statbegsys + [ident, procsym], fsys, 6); (* \u68c0\u67e5\u5f53\u524dtoken\u662f\u5426\u5408\u6cd5\uff0c\u4e0d\u5408\u6cd5\u5219\u7528fsys\u6062\u590d\u8bed\u6cd5\u5206\u6790\u540c\u65f6\u629b6\u53f7\u9519 *)\r\n      end\r\n      else\r\n        error(5) (* \u5982\u679c\u8fc7\u7a0b\u58f0\u660e\u540e\u7684\u7b26\u53f7\u4e0d\u662f\u5206\u53f7\uff0c\u629b\u51fa5\u53f7\u9519\u8bef *)\r\n    end;\r\n    test(statbegsys + [ident], declbegsys, 7) (* \u68c0\u67e5\u5f53\u524d\u72b6\u6001\u662f\u5426\u5408\u6cd5\uff0c\u4e0d\u5408\u6cd5\u5219\u7528\u58f0\u660e\u5f00\u59cb\u7b26\u53f7\u4f5c\u51fa\u9519\u6062\u590d\u3001\u629b7\u53f7\u9519 *)\r\n  until not (sym in declbegsys); (* \u76f4\u5230\u58f0\u660e\u6027\u7684\u6e90\u7a0b\u5e8f\u5206\u6790\u5b8c\u6bd5\uff0c\u7ee7\u7eed\u5411\u4e0b\u6267\u884c\uff0c\u5206\u6790\u4e3b\u7a0b\u5e8f *)\r\n  code[table[tx0].adr].a := cx; (* \u628a\u524d\u9762\u751f\u6210\u7684\u8df3\u8f6c\u8bed\u53e5\u7684\u8df3\u8f6c\u4f4d\u7f6e\u6539\u6210\u5f53\u524d\u4f4d\u7f6e *)\r\n  with table[tx0] do (* \u5728\u7b26\u53f7\u8868\u4e2d\u8bb0\u5f55 *)\r\n  begin\r\n    adr := cx; (* \u5730\u5740\u4e3a\u5f53\u524d\u4ee3\u7801\u5206\u914d\u5730\u5740 *)\r\n    size := dx; (* \u957f\u5ea6\u4e3a\u5f53\u524d\u6570\u636e\u4ee3\u5206\u914d\u4f4d\u7f6e *)\r\n  end;\r\n  cx0 := cx; (* \u8bb0\u4e0b\u5f53\u524d\u4ee3\u7801\u5206\u914d\u4f4d\u7f6e *)\r\n  gen(int, 0, dx); (* \u751f\u6210\u5206\u914d\u7a7a\u95f4\u6307\u4ee4\uff0c\u5206\u914ddx\u4e2a\u7a7a\u95f4 *)\r\n  statement([semicolon, endsym] + fsys); (* \u5904\u7406\u5f53\u524d\u9047\u5230\u7684\u8bed\u53e5\u6216\u8bed\u53e5\u5757 *)\r\n  gen(opr, 0, 0); (* \u751f\u6210\u4ece\u5b50\u7a0b\u5e8f\u8fd4\u56de\u64cd\u4f5c\u6307\u4ee4 *)\r\n  test(fsys, [], 8); (* \u7528fsys\u68c0\u67e5\u5f53\u524d\u72b6\u6001\u662f\u5426\u5408\u6cd5\uff0c\u4e0d\u5408\u6cd5\u5219\u629b8\u53f7\u9519 *)\r\n  listcode (* \u5217\u51fa\u672c\u5c42\u7684\u7c7bPCODE\u4ee3\u7801 *)\r\nend(* block *);\r\n(* PL\/0\u7f16\u8bd1\u5668\u4ea7\u751f\u7684\u7c7bPCODE\u76ee\u6807\u4ee3\u7801\u89e3\u91ca\u8fd0\u884c\u8fc7\u7a0binterpret *)\r\nprocedure interpret;\r\nconst \r\n  stacksize = 500; (* \u5e38\u91cf\u5b9a\u4e49\uff0c\u5047\u60f3\u7684\u6808\u5f0f\u8ba1\u7b97\u673a\u6709500\u4e2a\u6808\u5355\u5143 *)\r\nvar \r\n  p, b, t: integer; (* program base topstack registers *) \r\n  (* p\u4e3a\u7a0b\u5e8f\u6307\u4ee4\u6307\u9488\uff0c\u6307\u5411\u4e0b\u4e00\u6761\u8981\u8fd0\u884c\u7684\u4ee3\u7801 *)\r\n  (* b\u4e3a\u57fa\u5740\u6307\u9488\uff0c\u6307\u5411\u6bcf\u4e2a\u8fc7\u7a0b\u88ab\u8c03\u7528\u65f6\u6570\u636e\u533a\u4e2d\u5206\u914d\u7ed9\u5b83\u7684\u5c40\u90e8\u53d8\u91cf\u6570\u636e\u6bb5\u57fa\u5740 *)\r\n  (* t\u4e3a\u6808\u9876\u5bc4\u5b58\u5668\uff0c\u7c7bPCODE\u662f\u5728\u4e00\u79cd\u5047\u60f3\u7684\u6808\u5f0f\u8ba1\u7b97\u4e0a\u8fd0\u884c\u7684\uff0c\u8fd9\u4e2a\u53d8\u91cf\u8bb0\u5f55\u8fd9\u4e2a\u8ba1\u7b97\u673a\u7684\u5f53\u524d\u6808\u9876\u4f4d\u7f6e *)\r\n  i: instruction; (* i\u53d8\u91cf\u4e2d\u5b58\u653e\u5f53\u524d\u5728\u8fd0\u884c\u7684\u6307\u4ee4 *)\r\n  s: array[1..stacksize] of integer; (* datastore *) (* s\u4e3a\u6808\u5f0f\u8ba1\u7b97\u673a\u7684\u6570\u636e\u5185\u5b58\u533a *)\r\n  (* \u901a\u8fc7\u9759\u6001\u94fe\u6c42\u51fa\u6570\u636e\u533a\u57fa\u5730\u5740\u7684\u51fd\u6570base *)\r\n  (* \u53c2\u6570\u8bf4\u660e\uff1al:\u8981\u6c42\u7684\u6570\u636e\u533a\u6240\u5728\u5c42\u4e0e\u5f53\u524d\u5c42\u7684\u5c42\u5dee *)\r\n  (* \u8fd4\u56de\u503c\uff1a\u8981\u6c42\u7684\u6570\u636e\u533a\u57fa\u5740 *)\r\n  function base(l: integer): integer;\r\n  var \r\n    b1: integer;\r\n  begin\r\n    b1 := b; (* find base 1 level down *) (* \u9996\u5148\u4ece\u5f53\u524d\u5c42\u5f00\u59cb *)\r\n    while l &gt; 0 do (* \u5982\u679cl\u5927\u4e8e0\uff0c\u5faa\u73af\u901a\u8fc7\u9759\u6001\u94fe\u5f80\u524d\u627e\u9700\u8981\u7684\u6570\u636e\u533a\u57fa\u5740 *)\r\n    begin\r\n      b1 := s[b1]; (* \u7528\u5f53\u524d\u5c42\u6570\u636e\u533a\u57fa\u5740\u4e2d\u7684\u5185\u5bb9\uff08\u6b63\u597d\u662f\u9759\u6001\u94feSL\u6570\u636e\uff0c\u4e3a\u4e0a\u4e00\u5c42\u7684\u57fa\u5740\uff09\u7684\u4f5c\u4e3a\u65b0\u7684\u5f53\u524d\u5c42\uff0c\u5373\u5411\u4e0a\u627e\u4e86\u4e00\u5c42 *)\r\n      l := l - 1 (* \u5411\u4e0a\u4e86\u4e00\u5c42\uff0cl\u51cf\u4e00 *)\r\n    end;\r\n    base := b1 (* \u628a\u627e\u5230\u7684\u8981\u6c42\u7684\u6570\u636e\u533a\u57fa\u5740\u8fd4\u56de *)\r\n  end(* base *);\r\nbegin\r\n  writeln('start pl0'); (* PL\/0\u7a0b\u5e8f\u5f00\u59cb\u8fd0\u884c *)\r\n  t := 0; (* \u7a0b\u5e8f\u5f00\u59cb\u8fd0\u884c\u65f6\u6808\u9876\u5bc4\u5b58\u5668\u7f6e0 *)\r\n  b := 1; (* \u6570\u636e\u6bb5\u57fa\u5740\u4e3a1 *)\r\n  p := 0; (* \u4ece0\u53f7\u4ee3\u7801\u5f00\u59cb\u6267\u884c\u7a0b\u5e8f *)\r\n  s[1] := 0; \r\n  s[2] := 0;\r\n  s[3] := 0; (* \u6570\u636e\u5185\u5b58\u4e2d\u4e3aSL,DL,RA\u4e09\u4e2a\u5355\u5143\u5747\u4e3a0\uff0c\u6807\u8bc6\u4e3a\u4e3b\u7a0b\u5e8f *)\r\n  repeat (* \u5f00\u59cb\u4f9d\u6b21\u8fd0\u884c\u7a0b\u5e8f\u76ee\u6807\u4ee3\u7801 *)\r\n    i := code[p]; (* \u83b7\u53d6\u4e00\u884c\u76ee\u6807\u4ee3\u7801 *)\r\n    p := p + 1; (* \u6307\u4ee4\u6307\u9488\u52a0\u4e00\uff0c\u6307\u5411\u4e0b\u4e00\u6761\u4ee3\u7801 *)\r\n    with i do \r\n      case f of (* \u5982\u679ci\u7684f\uff0c\u5373\u6307\u4ee4\u52a9\u8bb0\u7b26\u662f\u4e0b\u9762\u7684\u67d0\u79cd\u60c5\u51b5\uff0c\u6267\u884c\u4e0d\u540c\u7684\u529f\u80fd *)\r\n        lit: (* \u5982\u679c\u662flit\u6307\u4ee4 *)\r\n        begin\r\n          t := t + 1; (* \u6808\u9876\u6307\u9488\u4e0a\u79fb\uff0c\u5728\u6808\u4e2d\u5206\u914d\u4e86\u4e00\u4e2a\u5355\u5143 *)\r\n          s[t] := a (* \u8be5\u5355\u5143\u7684\u5185\u5bb9\u5b58\u653ei\u6307\u4ee4\u7684a\u64cd\u4f5c\u6570\uff0c\u5373\u5b9e\u73b0\u4e86\u628a\u5e38\u91cf\u503c\u653e\u5230\u8fd0\u884c\u6808\u6808\u9876 *)\r\n        end;\r\n        opr: (* \u5982\u679c\u662fopr\u6307\u4ee4 *)\r\n          case a of (* operator *) (* \u6839\u636ea\u64cd\u4f5c\u6570\u4e0d\u540c\uff0c\u6267\u884c\u4e0d\u540c\u7684\u64cd\u4f5c *)\r\n            0: (* 0\u53f7\u64cd\u4f5c\u4e3a\u4ece\u5b50\u8fc7\u7a0b\u8fd4\u56de\u64cd\u4f5c *)\r\n            begin (* return *)\r\n              t := b - 1; (* \u91ca\u653e\u8fd9\u6bb5\u5b50\u8fc7\u7a0b\u5360\u7528\u7684\u6570\u636e\u5185\u5b58\u7a7a\u95f4 *)\r\n              p := s[t + 3]; (* \u628a\u6307\u4ee4\u6307\u9488\u53d6\u5230RA\u7684\u503c\uff0c\u6307\u5411\u7684\u662f\u8fd4\u56de\u5730\u5740 *)\r\n              b := s[t + 2] (* \u628a\u6570\u636e\u6bb5\u57fa\u5740\u53d6\u5230DL\u7684\u503c\uff0c\u6307\u5411\u8c03\u7528\u524d\u5b50\u8fc7\u7a0b\u7684\u6570\u636e\u6bb5\u57fa\u5740 *)\r\n            end;\r\n            1: (* 1\u53f7\u64cd\u4f5c\u4e3a\u6808\u9876\u6570\u636e\u53d6\u53cd\u64cd\u4f5c *)\r\n              s[t] := -s[t]; (* \u5bf9\u6808\u9876\u6570\u636e\u8fdb\u884c\u53d6\u53cd *)\r\n            2: (* 2\u53f7\u64cd\u4f5c\u4e3a\u6808\u9876\u4e24\u4e2a\u6570\u636e\u52a0\u6cd5\u64cd\u4f5c *)\r\n            begin\r\n              t := t - 1; (* \u6808\u9876\u6307\u9488\u4e0b\u79fb *) \r\n              s[t] := s[t] + s[t + 1] (* \u628a\u4e24\u5355\u5143\u6570\u636e\u76f8\u52a0\u5b58\u5165\u6808\u9876 *)\r\n            end;\r\n            3: (* 3\u53f7\u64cd\u4f5c\u4e3a\u6808\u9876\u4e24\u4e2a\u6570\u636e\u51cf\u6cd5\u64cd\u4f5c *)\r\n            begin\r\n              t := t - 1; (* \u6808\u9876\u6307\u9488\u4e0b\u79fb *) \r\n              s[t] := s[t] - s[t + 1] (* \u628a\u4e24\u5355\u5143\u6570\u636e\u76f8\u51cf\u5b58\u5165\u6808\u9876 *)\r\n            end;\r\n            4: (* 4\u53f7\u64cd\u4f5c\u4e3a\u6808\u9876\u4e24\u4e2a\u6570\u636e\u4e58\u6cd5\u64cd\u4f5c *)\r\n            begin\r\n              t := t - 1; (* \u6808\u9876\u6307\u9488\u4e0b\u79fb *)\r\n              s[t] := s[t] * s[t + 1] (* \u628a\u4e24\u5355\u5143\u6570\u636e\u76f8\u4e58\u5b58\u5165\u6808\u9876 *)\r\n            end;\r\n            5: (* 5\u53f7\u64cd\u4f5c\u4e3a\u6808\u9876\u4e24\u4e2a\u6570\u636e\u9664\u6cd5\u64cd\u4f5c *)\r\n            begin\r\n              t := t - 1; (* \u6808\u9876\u6307\u9488\u4e0b\u79fb *)\r\n              s[t] := s[t] div s[t + 1] (* \u628a\u4e24\u5355\u5143\u6570\u636e\u76f8\u6574\u9664\u5b58\u5165\u6808\u9876 *)\r\n            end;\r\n            6: (* 6\u53f7\u64cd\u4f5c\u4e3a\u5224\u5947\u64cd\u4f5c *)\r\n              s[t] := ord(odd(s[t])); (* \u6570\u636e\u6808\u9876\u7684\u503c\u662f\u5947\u6570\u5219\u628a\u6808\u9876\u503c\u7f6e1\uff0c\u5426\u5219\u7f6e0 *)\r\n            8: (* 8\u53f7\u64cd\u4f5c\u4e3a\u6808\u9876\u4e24\u4e2a\u6570\u636e\u5224\u7b49\u64cd\u4f5c *)\r\n            begin\r\n              t := t - 1; (* \u6808\u9876\u6307\u9488\u4e0b\u79fb *)\r\n              s[t] := ord(s[t] = s[t + 1]) (* \u5224\u7b49\uff0c\u76f8\u7b49\u6808\u9876\u7f6e1\uff0c\u4e0d\u7b49\u7f6e0 *)\r\n            end;\r\n            9: (* 9\u53f7\u64cd\u4f5c\u4e3a\u6808\u9876\u4e24\u4e2a\u6570\u636e\u5224\u4e0d\u7b49\u64cd\u4f5c *)\r\n            begin\r\n              t := t - 1; (* \u6808\u9876\u6307\u9488\u4e0b\u79fb *)\r\n              s[t] := ord(s[t] &lt;&gt; s[t + 1]) (* \u5224\u4e0d\u7b49\uff0c\u4e0d\u7b49\u6808\u9876\u7f6e1\uff0c\u76f8\u7b49\u7f6e0 *)\r\n            end;\r\n            10: (* 10\u53f7\u64cd\u4f5c\u4e3a\u6808\u9876\u4e24\u4e2a\u6570\u636e\u5224\u5c0f\u4e8e\u64cd\u4f5c *)\r\n            begin\r\n              t := t - 1; (* \u6808\u9876\u6307\u9488\u4e0b\u79fb *)\r\n              s[t] := ord(s[t] &lt; s[t + 1]) (* \u5224\u5c0f\u4e8e\uff0c\u5982\u679c\u4e0b\u9762\u7684\u503c\u5c0f\u4e8e\u4e0a\u9762\u7684\u503c\uff0c\u6808\u9876\u7f6e1\uff0c\u5426\u5219\u7f6e0 *)\r\n            end;\r\n            11: (* 11\u53f7\u64cd\u4f5c\u4e3a\u6808\u9876\u4e24\u4e2a\u6570\u636e\u5224\u5927\u4e8e\u7b49\u4e8e\u64cd\u4f5c *)\r\n            begin\r\n              t := t - 1; (* \u6808\u9876\u6307\u9488\u4e0b\u79fb *)\r\n              s[t] := ord(s[t] &gt;= s[t + 1]) (* \u5224\u5927\u4e8e\u7b49\u4e8e\uff0c\u5982\u679c\u4e0b\u9762\u7684\u503c\u5927\u4e8e\u7b49\u4e8e\u4e0a\u9762\u7684\u503c\uff0c\u6808\u9876\u7f6e1\uff0c\u5426\u5219\u7f6e0 *)\r\n            end;\r\n            12: (* 12\u53f7\u64cd\u4f5c\u4e3a\u6808\u9876\u4e24\u4e2a\u6570\u636e\u5224\u5927\u4e8e\u64cd\u4f5c *)\r\n            begin\r\n              t := t - 1; (* \u6808\u9876\u6307\u9488\u4e0b\u79fb *)\r\n              s[t] := ord(s[t] &gt; s[t + 1]) (* \u5224\u5927\u4e8e\uff0c\u5982\u679c\u4e0b\u9762\u7684\u503c\u5927\u4e8e\u4e0a\u9762\u7684\u503c\uff0c\u6808\u9876\u7f6e1\uff0c\u5426\u5219\u7f6e0 *)\r\n            end;\r\n            13: (* 13\u53f7\u64cd\u4f5c\u4e3a\u6808\u9876\u4e24\u4e2a\u6570\u636e\u5224\u5c0f\u4e8e\u7b49\u4e8e\u64cd\u4f5c *)\r\n            begin\r\n              t := t - 1; (* \u6808\u9876\u6307\u9488\u4e0b\u79fb *)\r\n              s[t] := ord(s[t] &lt;= s[t + 1]) (* \u5224\u5c0f\u4e8e\u7b49\u4e8e\uff0c\u5982\u679c\u4e0b\u9762\u7684\u503c\u5c0f\u4e8e\u7b49\u4e8e\u4e0a\u9762\u7684\u503c\uff0c\u6808\u9876\u7f6e1\uff0c\u5426\u5219\u7f6e0 *)\r\n            end;\r\n            14: (* 14\u53f7\u64cd\u4f5c\u4e3a\u8f93\u51fa\u6808\u9876\u503c\u64cd\u4f5c *)\r\n            begin\r\n              write(s[t]); (* \u8f93\u51fa\u6808\u9876\u503c *)\r\n              write(fa2, s[t]); (* \u540c\u65f6\u6253\u5370\u5230\u6587\u4ef6 *)\r\n              t := t - 1 (* \u6808\u9876\u4e0b\u79fb *)\r\n            end;\r\n            15: (* 15\u53f7\u64cd\u4f5c\u4e3a\u8f93\u51fa\u6362\u884c\u64cd\u4f5c *)\r\n            begin\r\n              writeln; (* \u8f93\u51fa\u6362\u884c *)\r\n              writeln(fa2) (* \u540c\u65f6\u8f93\u51fa\u5230\u6587\u4ef6 *)\r\n            end;\r\n            16: (* 16\u53f7\u64cd\u4f5c\u662f\u63a5\u53d7\u952e\u76d8\u503c\u8f93\u5165\u5230\u6808\u9876 *)\r\n            begin\r\n              t := t + 1; (* \u6808\u9876\u4e0a\u79fb\uff0c\u5206\u914d\u7a7a\u95f4 *)\r\n              write('?'); (* \u5c4f\u663e\u95ee\u53f7 *)\r\n              write(fa2, '?'); (* \u540c\u65f6\u8f93\u51fa\u5230\u6587\u4ef6 *)\r\n              readln(s[t]); (* \u83b7\u5f97\u8f93\u5165 *)\r\n              writeln(fa2, s[t]); (* \u628a\u7528\u6237\u8f93\u5165\u503c\u6253\u5370\u5230\u6587\u4ef6 *)\r\n            end;\r\n          end; (* opr\u6307\u4ee4\u5206\u6790\u8fd0\u884c\u7ed3\u675f *)\r\n        lod: (* \u5982\u679c\u662flod\u6307\u4ee4:\u5c06\u53d8\u91cf\u653e\u5230\u6808\u9876 *)\r\n        begin\r\n          t := t + 1; (* \u6808\u9876\u4e0a\u79fb\uff0c\u5f00\u8f9f\u7a7a\u95f4 *)\r\n          s[t] := s[base(l) + a] (* \u901a\u8fc7\u6570\u636e\u533a\u5c42\u5deel\u548c\u504f\u79fb\u5730\u5740a\u627e\u5230\u53d8\u91cf\u7684\u6570\u636e\uff0c\u5b58\u5165\u4e0a\u9762\u5f00\u8f9f\u7684\u65b0\u7a7a\u95f4\uff08\u5373\u6808\u9876\uff09 *)\r\n        end;\r\n        sto: (* \u5982\u679c\u662fsto\u6307\u4ee4 *)\r\n        begin\r\n          s[base(l) + a] := s[t]; (* \u628a\u6808\u9876\u7684\u503c\u5b58\u5165\u4f4d\u7f6e\u5728\u6570\u636e\u533a\u5c42\u5deel\u504f\u79fb\u5730\u5740a\u7684\u53d8\u91cf\u5185\u5b58 *)\r\n          t := t - 1 (* \u6808\u9879\u4e0b\u79fb\uff0c\u91ca\u653e\u7a7a\u95f4 *)\r\n        end;\r\n        cal: (* \u5982\u679c\u662fcal\u6307\u4ee4 *)\r\n        begin (* generat new block mark *)\r\n          s[t + 1] := base(l); (* \u5728\u6808\u9876\u538b\u5165\u9759\u6001\u94feSL *)\r\n          s[t + 2] := b; (* \u7136\u540e\u538b\u5165\u5f53\u524d\u6570\u636e\u533a\u57fa\u5740\uff0c\u4f5c\u4e3a\u52a8\u6001\u94feDL *)\r\n          s[t + 3] := p; (* \u6700\u540e\u538b\u5165\u5f53\u524d\u7684\u65ad\u70b9\uff0c\u4f5c\u4e3a\u8fd4\u56de\u5730\u5740RA *)\r\n          (* \u4ee5\u4e0a\u7684\u5de5\u4f5c\u5373\u4e3a\u8fc7\u7a0b\u8c03\u7528\u524d\u7684\u4fdd\u62a4\u73b0\u573a *)\r\n          b := t + 1; (* \u628a\u5f53\u524d\u6570\u636e\u533a\u57fa\u5740\u6307\u5411SL\u6240\u5728\u4f4d\u7f6e *)\r\n          p := a; (* \u4ecea\u6240\u6307\u4f4d\u7f6e\u5f00\u59cb\u7ee7\u7eed\u6267\u884c\u6307\u4ee4\uff0c\u5373\u5b9e\u73b0\u4e86\u7a0b\u5e8f\u6267\u884c\u7684\u8df3\u8f6c *)\r\n        end;\r\n        int: (* \u5982\u679c\u662fint\u6307\u4ee4 *)\r\n          t := t + a; (* \u6808\u9876\u4e0a\u79fba\u4e2a\u7a7a\u95f4\uff0c\u5373\u5f00\u8f9fa\u4e2a\u65b0\u7684\u5185\u5b58\u5355\u5143 *)\r\n        jmp: (* \u5982\u679c\u662fjmp\u6307\u4ee4 *)\r\n          p := a; (* \u628ajmp\u6307\u4ee4\u64cd\u4f5c\u6570a\u7684\u503c\u4f5c\u4e3a\u4e0b\u4e00\u6b21\u8981\u6267\u884c\u7684\u6307\u4ee4\u5730\u5740\uff0c\u5b9e\u73b0\u65e0\u6761\u4ef6\u8df3\u8f6c *)\r\n        jpc: (* \u5982\u679c\u662fjpc\u6307\u4ee4 *)\r\n        begin\r\n          if s[t] = 0 then (* \u5224\u65ad\u6808\u9876\u503c *)\r\n            p := a; (* \u5982\u679c\u662f0\u5c31\u8df3\u8f6c\uff0c\u5426\u5219\u4e0d\u8df3\u8f6c *)\r\n          t := t - 1 (* \u91ca\u653e\u6808\u9876\u7a7a\u95f4 *)\r\n        end;\r\n      end(* with,case *)\r\n  until p = 0; (* \u5982\u679cp\u7b49\u4e8e0\uff0c\u610f\u5473\u7740\u5728\u4e3b\u7a0b\u5e8f\u8fd0\u884c\u65f6\u9047\u5230\u4e86\u4ece\u5b50\u7a0b\u5e8f\u8fd4\u56de\u6307\u4ee4\uff0c\u4e5f\u5c31\u662f\u6574\u4e2a\u7a0b\u5e8f\u8fd0\u884c\u7684\u7ed3\u675f *)\r\n  close(fa2) (* \u5173\u95ed\u7528\u4e8e\u8bb0\u5f55\u5c4f\u5e55\u8f93\u5165\u8f93\u51fa\u7684fa2\u6587\u4ef6 *)\r\n  (* PCODE\u4ee3\u7801\u7684\u89e3\u91ca\u6267\u884c\u8fc7\u7a0b\u7ed3\u675f *)\r\nend(* interpret *);\r\nbegin (* main *)\r\n  for ch := ' ' to '!' do (* \u8fd9\u4e2a\u5faa\u73af\u628assym\u6570\u7ec4\u5168\u90e8\u586bnul *)\r\n    ssym[ch] := nul;\r\n  (* changed because of different character set\r\n  note the typos below in the original where\r\n  the alfas were not given the correct space *)\r\n  (* \u4e0b\u9762\u521d\u59cb\u5316\u4fdd\u7559\u5b57\u8868\uff0c\u4fdd\u7559\u5b57\u957f\u5ea6\u4e0d\u523010\u4e2a\u5b57\u7b26\u7684\uff0c\u591a\u4f59\u4f4d\u7f6e\u7528\u7a7a\u683c\u586b\u5145\uff0c\u4fbf\u4e8e\u8bcd\u6cd5\u5206\u6790\u65f6\u4ee5\u4e8c\u5206\u6cd5\u6765\u67e5\u627e\u4fdd\u7559\u5b57 *)\r\n  word[1] := 'begin     ';\r\n  word[2] := 'call      ';\r\n  word[3] := 'const     ';\r\n  word[4] := 'do        ';\r\n  word[5] := 'end       ';\r\n  word[6] := 'if        ';\r\n  word[7] := 'odd       ';\r\n  word[8] := 'procedure ';\r\n  word[9] := 'read      ';\r\n  word[10] := 'then      ';\r\n  word[11] := 'var       ';\r\n  word[12] := 'while     ';\r\n  word[13] := 'write     ';\r\n  (* \u4fdd\u7559\u5b57\u7b26\u53f7\u5217\u8868\uff0c\u5728\u4e0a\u9762\u7684\u4fdd\u7559\u5b57\u8868\u4e2d\u627e\u5230\u4fdd\u7559\u5b57\u540e\u53ef\u4ee5\u672c\u8868\u4e2d\u76f8\u5e94\u4f4d\u7f6e\u8be5\u4fdd\u7559\u5b57\u7684\u7c7b\u578b *)\r\n  wsym[1] := beginsym;\r\n  wsym[2] := callsym;\r\n  wsym[3] := constsym;\r\n  wsym[4] := dosym;\r\n  wsym[5] := endsym;\r\n  wsym[6] := ifsym;\r\n  wsym[7] := oddsym;\r\n  wsym[8] := procsym;\r\n  wsym[9] := readsym;\r\n  wsym[10] := thensym;\r\n  wsym[11] := varsym;\r\n  wsym[12] := whilesym;\r\n  wsym[13] := writesym;\r\n  (* \u521d\u59cb\u5316\u7b26\u53f7\u8868\uff0c\u628a\u53ef\u80fd\u51fa\u73b0\u7684\u7b26\u53f7\u8d4b\u4e0a\u76f8\u5e94\u7684\u7c7b\u578b\uff0c\u5176\u4f59\u7b26\u53f7\u7531\u4e8e\u5f00\u59cb\u5904\u7684\u5faa\u73af\u6240\u8d4b\u7684\u7c7b\u578b\u5747\u4e3anul *)\r\n  ssym['+'] := plus;\r\n  ssym['-'] := minus;\r\n  ssym['*'] := times;\r\n  ssym['\/'] := slash;\r\n  ssym['('] := lparen;\r\n  ssym[')'] := rparen;\r\n  ssym['='] := eql;\r\n  ssym[','] := comma;\r\n  ssym['.'] := period;\r\n  ssym['#'] := neq;\r\n  ssym[';'] := semicolon;\r\n  (* \u521d\u59cb\u5316\u7c7bPCODE\u52a9\u8bb0\u7b26\u8868\uff0c\u8fd9\u4e2a\u8868\u4e3b\u8981\u4f9b\u8f93\u51fa\u7c7bPCODE\u4ee3\u7801\u4e4b\u7528 *)\r\n  mnemonic[lit] := ' lit ';\r\n  mnemonic[opr] := ' opr ';\r\n  mnemonic[lod] := ' lod ';\r\n  mnemonic[sto] := ' sto ';\r\n  mnemonic[cal] := ' cal ';\r\n  mnemonic[int] := ' int ';\r\n  mnemonic[jmp] := ' jmp ';\r\n  mnemonic[jpc] := ' jpc ';\r\n  (* \u6211\u4fee\u6539\u7684\u4ee3\u7801\uff1a\u4e66\u4e0a\u6b64\u5904\u5747\u4e3a'xxx  '\u5f62\u5f0f\uff0c\u5373\u52a9\u8bb0\u7b26\u540e\u4e24\u4e2a\u7a7a\u683c\uff0c\u901a\u8fc7\u4e0a\u7f51\u67e5\u8be2\u539f\u7248\u7a0b\u5e8f\u786e\u8ba4\u4e3a\u52a9\u8bcd\u7b26\u524d\u540e\u5404\u4e00\u7a7a\u683c\u3002 *)\r\n  (* \u8fd9\u6837\u6539\u7684\u76ee\u7684\u662f\u4f7f\u540e\u9762\u7684\u8f93\u51fa\u7ed3\u679c\u6bd4\u8f83\u7f8e\u89c2 *)\r\n  declbegsys := [constsym, varsym, procsym];\r\n  statbegsys := [beginsym, callsym, ifsym, whilesym];\r\n  facbegsys := [ident, number, lparen];\r\n  (* page(output) *)\r\n  (* \u7531\u4e8eTurbo Pascal 7.0\u7684\u6587\u672c\u6587\u4ef6\u5904\u7406\u65b9\u6cd5\u4e0e\u6e90\u7a0b\u5e8f\u4e2d\u4f7f\u7528\u7684\u65b9\u6cd5\u6709\u5f88\u5927\u4e0d\u540c\uff0c\u56e0\u6b64\u4e0b\u9762\u7684\u6709\u5173\u6587\u4ef6\u5904\u7406\u7684\u4ee3\u7801\u8fdb\u884c\u4e86\u4e0d\u5c11\u66f4\u6539\u3002 *)\r\n  assign(fa1, 'fa1.txt'); (* \u628a\u6587\u672c\u6587\u4ef6fa1\u4e0efa1.txt\u6587\u4ef6\u5173\u8054\u8d77\u6765\uff0c\u7528\u4e8e\u8f93\u51fa\u751f\u6210\u7684\u7c7bPCODE\u4ee3\u7801 *)\r\n  rewrite(fa1); (* \u5efa\u7acb\u5e76\u6253\u5f00fa1.txt\u6587\u4ef6 *)\r\n  write('input file?  '); (* \u63d0\u793a\u8f93\u5165PL\/0\u6e90\u7a0b\u5e8f\u540d *)\r\n  write(fa1, 'input file? '); (* \u540c\u6837\u7684\u63d0\u793a\u8f93\u51fa\u5230fa1.txt\u6587\u4ef6 *)\r\n  readln(fname); (* \u83b7\u5f97\u952e\u76d8\u8f93\u5165\u7684\u6587\u4ef6\u540d *)\r\n  writeln(fa1, fname); (* \u628a\u952e\u76d8\u8f93\u5165\u6253\u5370\u5230fa1.txt\u6587\u4ef6 *)\r\n  {openf(fin,fname,'r');}\r\n  assign(fin, fname); (* \u628aPL\/0\u7684\u6e90\u7a0b\u5e8f\u6587\u4ef6\u4e0efin\u5173\u8054 *)\r\n  reset(fin); (* \u6253\u5f00fin\u6240\u5173\u8054\u7684PL\/0\u6e90\u7a0b\u5e8f\u6587\u4ef6 *) \r\n  write('list object code ?'); (* \u63d0\u793a\u662f\u5426\u8981\u5217\u51fa\u7c7bPCODE\u4ee3\u7801 *)\r\n  readln(fname); (* \u83b7\u5f97\u7528\u6237\u8f93\u5165 *)\r\n  write(fa1, 'list object code ?'); (* \u540c\u6837\u7684\u63d0\u793a\u5199\u5230fa1.txt\u6587\u4ef6\u4e2d *)\r\n  listswitch := (fname[1] = 'y'); (* \u5982\u679c\u8f93\u5165'y'\u5f00\u5934\u7684\u5b57\u7b26\u4e32\uff0c\u628alistswitch\u6807\u5fd7\u7f6etrue\uff0c\u5426\u5219\u4e3afalse *)\r\n  err := 0; (* \u51fa\u9519\u6b21\u6570\u7f6e0 *)\r\n  cc := 0; (* \u8bcd\u6cd5\u5206\u6790\u884c\u7f13\u51b2\u533a\u6307\u9488\u7f6e0 *)\r\n  cx := 0; (* \u7c7bPCODE\u4ee3\u7801\u8868\u6307\u9488\u7f6e0 *)\r\n  ll := 0; (* \u8bcd\u6cd5\u5206\u6790\u884c\u7f13\u51b2\u533a\u957f\u5ea6\u7f6e0 *)\r\n  ch := ' '; (* \u8bcd\u6cd5\u5206\u6790\u5f53\u524d\u5b57\u7b26\u4e3a\u7a7a\u683c *)\r\n  kk := al; (* \u7f6ekk\u7684\u503c\u4e3a\u5141\u8bb8\u7684\u6807\u8bc6\u7b26\u7684\u6700\u957f\u957f\u5ea6\uff0c\u5177\u4f53\u7528\u610f\u89c1getsym\u8fc7\u7a0b\u6ce8\u91ca *)\r\n  assign(fa, 'fa.txt'); (* \u628afa.txt\u4e0efa\u5173\u8054\u3002fa\u7528\u4e8e\u8f93\u51fa\u6e90\u7a0b\u5e8f *)\r\n  rewrite(fa); (* \u5efa\u7acb\u5e76\u6253\u5f00fa.txt *)\r\n  getsym; (* \u9996\u6b21\u8c03\u7528\u8bcd\u6cd5\u5206\u6790\u5b50\u7a0b\u5e8f\uff0c\u83b7\u53d6\u6e90\u7a0b\u5e8f\u7684\u7b2c\u4e00\u4e2a\u8bcd\uff08token\uff09 *)\r\n  block(0, 0, [period] + declbegsys + statbegsys); (* \u5f00\u59cb\u8fdb\u884c\u4e3b\u7a0b\u5e8f\uff08\u4e5f\u5c31\u662f\u7b2c\u4e00\u4e2a\u5206\u7a0b\u5e8f\uff09\u7684\u8bed\u6cd5\u5206\u6790 *)\r\n  (* \u4e3b\u7a0b\u5e8f\u6240\u5728\u5c42\u4e3a0\u5c42\uff0c\u7b26\u53f7\u8868\u6682\u65f6\u4e3a\u7a7a\uff0c\u7b26\u53f7\u8868\u6307\u9488\u63070\u53f7\u4f4d\u7f6e *)\r\n  close(fa); (* \u5173\u95ed\u6587\u4ef6 *)\r\n  close(fa1); (* \u5173\u95ed\u6587\u4ef6 *)\r\n  if sym &lt;&gt; period then (* \u4e3b\u7a0b\u5e8f\u5206\u6790\u7ed3\u675f\uff0c\u5e94\u9047\u5230\u8868\u660e\u7a0b\u5e8f\u7ed3\u675f\u7684\u53e5\u53f7 *)\r\n    error(9); (* \u5982\u679c\u4e0d\u662f\u53e5\u53f7\uff0c\u51fa\u73b09\u53f7\u9519\u8bef *)\r\n  (* \u4ee5\u4e0a\u53ef\u77e5\uff0c\u4e00\u4e2a\u5408\u6cd5\u7684PL\/0\u6e90\u7a0b\u5e8f\u5e94\u7531\u5206\u7a0b\u5e8f\u548c\u53e5\u53f7\u6784\u6210\u3002 *)\r\n  if err = 0 then (* \u5982\u679c\u51fa\u9519\u6b21\u6570\u4e3a0\uff0c\u53ef\u4ee5\u5f00\u59cb\u89e3\u91ca\u6267\u884c\u7f16\u8bd1\u4ea7\u751f\u7684\u4ee3\u7801 *)\r\n  begin\r\n    assign(fa2, 'fa2.txt'); (* \u628a\u6587\u672c\u6587\u4ef6fa2\u4e0efa2.txt\u6587\u4ef6\u5173\u8054\u8d77\u6765\uff0c\u7528\u4e8e\u8f93\u51fa\u7c7bPCODE\u4ee3\u7801\u8fd0\u884c\u7ed3\u679c *)\r\n    rewrite(fa2); (* \u5efa\u7acb\u5e76\u6253\u5f00fa2\u6587\u4ef6 *)\r\n    interpret (* \u5f00\u59cb\u89e3\u91ca\u6267\u884c\u7c7bPCODE\u4ee3\u7801 *)\r\n  end\r\n  else\r\n    write('errors in pl\/0 program'); (* \u5982\u679c\u6709\u9519\u8bef\uff0c\u63d0\u793a\u7a0b\u5e8f\u6709\u9519\u8bef *)\r\n  99: (* \u8fd9\u4e2a\u6807\u53f7\u539f\u6765\u662f\u7528\u4e8e\u9000\u51fa\u7a0b\u5e8f\u7684\uff0c\u7531\u4e8eTurbo Pascal\u4e0d\u652f\u6301\u8de8\u8fc7\u7a0b\u7684\u8df3\u8f6c\uff0c\u56e0\u6b64\u8fd9\u91cc\u8fd9\u4e2a\u6807\u53f7\u4e5f\u6ca1\u7528\u4e86\u3002 *)\r\n  {closef(fin);}\r\n  close(fin); (* \u5173\u95ed\u6e90\u7a0b\u5e8f\u6587\u4ef6 *)\r\n  writeln\r\nend.\r\n************************************************************************\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>PL\/0\u8bed\u8a00\u662fPascal\u8bed\u8a00\u7684\u4e00\u4e2a\u5b50\u96c6\uff0c\u6211\u4eec\u8fd9\u91cc\u5206\u6790\u7684PL\/0\u7684\u7f16\u8bd1\u7a0b\u5e8f\u5305\u62ec\u4e86 &hellip; <a href=\"https:\/\/www.freemindworld.com\/blog\/2002\/020815_pl0_analysis.shtml\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,11],"tags":[],"class_list":["post-116","post","type-post","status-publish","format-standard","hentry","category-csdn","category-11"],"_links":{"self":[{"href":"https:\/\/www.freemindworld.com\/blog\/wp-json\/wp\/v2\/posts\/116","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.freemindworld.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.freemindworld.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.freemindworld.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.freemindworld.com\/blog\/wp-json\/wp\/v2\/comments?post=116"}],"version-history":[{"count":0,"href":"https:\/\/www.freemindworld.com\/blog\/wp-json\/wp\/v2\/posts\/116\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.freemindworld.com\/blog\/wp-json\/wp\/v2\/media?parent=116"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.freemindworld.com\/blog\/wp-json\/wp\/v2\/categories?post=116"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.freemindworld.com\/blog\/wp-json\/wp\/v2\/tags?post=116"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}