⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pascal.gram

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 GRAM
📖 第 1 页 / 共 2 页
字号:
	|	opParamType		prIdentList		COLON { PrintString(":"); }		typeIdentifier	;opParamType:		/* empty */	|	VAR { PrintKeyword("VAR"); }		|	FUNCTION { PrintKeyword("FUNCTION");		SourceError("use procedure type for function parameters"); }	;		/* ************************ Statements *************************** */StatementSequence:		statement	|	StatementSequence SEMICOLON {PrintSemi();} statement	|	error		SEMICOLON { SourceError("statement error"); }		statement		;DelimitedSequence:		statement	;BeginEndBlock:		BEGIN			/* the BEGIN/END isn't needed */		StatementSequence		END		{ EatSpace(); }	;		statement:		opLabel		unlabelledStatement	;opLabel:		/* empty */	|	opLabel NUMBER COLON { PrintConst($2); PrintString(":");		SourceError("no gotos or labels"); }	;unlabelledStatement:		/* empty */	|	Assignment	|	ProcedureCall	|	IfStatement		|	CaseStatement	|	WhileStatement	|	RepeatStatement	|	ForStatement	|	WithStatement	|	GotoStatement	|	BeginEndBlock	;Assignment:		designator ASSIGN		{ PrintString(":="); CheckFunction($1); } expression	;ProcedureCall:		prIdent	|	prIdent ActualParameters	;ActualParameters:		LPAREN { PrintString("("); }		RPAREN { PrintString(")"); }	|	LPAREN { PrintString("("); }		ColonExpList		RPAREN { PrintString(")"); }	;IfStatement:		IF { PrintKeyword("IF");} expression		THEN { PrintKeyword("THEN"); EatSpace();} DelimitedSequence		ElsePart		{ PrintEND(); }	;ElsePart:		/* empty */	|	ELSE { EatSpace(); } ElseIfPart	;ElseIfPart:		IF { PrintKeyword("ELSIF"); } expression		THEN { PrintKeyword("THEN"); EatSpace(); } DelimitedSequence		ElsePart	|		{ PrintKeyword("ELSE"); } DelimitedSequence	;CaseStatement:		CASE		{ PrintKeyword("CASE"); }		expression		OF { PrintKeyword("OF"); AdvanceSpace(); }		lsCaseInstance		END		{ PrintEND(); }	;lsCaseInstance:		caseInstance			|	lsCaseInstance caseInstance	;caseInstance:		{ PrintString("| "); }		ExpList 			/* too general */		COLON { PrintString(":"); EatSpace(); }		DelimitedSequence		SEMICOLON	;WhileStatement:		WHILE		{ PrintKeyword("WHILE"); }		expression		DO { PrintKeyword("DO"); EatSpace(); }		DelimitedSequence		{ PrintEND(); }	;RepeatStatement:		REPEAT { PrintKeyword("REPEAT"); }		StatementSequence		UNTIL { PrintKeyword("UNTIL"); }		expression	;ForStatement:		FOR		{ PrintKeyword("FOR"); }		designator		ASSIGN { PrintString(":="); }		expression		TOpart		DO { PrintKeyword("DO"); EatSpace(); }		DelimitedSequence		{ PrintEND(); }	;TOpart:		TO { PrintKeyword("TO"); }		expression	|	DOWNTO { PrintKeyword("TO"); }		expression		{ PrintKeyword("BY -1"); EnsureSpace(); }	;WithStatement:		WITH		{ PrintKeyword("WITH"); }		WithDesignatorMiddle	;WithDesignatorMiddle:		designator COMMA { PrintString(","); } WithDesignatorMiddle					{ PrintEND(); }	|		designator DO { PrintKeyword("DO"); EatSpace(); }		DelimitedSequence { PrintEND(); }	;GotoStatement:		GOTO { PrintKeyword("GOTO"); }		expression				/* too general */		{ SourceError("no gotos or labels"); }	;/* ************************** expressions ***************************** */factor:		NUMBER { PrintConst($1); }	|	CHARCONST { PrintStringConst($1); }	|	STRCONST { PrintStringConst($1); }	|	setexpr	|	designator	|	designator ActualParameters	|	LPAREN { PrintString("("); }		expression		RPAREN { PrintString(")"); }	|	NOT { PrintKeyword("NOT"); }		factor	;/* ********************************************************************** */designator:		prIdent	|	designator		LBRACKET { PrintString("["); }		ExpList		RBRACKET { PrintString("]"); }	|	designator UPARROW { PrintString("^"); }	|	designator DOT { PrintString("."); }		prIdent	;expression:		SimpleExpression	|	SimpleExpression relation SimpleExpression	;ExpList:		expression	|	ExpList		COMMA { PrintString(","); }		expression	;ColonExpList:				/* for parameter lists */		expression		opColonParam	|	ColonExpList		COMMA { PrintString(","); }		expression		opColonParam	;	/* opColonParam allows format stuff on write statements to be parsed */opColonParam:		/* empty */	|	opColonParamHeader opColonParam	|	opColonParamHeader prIdent opColonParam	;opColonParamHeader:		COLON { PrintString(":"); } expression	;setexpr:		LBRACKET { PrintString("{"); }		oplsElement		RBRACKET { PrintString("}"); }	|	prIdent		LBRACE { PrintString("{"); }		oplsElement		RBRACE { PrintString("}"); }	;oplsElement:		/* empty */	|	ElementList	;/*Token*/MulOperator:		ASTERISK { PrintString("*"); }	|	SLASH { PrintString("/"); }	|	DIV { PrintKeyword("DIV"); }	|	MOD { PrintKeyword("MOD"); }	|	AND { PrintKeyword("AND"); }	;/*Token*/AddOperator:		PLUS { PrintString("+"); }	|	MINUS { PrintString("-"); }	|	OR { PrintKeyword("OR"); }	;/*Token*/relation:		EQUALS { PrintString("="); }	|	NOTEQUAL { PrintString("<>"); }	|	LESS { PrintString("<"); }	|	LSEQUAL { PrintString("<="); }	|	GREATER { PrintString(">"); }	|	GREQUAL { PrintString(">="); }	|	IN { PrintKeyword("IN"); }	;Element:		expression	|	expression		DOTDOT { PrintString(".."); }		expression	;ElementList:		Element	|	ElementList		COMMA { PrintString(","); }		Element	;term:		factor	|	term MulOperator factor	;SimpleExpression:		lsAddTerm	|	PLUS { PrintString("+"); }		lsAddTerm	|	MINUS { PrintString("-"); }		lsAddTerm	;lsAddTerm:		term	|	lsAddTerm AddOperator term	;PlusMinus:		PLUS { PrintString("+"); }	|	MINUS { PrintString("-"); }	;/* ************************** identifiers **************************** */typeIdentifier:		prIdent	;/*Symbol*/prIdent:		ident { PrintIdent($1);}	;zoplsIdent:		/* empty */	|	LPAREN IdentList RPAREN	;prIdentList:		prIdent	|	prIdentList		COMMA { PrintString(","); }		prIdent	;IdentList:		ident	|	IdentList COMMA ident	;/*String*/ident:		IDENT	;/* **************************** constants ******************************** */constant:		NUMBER { PrintConst($1); }		|	PlusMinus		NUMBER { PrintConst($2); }	|	CHARCONST { PrintStringConst($1); }	|	STRCONST { PrintStringConst($1); }	|	PlusMinus		prIdent	|	prIdent	;/* ***********************  Translation hacks  *************************** */exportIdent:		prIdent		{ CheckExport($1); }	;varIdentList:		exportIdent	|	varIdentList		COMMA { PrintString(","); }		exportIdent	;%%PrintEND(){	PrintSemi();	PrintKeyword("END");	PrintSemi();}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -