示例#1
0
 public FunctionNode(Node name,Node paraNode,Node func)
     : base()
 {
     this.name = (SymbolNode)name;
     this.paraNode = (ParametersNode)paraNode;
     this.func = (BlockNode)func;
     this.paraNode.SetBlock(this.func);
 }
示例#2
0
文件: Node.cs 项目: tomoki/Umi
 //messageを受け取る。
 public Node recv_message(Node recv,string message)
 {
     if(recv==null){
         return GetSlot(message)(null);
     }else{
         return GetSlot(message)(recv);
     }
 }
示例#3
0
文件: NumberNode.cs 项目: tomoki/Umi
 public Node div(Node node)
 {
     Node n = node.eval();
     if(!(node is NumberNode)){
         throw new Exception("Right is not Number");
     }
     return new NumberNode(Value/(((NumberNode)n).Value));
 }
示例#4
0
文件: BlockNode.cs 项目: tomoki/Umi
 public void Set(string str,Node n)
 {
     if(existName(str)){
         SetSub(str,n);
     }else{
         Name[str] = n;
     }
 }
示例#5
0
文件: StringNode.cs 项目: tomoki/Umi
 public Node plus(Node node)
 {
     Node n = node.eval();
     if(!(node is StringNode)){
         throw new UmiException("Right is not String");
     }
     return new StringNode(Value+(((StringNode)n).Value));
 }
示例#6
0
文件: TrueNode.cs 项目: tomoki/Umi
 public Node equal(Node node)
 {
     if(node is TrueNode){
         return new TrueNode();
     }else if(node is FalseNode){
         return new FalseNode();
     }else{
         throw new UmiException("Right is not boolean");
     }
 }
示例#7
0
 public Node call(Node node)
 {
     ArgumentsNode argsNode = (ArgumentsNode)node;
     if(argsNode.Length != paraNode.Length){
         throw new UmiException("Call failed because of args'length");
     }
     for(int i=0;i<argsNode.Length;i++){
         paraNode[i].assign(argsNode[i].eval());
     }
     return func.eval();
 }
示例#8
0
文件: NumberNode.cs 项目: tomoki/Umi
 public Node greaterequal(Node node)
 {
     Node n = node.eval();
     if(!(node is NumberNode)){
         throw new Exception("Right is not Number");
     }
     if(((NumberNode)n).Value <= this.Value){
         return new TrueNode();
     }else{
         return new FalseNode();
     }
 }
示例#9
0
文件: SystemNode.cs 项目: tomoki/Umi
 public Node print(Node node)
 {
     if(node is ArgumentsNode){
         Node s = null;
         for(int i=0;i<((ArgumentsNode)node).Length;i++){
             s = send_message((((ArgumentsNode)node)[i]).eval(),null,"to_s");
             Console.WriteLine(((StringNode)s).Value);
         }
         return s;
     }else{
         Node s = send_message(node.eval(),null,"to_s");
         Console.WriteLine(((StringNode)s).Value);
         return s;
     }
     return null;
 }
示例#10
0
文件: NumberNode.cs 项目: tomoki/Umi
 public override Node to_s(Node node)
 {
     return new StringNode(Value.ToString());
 }
示例#11
0
文件: NumberNode.cs 项目: tomoki/Umi
 public Node positive(Node node)
 {
     return new NumberNode(1*Value);
 }
示例#12
0
文件: Parser.cs 项目: tomoki/Umi
 private Node ParseAssignment2(Node node)
 {
     TokenType op_type = tokenType;
     GetToken();
     Node right = ParseExpression();
     Node op = new AssignNode(node,right,op_type);
     return op;
 }
示例#13
0
 public PositiveNode(Node node)
 {
     this.node = node;
 }
示例#14
0
文件: SymbolNode.cs 项目: tomoki/Umi
 public override Node to_s(Node node)
 {
     return new StringNode(name);
 }
示例#15
0
文件: Node.cs 项目: tomoki/Umi
 public virtual Node to_s(Node node)
 {
     return new StringNode("Node");
 }
示例#16
0
文件: AssignNode.cs 项目: tomoki/Umi
 public AssignNode(Node left,Node right,TokenType op_type)
 {
     Right = right;
     Left = left;
     OPType = op_type;
 }
示例#17
0
文件: ElifNode.cs 项目: tomoki/Umi
 public ElifNode(Node boolean,Node TrueBlock)
 {
     this.boolean = boolean;
     this.TrueBlock = TrueBlock;
     excuted = false;
 }
示例#18
0
文件: CompareNode.cs 项目: tomoki/Umi
 public CompareNode(Node left,Node right,TokenType op_type)
 {
     Left = left;
     Right = right;
     OPType = op_type;
 }
示例#19
0
文件: Parser.cs 项目: tomoki/Umi
 private Node ParseMethod(Node node)
 {
     SymbolNode name = ParseSymbol();
     Node argnode = ParseArguments();
     return new MethodNode(node,argnode,name.Name);
 }
示例#20
0
文件: Parser.cs 项目: tomoki/Umi
 private Node ParseComparison2(Node node)
 {
     TokenType op_type = tokenType;
     GetToken();
     Node right = ParseAdditiveExpression();
     Node compNode = new CompareNode(node,right,op_type);
     return compNode;
 }
示例#21
0
文件: SymbolNode.cs 项目: tomoki/Umi
 public Node assign(Node node)
 {
     Node n = node.eval();
     Block.Set(name,n);
     return n;
 }
示例#22
0
文件: BlockNode.cs 项目: tomoki/Umi
 public void Add(Node n)
 {
     ChildNodes.Add(n);
 }
示例#23
0
文件: SymbolNode.cs 项目: tomoki/Umi
 public Node defineFunc(Node node)
 {
     Block.Set(name,node);
     return node;
 }
示例#24
0
文件: TrueNode.cs 项目: tomoki/Umi
 public override Node to_s(Node node)
 {
     return new StringNode("true");
 }
示例#25
0
文件: MethodNode.cs 项目: tomoki/Umi
 public MethodNode(Node node,Node x,string message)
 {
     this.node = node;
     this.x = x;
     this.message = message;
 }
示例#26
0
文件: NumberNode.cs 项目: tomoki/Umi
 public Node negative(Node node)
 {
     return new NumberNode(-1*Value);
 }
示例#27
0
文件: Node.cs 项目: tomoki/Umi
 //send_messageは、senderのGetSlot(message)した関数にrecvを渡して実行する。
 //これはSmallTalkのオブジェクト指向。
 public Node send_message(Node sender,Node recv,string message)
 {
     return sender.recv_message(recv,message);
 }
示例#28
0
文件: FalseNode.cs 项目: tomoki/Umi
 public Node not(Node n)
 {
     return new TrueNode();
 }
示例#29
0
 //実引数を追加。
 public void Add(Node n)
 {
     arguments.Add(n);
 }
示例#30
0
文件: TrueNode.cs 项目: tomoki/Umi
 public Node not(Node n)
 {
     return new FalseNode();
 }