Beispiel #1
0
        public Code EvalLiteralWordAtom(ParseTreeNode node, ref CgContext ctx)
        {
            switch (node.Term.Name)
            {
                case "identifier":
                    return new Code(EvalIdentifier(node, ref ctx));

                case "character":
                    return new Code(EvalCharacter(node, ref ctx));

                case "number":
                    return new Code(EvalNumber(node, ref ctx));

                case "DifferenceLiteral":
                    {
                        var @base = ctx.GetCurrentAddress();
                        var target = EvalLiteralWordAtom(node.ChildNodes[0].ChildNodes[0], ref ctx);
                        return ctx.EncodeDifference(new Difference(@base, target));
                    }

                case "DifferenceTo":
                    return EvalLiteralWordAtom(node.ChildNodes[0], ref ctx);

                default:
                    throw new UnexpectedGrammarException();
            }
        }
Beispiel #2
0
        public Code EvalLiteralWord(ParseTreeNode node, ref CgContext ctx)
        {
            var head = node.ChildNodes[0];
            var tail = node.ChildNodes.Count > 1 ? node.ChildNodes[1] : null;
            
            var code = EvalLiteralWordAtom(head, ref ctx);

            if (tail != null)
            {
                var tailC = EvalLiteralWordAtom(tail, ref ctx);
                var diff = new Difference(code, tailC);
                code = ctx.EncodeDifference(diff);
            }

            return code;
        }