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

📄 mod2.gram

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 GRAM
📖 第 1 页 / 共 2 页
字号:
	|	EXIT				{ $$ = ExitStmtNode(); }	    /* The following two rules will shift/reduce conflict because */	    /* semicolons are optional between statements (see semicolon  */	    /* production) to assist error recovery. */	|	RETURN				{ $$ = ReturnStmtNode(0); }	|	RETURN expression				{ $$ = ReturnStmtNode($2); }	|	error				{ $$ = 0; }	;ActualParameters:		LPAREN RPAREN				{ $$ = AddToExprList(0,0); }	|	LPAREN ExpList RPAREN				{ $$ = $2; }	;factor:		CARDCONST				{ $$ = ConstExprNode($1); }	|	REALCONST				{ $$ = ConstExprNode($1); }	|	CHARCONST				{ $$ = ConstExprNode($1); }	|	STRCONST				{ $$ = ConstExprNode($1); }	|	BOOLCONST				{ $$ = ConstExprNode($1); }	|	setexpr				/*=*/	|	designator				/*=*/	|	designator ActualParameters				{ $$ = FuncExprNode($1,$2); }	|	LPAREN expression RPAREN				{ $$ = $2; }	|	NOT factor				{ $$ = UnOpExprNode(NOT,$2); }	|	PLUS factor				{ $$ = UnOpExprNode(PLUS,$2); }	|	MINUS factor				{ $$ = UnOpExprNode(MINUS,$2); }	;SimpleExpression:		factor				/*=*/	|	SimpleExpression ASTERISK SimpleExpression				{ $$ = BinOpExprNode(ASTERISK,$1,$3); }	|	SimpleExpression SLASH SimpleExpression				{ $$ = BinOpExprNode(SLASH,$1,$3); }	|	SimpleExpression DIV SimpleExpression				{ $$ = BinOpExprNode(DIV,$1,$3); }	|	SimpleExpression MOD SimpleExpression				{ $$ = BinOpExprNode(MOD,$1,$3); }	|	SimpleExpression PLUS SimpleExpression				{ $$ = BinOpExprNode(PLUS,$1,$3); }	|	SimpleExpression MINUS SimpleExpression				{ $$ = BinOpExprNode(MINUS,$1,$3); }	|	SimpleExpression AND SimpleExpression				{ $$ = BinOpExprNode(AND,$1,$3); }	|	SimpleExpression AMPERSAND SimpleExpression				{ $$ = BinOpExprNode(AMPERSAND,$1,$3); }	|	SimpleExpression OR SimpleExpression				{ $$ = BinOpExprNode(OR,$1,$3); }	;expression:		SimpleExpression				/*=*/	|	SimpleExpression relation SimpleExpression				{ $$ = BinOpExprNode($2,$1,$3); }	;ExpList:		expression				{ $$ = AddToExprList(0,$1); }	|	ExpList COMMA expression				{ $$ = AddToExprList($1,$3); }	;designatorx:		qualident LBRACKET ExpList RBRACKET 				{ $$ = SubscriptExprNode(SymExprNode($1),$3); }	|	designatorx LBRACKET ExpList RBRACKET 				{ $$ = SubscriptExprNode($1,$3); }	|	qualident UPARROW				{ $$ = DerefExprNode(SymExprNode($1)); }	|	designatorx UPARROW				{ $$ = DerefExprNode($1); }	|	designatorx DOT ident				{ $$ = DotExprNode($1,$3); }	;designator:		qualident				{ $$ = SymExprNode($1); }	|	designatorx				/*=*/	;VariableDeclaration:		IdentList COLON type semicolon				{ DefineVarList($1,$3,VAR); }	|	ATEXTERNAL IdentList COLON type semicolon				{ DefineVarList($2,$4,ATEXTERNAL); }	|	error SEMICOLON;				/**/	;seqVariableDeclaration:		/* empty */				/**/	|	seqVariableDeclaration VariableDeclaration				/**/	;oplsFormals:		/* empty */				{ $$ = 0; }	|	varFormalType				/*=*/	|	oplsFormals COMMA varFormalType				{ $$ = AppendParamList($1,$3); }	;varFormalType:		FormalType				{ $$ = MakeParamList(0,0,$1); }	|	VAR FormalType				{ $$ = MakeParamList(VAR,0,$2); }	;ProcedureType:		PROCEDURE				{ $$ = procTypeNode; }	|	PROCEDURE LPAREN oplsFormals RPAREN				{ $$ = ProcType($3,0); }	|	PROCEDURE LPAREN oplsFormals RPAREN COLON qualident				{ $$ = ProcType($3,TypeOf($6)); }	;PointerCheckType:		/* empty */				{ $$ = POINTER; }	|	ATPASCAL				{ $$ = ATPASCAL; }	|	ATC				{ $$ = ATC; }	|	ATNONE				{ $$ = ATNONE; }	|	ATNIL				{ $$ = ATNIL; }	;PointerType:		/* The following rules will reduce/reduce conflict since    */		/* type->SimpleType->qualident->ident. The first rule will  */		/* reduced because it comes first.  The conflict exists     */		/* because normally we want to find out what the to type is,*/		/* but if it is an ident, it may not be defined yet. */		POINTER PointerCheckType TO ident				{ $$ = PointerForwardType($4,$2); }	|	POINTER PointerCheckType TO type				{ $$ = PointerType($4,$2); }	;SetType:		SET OF SimpleType				{ $$ = SetType($3); }	;ConstElement:		ConstExpression				{ $$ = MakeConstSet($1,0); }	|	ConstExpression DOTDOT ConstExpression				{ $$ = MakeConstSet($1,$3); }	;ConstElementList:		ConstElement				{ $$ = AddToConstSetList(0,$1); }	|	ConstElementList COMMA ConstElement				{ $$ = AddToConstSetList($1,$3); }	;Element:		expression				{ $$ = MakeExprSet($1,0); }	|	expression DOTDOT expression				{ $$ = MakeExprSet($1,$3); }	;ElementList:		Element				{ $$ = AddToExprSetList(0,$1); }	|	ElementList COMMA Element				{ $$ = AddToExprSetList($1,$3); }	;variant:		/* empty */				{ $$ = 0; }	|	ConstElementList COLON FieldListSequence				{ $$ = MakeVariant($1,$3); }	;FieldList:		/* empty */				{ $$ = AddToFieldList(0,0); }	|	IdentList COLON type				{ $$ = MakeFieldList($1,$3); }	|	CASE qualident OF seqVariant opFormELSE END				{ $$ = MakeVariantField(0,TypeOf($2),$4,$5); }	|	CASE ident COLON qualident OF seqVariant opFormELSE END				{ $$ = MakeVariantField($2,TypeOf($4),$6,$7); }	;seqVariant:		variant				{ $$ = AddToVariantList(0,$1); }	|	seqVariant BAR variant				{ $$ = AddToVariantList($1,$3); }	;opFormELSE:		/* empty */				{ $$ = 0; }	|	ELSE FieldListSequence				{ $$ = MakeVariant(0,$2); }	;FieldListSequence:		FieldList				/*=*/	|	FieldListSequence SEMICOLON FieldList				{ $$ = AppendFieldList($1,$3); }	;RecordType:		RECORD FieldListSequence END				{ $$ = RecordType($2); }	;array:		ARRAY				{ $$ = ARRAY; }	|	ATDYNARRAY				{ $$ = ATDYNARRAY; }	|	ATSUBARRAY				{ $$ = ATSUBARRAY; }	;ArrayType:		ARRAY SimpleType ArrayElementPart				{ $$ = ArrayType($2,$3,ARRAY,0); }	|	array OF qualident				{ $$ = ArrayType(0,TypeOf($3),$1,0); }	|	array ATNOCOUNT OF qualident				{ $$ = ArrayType(0,TypeOf($4),$1,ATNOCOUNT); }	;ArrayElementPart:		OF type				{ $$ = $2; }	|	COMMA SimpleType ArrayElementPart		/* Right recursion is important for multidimensional arrays */				{ $$ = ArrayType($2,$3,ARRAY,0); }	;SubrangeType:		LBRACKET ConstExpression DOTDOT ConstExpression RBRACKET				{ $$ = SubrangeType($2,$4); }	;IdentList:		ident				{ $$ = AddToIdentList(0,MakeIdent($1)); }	|	IdentList COMMA ident				{ $$ = AddToIdentList($1,MakeIdent($3)); }	;enumeration:		LPAREN IdentList RPAREN				{ $$ =  EnumerationType($2); }	;SimpleType:		qualident				{ $$ = TypeOf($1); }	|	enumeration				/*=*/	|	SubrangeType				/*=*/	;type:		SimpleType				/*=*/	|	ArrayType				/*=*/	|	RecordType				/*=*/	|	SetType				/*=*/	|	PointerType				/*=*/	|	ProcedureType				/*=*/	|	ATSIZE ConstExpression type				{ $$ = TypeWithSize($3,$2); }	|	ATALIGN ConstExpression type				{ $$ = TypeWithAlign($3,$2); }	;TypeDeclaration:		ident EQUALS type SEMICOLON				{ DefineType($1,$3); }	|	error SEMICOLON				/**/	;seqTypeDeclaration:		/* empty */				/**/	|	seqTypeDeclaration TypeDeclaration				/**/	;setconst:		LBRACE oplsConstElement RBRACE				{ $$ = SetConst($2,0); }	|	qualident LBRACE oplsConstElement RBRACE				{ $$ = SetConst($3,TypeOf($1)); }	;oplsConstElement:		/* empty */				{ $$ = 0; }	|	ConstElementList				/*=*/	;setexpr:		LBRACE oplsElement RBRACE				{ $$ = SetExprNode($2,0); }	|	qualident LBRACE oplsElement RBRACE				{ $$ = SetExprNode($3,$1); }	;oplsElement:		/* empty */				{ $$ = 0; }	|	ElementList				/*=*/	;ConstFactor:		qualident				{ $$ = SymConst($1); }	|	CARDCONST				/*=*/	|	REALCONST				/*=*/	|	CHARCONST				/*=*/	|	STRCONST				/*=*/	|	BOOLCONST				/*=*/	|	setconst				/*=*/	|	LPAREN ConstExpression RPAREN				{ $$ = $2; }	|	NOT ConstFactor				{ $$ = UnOpConst(NOT,$2); }	|	PLUS ConstFactor				{ $$ = UnOpConst(PLUS,$2); }	|	MINUS ConstFactor				{ $$ = UnOpConst(MINUS,$2); }	;/*ConstNode*/SimpleConstExpr:		ConstFactor				/*=*/	|	SimpleConstExpr ASTERISK SimpleConstExpr				{ $$ = BinOpConst(ASTERISK,$1,$3,0); }	|	SimpleConstExpr SLASH SimpleConstExpr				{ $$ = BinOpConst(SLASH,$1,$3,0); }	|	SimpleConstExpr DIV SimpleConstExpr				{ $$ = BinOpConst(DIV,$1,$3,0); }	|	SimpleConstExpr MOD SimpleConstExpr				{ $$ = BinOpConst(MOD,$1,$3,0); }	|	SimpleConstExpr PLUS SimpleConstExpr				{ $$ = BinOpConst(PLUS,$1,$3,0); }	|	SimpleConstExpr MINUS SimpleConstExpr				{ $$ = BinOpConst(MINUS,$1,$3,0); }	|	SimpleConstExpr AND SimpleConstExpr				{ $$ = BinOpConst(AND,$1,$3,0); }	|	SimpleConstExpr AMPERSAND SimpleConstExpr				{ $$ = BinOpConst(AMPERSAND,$1,$3,0); }	|	SimpleConstExpr OR SimpleConstExpr				{ $$ = BinOpConst(OR,$1,$3,0); }	;/*Token*/relation:		EQUALS				{ $$ = EQUALS; }	|	SHARP				{ $$ = SHARP; }	|	NOTEQUAL				{ $$ = NOTEQUAL; }	|	LESS				{ $$ = LESS; }	|	LSEQUAL				{ $$ = LSEQUAL; }	|	GREATER				{ $$ = GREATER; }	|	GREQUAL				{ $$ = GREQUAL; }	|	IN				{ $$ = IN; }	;/*ConstNode*/ConstExpression:		SimpleConstExpr				/*=*/	|	SimpleConstExpr relation SimpleConstExpr				{ $$ = BinOpConst($2,$1,$3,0); }	;ConstantDeclaration:		ident EQUALS ConstExpression SEMICOLON				{ DefineConst($1,$3); }	|	error SEMICOLON				/**/	;seqConstantDeclaration:		/* empty */				/**/	|	seqConstantDeclaration ConstantDeclaration				/**/	;/*Symbol*/qualident:		ident				{ $$ = AddToIdentList(0,MakeIdent($1)); }	|	qualident DOT ident				{ $$ = AddToIdentList($1,MakeIdent($3)); }	;/*String*/ident:		IDENT				/*=*/	;/*String*/ENDident:		END IDENT				{ $$ = $2; }	|		END				{ ErrorMissingIdent(); $$ = 0; }	;moduleDOT:		DOT	|		/* empty */				{ ErrorModuleDot(); }	|		SEMICOLON				{ ErrorModuleDot(); }	;semicolon:		SEMICOLON	|		/*empty*/				{ ErrorMissingSemicolon(); }	;

⌨️ 快捷键说明

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