void Imperative_num(out ProtoCore.AST.ImperativeAST.ImperativeNode node) { node = null; String localvalue = String.Empty; int line = ProtoCore.DSASM.Constants.kInvalidIndex; int col = ProtoCore.DSASM.Constants.kInvalidIndex; if (la.kind == 12) { Get(); localvalue = "-"; line = t.line; col = t.col; } if (la.kind == 2) { Get(); node = new ProtoCore.AST.ImperativeAST.IntNode() { value = localvalue + t.val }; if (ProtoCore.DSASM.Constants.kInvalidIndex != line){ node.line = line; node.col = col; } else{ NodeUtils.SetNodeLocation(node, t); } } else if (la.kind == 3) { Get(); node = new ProtoCore.AST.ImperativeAST.DoubleNode() { value = localvalue + t.val }; if (ProtoCore.DSASM.Constants.kInvalidIndex != line){ node.line = line; node.col = col; } else{ NodeUtils.SetNodeLocation(node, t); } } else SynErr(125); }
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); }
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); }