Exemple #1
0
	void Imperative_num(out ProtoCore.AST.ImperativeAST.ImperativeNode node) {
		node = null; 
		int sign = 1;
		int line = ProtoCore.DSASM.Constants.kInvalidIndex; int col = ProtoCore.DSASM.Constants.kInvalidIndex;
		
		if (la.kind == 15) {
			Get();
			sign = -1;
			line = t.line; 
			col = t.col; 
			
		}
		if (la.kind == 2) {
			Get();
			Int64 value;
			if (Int64.TryParse(t.val, System.Globalization.NumberStyles.Number, System.Globalization.CultureInfo.InvariantCulture, out value))
			{
			   node = new ProtoCore.AST.ImperativeAST.IntNode(value * sign);
			}
			else
			{
			   node = new ProtoCore.AST.ImperativeAST.NullNode();
			}
			
			if (ProtoCore.DSASM.Constants.kInvalidIndex != line)
			{
			   node.line = line; node.col = col; 
			}
			else
			{
			   NodeUtils.SetNodeLocation(node, t); 
			}
			
		} else if (la.kind == 3) {
			Get();
			double value;
			if (Double.TryParse(t.val, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out value))
			{
			   node = new ProtoCore.AST.ImperativeAST.DoubleNode(value * sign);
			}
			else
			{
			   node = new ProtoCore.AST.ImperativeAST.NullNode();
			}
			
			if (ProtoCore.DSASM.Constants.kInvalidIndex != line){
			   node.line = line; node.col = col; }
			else{
			   NodeUtils.SetNodeLocation(node, t); }
			
		} else SynErr(123);
	}
Exemple #2
0
 void Imperative_factor(out ProtoCore.AST.ImperativeAST.ImperativeNode node)
 {
     node = null;
     if (IsNumber()) {
     Imperative_num(out node);
     } else if (la.kind == 5) {
     Imperative_Char(out node);
     } else if (la.kind == 4) {
     Imperative_String(out node);
     } else if (la.kind == 40) {
     Get();
     node = new ProtoCore.AST.ImperativeAST.BooleanNode() { value = ProtoCore.DSASM.Literal.True }; NodeUtils.SetNodeLocation(node, t);
     } else if (la.kind == 41) {
     Get();
     node = new ProtoCore.AST.ImperativeAST.BooleanNode() { value = ProtoCore.DSASM.Literal.False }; NodeUtils.SetNodeLocation(node, t);
     } else if (la.kind == 42) {
     Get();
     node = new ProtoCore.AST.ImperativeAST.NullNode(); NodeUtils.SetNodeLocation(node, t);
     } else if (la.kind == 1 || la.kind == 9 || la.kind == 44) {
     Imperative_IdentifierList(out node);
     } else if (StartOf(23)) {
     Imperative_unaryexpr(out node);
     } else SynErr(119);
 }
Exemple #3
0
	void Imperative_factor(out ProtoCore.AST.ImperativeAST.ImperativeNode node) {
		node = null; 
		if (IsNumber()) {
			Imperative_num(out node);
		} else if (la.kind == 5) {
			Imperative_Char(out node);
		} else if (la.kind == 4) {
			Imperative_String(out node);
		} else if (la.kind == 41) {
			Get();
			node = new ProtoCore.AST.ImperativeAST.BooleanNode(true);
			NodeUtils.SetNodeLocation(node, t); 
			
		} else if (la.kind == 42) {
			Get();
			node = new ProtoCore.AST.ImperativeAST.BooleanNode(false); 
			NodeUtils.SetNodeLocation(node, t); 
			
		} else if (la.kind == 43) {
			Get();
			node = new ProtoCore.AST.ImperativeAST.NullNode(); 
			NodeUtils.SetNodeLocation(node, t); 
			
		} else if (la.kind == 1 || la.kind == 12 || la.kind == 45) {
			Imperative_IdentifierList(out node);
		} else if (la.kind == 14 || la.kind == 15 || la.kind == 63) {
			Imperative_unaryexpr(out node);
		} else SynErr(117);
	}
Exemple #4
0
	void Imperative_num(out ProtoCore.AST.ImperativeAST.ImperativeNode node) {
		node = null; 
		int sign = 1;
		int line = ProtoCore.DSASM.Constants.kInvalidIndex; int col = ProtoCore.DSASM.Constants.kInvalidIndex;
		
		if (la.kind == 13) {
			Get();
			sign = -1;
			line = t.line; 
			col = t.col; 
			
		}
		if (la.kind == 2) {
			Get();
			Int64 value;
			if (Int64.TryParse(t.val, out value))
			{
			   node = new ProtoCore.AST.ImperativeAST.IntNode(value * sign);
			}
			else
			{
			   node = new ProtoCore.AST.ImperativeAST.NullNode();
			}
			
			if (ProtoCore.DSASM.Constants.kInvalidIndex != line)
			{
			   node.line = line; node.col = col; 
			}
			else
			{
			   NodeUtils.SetNodeLocation(node, t); 
			}
			
		} else if (la.kind == 3) {
			Get();
			double value;
			if (Double.TryParse(t.val, out value))
			{
			   node = new ProtoCore.AST.ImperativeAST.DoubleNode(value * sign);
			}
			else
			{
			   node = new ProtoCore.AST.ImperativeAST.NullNode();
			}
			
			if (ProtoCore.DSASM.Constants.kInvalidIndex != line){
			   node.line = line; node.col = col; }
			else{
			   NodeUtils.SetNodeLocation(node, t); }
			
		} else SynErr(130);
	}