ExampleCGImpl.mesa
Copyright Ó 1987 by Xerox Corporation. All rights reserved.
Generated by BJackson.pa at April 22, 1987 2:16:54 am PDT
using ThreeCasabaFour [1.1] of April 14, 1987 6:34:07 pm PDT
DIRECTORY
ExampleBaseDef,
ExampleCGDef USING[],
ExampleATDef,
ExampleAGDef,
ThreeC4Support,
ExampleGenericDef;
ExampleCGImpl: CEDAR PROGRAM IMPORTS ExampleAGDef EXPORTS ExampleCGDef=
BEGIN
OPEN ExampleBaseDef, ExampleATDef, ExampleAGDef, ThreeC4Support, ExampleGenericDef;
ExampleCGLinkProc: PUBLIC PROC[prodLinkArray: SeeProdLinkArray, tknLinkArray: TokenLinkArray] =
BEGIN
prodLinkArray[0] ← Seemaingoal;
prodLinkArray[1] ← Seesumprod;
prodLinkArray[2] ← Seesumplus;
prodLinkArray[3] ← Seesumminus;
prodLinkArray[4] ← Seeproductprim;
prodLinkArray[5] ← Seeproductmult;
prodLinkArray[6] ← Seeproductdiv;
prodLinkArray[7] ← Seeprimitivenumber;
prodLinkArray[8] ← Seeprimitiveloc;
prodLinkArray[9] ← Seeprimitivesignal;
prodLinkArray[10] ← Seeprimitiveparen;
END;
Seemaingoal: PROC[nodes: LIST OF REF ANY, position: INT, length: INT]
RETURNS[LIST OF REF ANY] =
BEGIN
stack: LIST OF REF ANY ← nodes;
sum: ExpressionNode;
sum ← NARROW[stack.first];
stack ← stack.rest;
stack ← CONS[sum, stack];
RETURN[stack]
END;
Seesumprod: PROC[nodes: LIST OF REF ANY, position: INT, length: INT]
RETURNS[LIST OF REF ANY] =
BEGIN
stack: LIST OF REF ANY ← nodes;
product: ExpressionNode;
product ← NARROW[stack.first];
stack ← stack.rest;
stack ← CONS[product, stack];
RETURN[stack]
END;
Seesumplus: PROC[nodes: LIST OF REF ANY, position: INT, length: INT]
RETURNS[LIST OF REF ANY] =
BEGIN
stack: LIST OF REF ANY ← nodes;
sum: ExpressionNode;
product: ExpressionNode;
product ← NARROW[stack.first];
stack ← stack.rest;
sum ← NARROW[stack.first];
stack ← stack.rest;
stack ← CONS[BuildExpressionbinProdNode[position, length, sum, Op.plus, product], stack];
RETURN[stack]
END;
Seesumminus: PROC[nodes: LIST OF REF ANY, position: INT, length: INT]
RETURNS[LIST OF REF ANY] =
BEGIN
stack: LIST OF REF ANY ← nodes;
sum: ExpressionNode;
product: ExpressionNode;
product ← NARROW[stack.first];
stack ← stack.rest;
sum ← NARROW[stack.first];
stack ← stack.rest;
stack ← CONS[BuildExpressionbinProdNode[position, length, sum, Op.minus, product], stack];
RETURN[stack]
END;
Seeproductprim: PROC[nodes: LIST OF REF ANY, position: INT, length: INT]
RETURNS[LIST OF REF ANY] =
BEGIN
stack: LIST OF REF ANY ← nodes;
primitive: ExpressionNode;
primitive ← NARROW[stack.first];
stack ← stack.rest;
stack ← CONS[primitive, stack];
RETURN[stack]
END;
Seeproductmult: PROC[nodes: LIST OF REF ANY, position: INT, length: INT]
RETURNS[LIST OF REF ANY] =
BEGIN
stack: LIST OF REF ANY ← nodes;
product: ExpressionNode;
primitive: ExpressionNode;
primitive ← NARROW[stack.first];
stack ← stack.rest;
product ← NARROW[stack.first];
stack ← stack.rest;
stack ← CONS[BuildExpressionbinProdNode[position, length, product, Op.mult, primitive], stack];
RETURN[stack]
END;
Seeproductdiv: PROC[nodes: LIST OF REF ANY, position: INT, length: INT]
RETURNS[LIST OF REF ANY] =
BEGIN
stack: LIST OF REF ANY ← nodes;
product: ExpressionNode;
primitive: ExpressionNode;
primitive ← NARROW[stack.first];
stack ← stack.rest;
product ← NARROW[stack.first];
stack ← stack.rest;
stack ← CONS[BuildExpressionbinProdNode[position, length, product, Op.div, primitive], stack];
RETURN[stack]
END;
Seeprimitivenumber: PROC[nodes: LIST OF REF ANY, position: INT, length: INT]
RETURNS[LIST OF REF ANY] =
BEGIN
stack: LIST OF REF ANY ← nodes;
number: numberNode;
number ← NARROW[stack.first];
stack ← stack.rest;
stack ← CONS[BuildExpressionnumberProdNode[position, length, number], stack];
RETURN[stack]
END;
Seeprimitiveloc: PROC[nodes: LIST OF REF ANY, position: INT, length: INT]
RETURNS[LIST OF REF ANY] =
BEGIN
stack: LIST OF REF ANY ← nodes;
stack ← CONS[BuildExpressionlocProdNode[position, length], stack];
RETURN[stack]
END;
Seeprimitivesignal: PROC[nodes: LIST OF REF ANY, position: INT, length: INT]
RETURNS[LIST OF REF ANY] =
BEGIN
stack: LIST OF REF ANY ← nodes;
stack ← CONS[BuildExpressionsignalProdNode[position, length], stack];
RETURN[stack]
END;
Seeprimitiveparen: PROC[nodes: LIST OF REF ANY, position: INT, length: INT]
RETURNS[LIST OF REF ANY] =
BEGIN
stack: LIST OF REF ANY ← nodes;
sum: ExpressionNode;
sum ← NARROW[stack.first];
stack ← stack.rest;
stack ← CONS[sum, stack];
RETURN[stack]
END;
END..