📄 instruction.cpp
字号:
// Instruction.cpp : implementation file
//
#include "stdafx.h"
#include "PL0.h"
#include "Instruction.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CInstruction dialog
CInstruction::CInstruction(CWnd* pParent /*=NULL*/)
: CDialog(CInstruction::IDD, pParent)
{
//{{AFX_DATA_INIT(CInstruction)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CInstruction::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CInstruction)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CInstruction, CDialog)
//{{AFX_MSG_MAP(CInstruction)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CInstruction message handlers
BOOL CInstruction::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CDialog::OnInitDialog();
CListBox *pLB=(CListBox *)GetDlgItem(IDC_LIST1);
CString text[34];
text[0]+=" 语法说明: " ;
text[1]+="(1) <程序>::=<分程序>.";
text[2]+="(2) <分程序>::=[<常量说明部分>][<变量说明部分>][<过程说明部分>]<语句>";
text[3]+="(3) <常量说明部分>::=const<常量定义>{,<常量定义>};";
text[4]+="(4) <常量定义>::=<标识符>=<整数>";
text[5]+="(5) <整数>::={-|+}<数字>{,<数字>}";
text[6]+="(6) <变量说明部分>::=var<标识符>{,<标识符>};";
text[7]+="(7) <标识符>::=<字母>{<字母>|<数字>}";
text[8]+="(8) <过程说明部分>::=<过程首部><分程序>{;<过程说明部分>};";
text[9]+="(9) <过程首部>::=procedure<标识符>;";
text[10]+="(10) <语句>::=<赋值语句>|<条件语句>|<当型循环语句>|<过程调用语句>|";
text[11]+=" <语句>::=<读语句>|<写语句>|<复合语句>|<空>";
text[12]+="(11) <赋值语句>::=<标识符>:=<表达式>";
text[13]+="(12) <复合语句>::=begin<语句>{;<语句>}end";
text[14]+="(13) <条件>::=<表达式><关系运算符><表达式>|odd<表达式>";
text[15]+="(14) <表达式>::=[+|-]<项>{<加减运算符><项>}";
text[16]+="(15) <项>::=<因子>{<乘除法运算符><因子>}";
text[17]+="(16) <因子>::=<标识符>|<无符号整数>|(<表达式>)";
text[18]+="(17) <加减法运算符>::=+|-";
text[19]+="(18) <乘除法运算符>::=*|/";
text[20]+="(19) <关系运算符>::= =|#|<|<=|>|>=";
text[21]+="(20) <条件运算符号>::=if<条件>then<语句>";
text[22]+="(21) <过程调用语句>::=call<标识符>";
text[23]+="(22) <当型循环语句>::=while<条件>do<标识符";
text[24]+="(23) <读语句>::=read(<标识符>{,<标识符>})";
text[25]+="(24) <写语句>::=write(<表达式>{,<表达式>})";
text[26]+="(25) <字母>::= a|b|c|d|……|X|Y|Z";
text[27]+="(26) <数字>::= 0|1|2|……|8|9";
text[28]+="(27) <注释语句>::= //…… | /*...*/ ";
text[29]+=" 符号的解释:::=表示“定义为”;<>表示语法构造成分(非终结符);";
text[30]+=" |表示或; { }表示可重复选(0或多个);[ ]任选项;( )其内成分优先";
text[31]+=" 文法限制: ";
text[32]+=" (1) 自定义标识符的长度不应超过10 个字符!";
text[33]+=" (2) 编程中函数的嵌套层数不能超过3层!";
for(int i=0;i<34;i++)
pLB->InsertString(-1,text[i]);
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -