예제 #1
0
        protected override void ConstructFieldTemplates(NodeProvider nodeProvider, Dictionary <Type, NodeFieldTemplate> templates)
        {
            NodeLibrary library = nodeProvider.GetNodeLibrary();

            foreach (var nodeTemplate in library.nodeTemplates)
            {
                Type type = nodeTemplate.RuntimeNodeType;

                var template = new NodeFieldTemplate();
                var fields   = type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);

                foreach (var field in fields)
                {
                    bool isPrivate = field.IsPrivate;

                    if (IsOutput(field))
                    {
                        template.OutputPorts.Add(new Ports.PortDescription(field.Name, field.FieldType, PortDirection.Output, false, false));
                    }
                    else if (IsInput(field))
                    {
                        template.OutputPorts.Add(new Ports.PortDescription(field.Name, field.FieldType, PortDirection.Input, false, false));
                    }
                    else
                    {
                        template.Properties.Add(new PropertyDescription {
                            FieldType = field
                        });
                    }
                }

                templates.Add(type, template);
            }
        }
예제 #2
0
        //
        // An @import directive
        //
        //     @import "lib";
        //
        // Depending on our environemnt, importing is done differently:
        // In the browser, it's an XHR request, in Node, it would be a
        // file-system operation. The function used for importing is
        // stored in `import`, which we pass to the Import constructor.
        //
        public Import Import(Parser parser)
        {
            Node path = null;

            var index = parser.Tokenizer.Location.Index;

            if (parser.Tokenizer.Match(@"@import\s+") && (path = Quoted(parser) || Url(parser)))
            {
                if (!parser.Tokenizer.Match(';'))
                {
                    throw new ParsingException("Expected ';'", parser.Tokenizer.Location.Index);
                }

                if (path is Quoted)
                {
                    return(NodeProvider.Import(path as Quoted, parser.Importer, index));
                }

                if (path is Url)
                {
                    return(NodeProvider.Import(path as Url, parser.Importer, index));
                }
            }

            return(null);
        }
예제 #3
0
파일: Library.cs 프로젝트: muntac/unitytool
        // Checks for collision between two nodes and their children
        public static bool CheckCollision(Node n1, Node n2, NodeProvider provider, SpaceState state, bool noisy = false, int deep = 0)
        {
            if (deep > 5)
                return false;
            int x = (n1.x + n2.x) / 2;
            int y = (n1.y + n2.y) / 2;
            int t = (n1.t + n2.t) / 2;
            Node n3 = provider.GetNode (t, x, y);

            // Noisy calculation
            if (state.enemies != null && ((Cell)n3.cell).noisy) {
                foreach (Enemy enemy in state.enemies) {
                    Vector3 dupe = enemy.positions [t];
                    dupe.x = (dupe.x - state.floorMin.x) / state.tileSize.x;
                    dupe.y = n3.t;
                    dupe.z = (dupe.z - state.floorMin.z) / state.tileSize.y;

                    // This distance is in number of cells size radius i.e. a 10 tilesize circle around the point
                    if (Vector3.Distance (dupe, n3.GetVector3 ()) < 10)
                        return true;
                }
            }

            return !(n3.cell.safe || !(n3.cell.blocked || n3.cell.seen)) || CheckCollision (n1, n3, provider, state, noisy, deep + 1) || CheckCollision (n2, n3, provider, state, noisy, deep + 1);
        }
예제 #4
0
        public Node Addition(Parser parser)
        {
            var m = Multiplication(parser);

            if (!m)
            {
                return(null);
            }

            Operation operation = null;

            while (true)
            {
                GatherComments(parser);

                var index = parser.Tokenizer.Location.Index;
                var op    = parser.Tokenizer.Match(@"[-+]\s+");
                if (!op && !char.IsWhiteSpace(parser.Tokenizer.GetPreviousCharIgnoringComments()))
                {
                    op = parser.Tokenizer.Match(@"[-+]");
                }

                Node a = null;
                if (op && (a = Multiplication(parser)))
                {
                    operation = NodeProvider.Operation(op.Value, operation ?? m, a, index);
                }
                else
                {
                    break;
                }
            }
            return(operation ?? m);
        }
예제 #5
0
        protected virtual void BuildCreateNodeMenu(ContextualMenuPopulateEvent evt)
        {
            foreach (var nodeMenuItem in NodeProvider.GetNodeMenuEntries())
            {
                var     mousePos      = (evt.currentTarget as VisualElement).ChangeCoordinatesTo(contentViewContainer, evt.localMousePosition);
                Vector2 nodePosition  = mousePos;
                string  souceNodeName = GraphNodeType.MNode.ToString(); // Reverse direction
                string  actionName    = $"Create/{(nodeMenuItem.type == typeof(ConvertNode) ? nodeMenuItem.path.Split('$')[0].Split('.').LastOrDefault() : nodeMenuItem.type == typeof(SourceNode) ? ($"{nodeMenuItem.path}{souceNodeName}") : nodeMenuItem.path)}";

                evt.menu.AppendAction(actionName,
                                      (e) =>
                {
                    if (nodeMenuItem.type.IsAssignableFrom(typeof(ConvertNode)))
                    {
                        CreateConverterNodeOfClass(nodeMenuItem.path, nodePosition);
                    }
                    else if (nodeMenuItem.type.IsAssignableFrom(typeof(SourceNode)))
                    {
                        AddSourceNode(typeof(int), !isM2V, nodePosition, GraphNodeType.MNode.ToString(), true);
                    }
                    else
                    {
                        CreateNodeOfType(nodeMenuItem.type, nodePosition);
                    }
                }, DropdownMenuAction.AlwaysEnabled
                                      );
            }
        }
        /// <summary>
        /// Validate given solution
        /// </summary>
        /// <param name="tour">Tour to check</param>
        private void ValidateTour(ITour tour)
        {
            if (tour == null)
            {
                throw new ArgumentNullException("tour");
            }

            if (tour.Dimension != tour.Nodes.Count)
            {
                throw new TourInvalidException("Tour dimension does not match number of nodes on a list");
            }

            HashSet <int> identifiers = new HashSet <int>();

            foreach (int nodeId in tour.Nodes)
            {
                if (identifiers.Contains(nodeId))
                {
                    throw new TourInvalidException("Tour is invalid, has a node " + nodeId + " multiple times");
                }

                if (null == NodeProvider.GetNode(nodeId))
                {
                    throw new TourInvalidException("Tour is invalid, has a node " + nodeId + " which is not present in a problem");
                }

                identifiers.Add(nodeId);
            }
        }
예제 #7
0
        //
        // An @import directive
        //
        //     @import "lib";
        //
        // Depending on our environemnt, importing is done differently:
        // In the browser, it's an XHR request, in Node, it would be a
        // file-system operation. The function used for importing is
        // stored in `import`, which we pass to the Import constructor.
        //
        public Import Import(Parser parser)
        {
            Node path = null;

            var index = parser.Tokenizer.Location.Index;

            if (parser.Tokenizer.Match(@"@import\s+") && (path = Quoted(parser) || Url(parser)))
            {
                var features = MediaFeatures(parser);

                if (!parser.Tokenizer.Match(';'))
                {
                    throw new ParsingException("Expected ';' (possibly unrecognised media sequence)", parser.Tokenizer.Location.Index);
                }

                if (path is Quoted)
                {
                    return(NodeProvider.Import(path as Quoted, parser.Importer, features, index));
                }

                if (path is Url)
                {
                    return(NodeProvider.Import(path as Url, parser.Importer, features, index));
                }

                throw new ParsingException("unrecognised @import format", index);
            }

            return(null);
        }
예제 #8
0
        //
        // Entities are tokens which can be found inside an Expression
        //

        //
        // A string, which supports escaping " and '
        //
        //     "milky way" 'he\'s the one!'
        //
        public Quoted Quoted(Parser parser)
        {
            var index   = parser.Tokenizer.Location.Index;
            var escaped = false;
            var quote   = parser.Tokenizer.CurrentChar;

            if (parser.Tokenizer.CurrentChar == '~')
            {
                escaped = true;
                quote   = parser.Tokenizer.NextChar;
            }
            if (quote != '"' && quote != '\'')
            {
                return(null);
            }

            if (escaped)
            {
                parser.Tokenizer.Match('~');
            }

            string str = parser.Tokenizer.GetQuotedString();

            if (str == null)
            {
                return(null);
            }

            return(NodeProvider.Quoted(str, str.Substring(1, str.Length - 2), escaped, index));
        }
예제 #9
0
        //
        // An operand is anything that can be part of an operation,
        // such as a Color, or a Variable
        //
        public Node Operand(Parser parser)
        {
            CharMatchResult negate = null;

            if (parser.Tokenizer.CurrentChar == '-' && parser.Tokenizer.Peek(@"-[@\(]"))
            {
                negate = parser.Tokenizer.Match('-');
                GatherComments(parser);
            }

            var operand = Sub(parser) ??
                          Dimension(parser) ??
                          Color(parser) ??
                          (Node)Variable(parser);

            if (operand != null)
            {
                return(negate ?
                       NodeProvider.Operation("*", NodeProvider.Number("-1", "", negate.Index), operand, negate.Index) :
                       operand);
            }

            if (parser.Tokenizer.CurrentChar == 'u' && parser.Tokenizer.Peek(@"url\("))
            {
                return(null);
            }

            return(Call(parser) || Keyword(parser));
        }
예제 #10
0
        //
        // A function call
        //
        //     rgb(255, 0, 255)
        //
        // We also try to catch IE's `alpha()`, but let the `alpha` parser
        // deal with the details.
        //
        // The arguments are parsed with the `entities.arguments` parser.
        //
        public Call Call(Parser parser)
        {
            var memo  = Remember(parser);
            var index = parser.Tokenizer.Location.Index;

            var name = parser.Tokenizer.Match(@"(%|[a-zA-Z0-9_-]+)\(");

            if (!name)
            {
                return(null);
            }

            if (name[1].ToLowerInvariant() == "alpha")
            {
                var alpha = Alpha(parser);
                if (alpha != null)
                {
                    return(alpha);
                }
            }

            var args = Arguments(parser);

            if (!parser.Tokenizer.Match(')'))
            {
                Recall(parser, memo);
                return(null);
            }

            return(NodeProvider.Call(name[1], args, index));
        }
예제 #11
0
 public virtual void EnsureNodeTypes()
 {
     if (NodeTypes == null)
     {
         NodeTypes = NodeProvider.GetChildrenTypes(this);
     }
 }
예제 #12
0
        //Generates the .figmafile
        internal void SaveLocalDocument(bool includeImages, NodeProvider provider)
        {
            if (string.IsNullOrEmpty(FileId))
            {
                throw new InvalidOperationException("id not set");
            }

            if (Document == null)
            {
                throw new InvalidOperationException("document not loaded not set");
            }
            var documentFilePath = DocumentFilePath;

            if (File.Exists(documentFilePath))
            {
                File.Delete(documentFilePath);
            }

            Document.Save(documentFilePath);

            //get image resources
            if (!includeImages)
            {
                return;
            }

            var resourcesDirectoryPath = Path.Combine(DirectoryPath, ResourcesDirectoryName);

            GenerateOutputResourceFiles(provider, FileId, resourcesDirectoryPath);
        }
예제 #13
0
        //Generates all the resources from the current .figmafile
        internal static void GenerateOutputResourceFiles(NodeProvider provider, string fileId, string resourcesDirectoryPath)
        {
            var figmaImageIds = new List <IImageNodeRequest>();

            foreach (var mainNode in provider.Response.document.children)
            {
                figmaImageIds.AddRange(provider.SearchImageNodes(mainNode)
                                       .Select(s => provider.CreateEmptyImageNodeRequest(s)));
            }

            //var mainNode = figmaResponse.document.children.FirstOrDefault ();
            if (figmaImageIds.Count > 0)
            {
                if (!Directory.Exists(resourcesDirectoryPath))
                {
                    Directory.CreateDirectory(resourcesDirectoryPath);
                }

                var downloadImages = figmaImageIds.ToArray();

                //2 scales
                foreach (var scale in new int[] { 1, 2 })
                {
                    AppContext.Api.ProcessDownloadImages(fileId, downloadImages, scale: scale);
                }
                provider.SaveResourceFiles(resourcesDirectoryPath, ImageFormat, downloadImages);
            }
        }
예제 #14
0
        //
        // A Selector Element
        //
        //     div
        //     + h1
        //     #socks
        //     input[type="text"]
        //
        // Elements are the building blocks for Selectors,
        // they are made out of a `Combinator` (see combinator rule),
        // and an element name, such as a tag a class, or `*`.
        //
        public Element Element(Parser parser)
        {
            var index = parser.Tokenizer.Location.Index;

            GatherComments(parser);

            Combinator c = Combinator(parser);

            PushComments();
            GatherComments(parser); // to collect, combinator must have picked up something which would require memory anyway
            var e = parser.Tokenizer.Match(@"[.#:]?[a-zA-Z0-9_-]+") || parser.Tokenizer.Match('*') || Attribute(parser) ||
                    parser.Tokenizer.MatchAny(@"\([^)@]+\)");

            bool isCombinatorAnd = !e && c.Value.StartsWith("&");

            if (e || isCombinatorAnd)
            {
                c.PostComments = PullComments();
                PopComments();
                c.PreComments = PullComments();
                return(NodeProvider.Element(c, isCombinatorAnd ? null : e.Value, index));
            }

            PopComments();
            return(null);
        }
예제 #15
0
파일: Library.cs 프로젝트: Hengle/unitytool
        // Checks for collision between two nodes and their children
        public static bool CheckCollision(Node n1, Node n2, NodeProvider provider, SpaceState state, bool noisy = false, int deep = 0)
        {
            if (deep > 5)
            {
                return(false);
            }
            int  x  = (n1.x + n2.x) / 2;
            int  y  = (n1.y + n2.y) / 2;
            int  t  = (n1.t + n2.t) / 2;
            Node n3 = provider.GetNode(t, x, y);

            // Noisy calculation
            if (state.enemies != null && ((Cell)n3.cell).noisy)
            {
                foreach (Enemy enemy in state.enemies)
                {
                    Vector3 dupe = enemy.positions [t];
                    dupe.x = (dupe.x - state.floorMin.x) / state.tileSize.x;
                    dupe.y = n3.t;
                    dupe.z = (dupe.z - state.floorMin.z) / state.tileSize.y;

                    // This distance is in number of cells size radius i.e. a 10 tilesize circle around the point
                    if (Vector3.Distance(dupe, n3.GetVector3()) < 10)
                    {
                        return(true);
                    }
                }
            }

            return(!n3.cell.IsWalkable() || CheckCollision(n1, n3, provider, state, noisy, deep + 1) || CheckCollision(n2, n3, provider, state, noisy, deep + 1));
        }
예제 #16
0
 private void Initialize()
 {
     m_nodeProvider  = new BrianNodeProvider();
     m_fieldProvider = new BrianFieldProvider();
     m_editorView    = new NodeSketchEditorView(this, m_nodeProvider, m_fieldProvider);
     rootVisualElement.Add(m_editorView);
 }
예제 #17
0
        public Node Multiplication(Parser parser)
        {
            GatherComments(parser);

            var m = Operand(parser);

            if (!m)
            {
                return(null);
            }

            Node operation = m;

            while (true)
            {
                GatherComments(parser); // after left operand

                var index = parser.Tokenizer.Location.Index;
                var op    = parser.Tokenizer.Match(@"[\/*]");

                GatherComments(parser); // after operation

                Node a = null;
                if (op && (a = Operand(parser)))
                {
                    operation = NodeProvider.Operation(op.Value, operation, a, index);
                }
                else
                {
                    break;
                }
            }
            return(operation);
        }
예제 #18
0
 private void Initialize()
 {
     m_nodeProvider  = new NodeScriptNodeProvider();
     m_fieldProvider = new GraphNodeDefaultFieldProvider();
     m_editorView    = new NodeSketchEditorView(this, m_nodeProvider, m_fieldProvider);
     rootVisualElement.Add(m_editorView);
 }
예제 #19
0
        //
        // A Value is a comma-delimited list of Expressions
        //
        //     font-family: Baskerville, Georgia, serif;
        //
        // In a Rule, a Value represents everything after the `:`,
        // and before the `;`.
        //
        public Value Value(Parser parser)
        {
            var expressions = new NodeList();

            var index = parser.Tokenizer.Location.Index;

            Node e;

            while (e = Expression(parser))
            {
                expressions.Add(e);
                if (!parser.Tokenizer.Match(','))
                {
                    break;
                }
            }

            GatherComments(parser);

            var important = Important(parser);

            if (expressions.Count > 0)
            {
                var value = NodeProvider.Value(expressions, important, index);

                if (!string.IsNullOrEmpty(important))
                {
                    value.PreImportantComments = PullComments();
                }

                return(value);
            }

            return(null);
        }
예제 #20
0
        public Value Font(Parser parser)
        {
            var  value      = new NodeList();
            var  expression = new NodeList();
            Node e;

            var index = parser.Tokenizer.Location.Index;

            while (e = Shorthand(parser) || Entity(parser))
            {
                expression.Add(e);
            }
            value.Add(NodeProvider.Expression(expression, index));

            if (parser.Tokenizer.Match(','))
            {
                while (e = Expression(parser))
                {
                    value.Add(e);
                    if (!parser.Tokenizer.Match(','))
                    {
                        break;
                    }
                }
            }
            return(NodeProvider.Value(value, Important(parser), index));
        }
예제 #21
0
        protected override void ConstructFieldTemplates(NodeProvider nodeProvider, Dictionary <Type, NodeFieldTemplate> templates)
        {
            NodeLibrary library = nodeProvider.GetNodeLibrary();

            foreach (var nodeTemplate in library.nodeTemplates)
            {
                Type type     = nodeTemplate.RuntimeNodeType;
                var  fields   = type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
                var  template = new NodeFieldTemplate();

                var supressInput = type.GetCustomAttribute <SupressInputAttribute>();

                // All tasks (nodes in this case) need to have an input, that isnt in the code of the behaviours
                // so we just add it in the first thing we do.
                if (supressInput == null)
                {
                    template.InputPorts.Add(new PortDescription("Input", typeof(Task), PortDirection.Input, false, false));
                }

                foreach (var field in fields)
                {
                    OutputAttribute output   = field.GetCustomAttribute <OutputAttribute>();
                    InputAttribute  input    = field.GetCustomAttribute <InputAttribute>();
                    SerializeField  property = field.GetCustomAttribute <SerializeField>();

                    bool autoAdd  = false;
                    bool isInput  = input == null ? false : true;
                    bool isOutput = output == null ? false : true;

                    if (output != null)
                    {
                        autoAdd = output.AutoAddPortOnConnect;
                    }
                    if (input != null)
                    {
                        autoAdd = input.AutoAddPortOnConnect;
                    }

                    bool isList = IsListType(field);

                    if (output != null || input != null)
                    {
                        if (IsListType(field))
                        {
                            AddGenericPort(template, field, isInput, isOutput, autoAdd);
                        }
                        else
                        {
                            AddNonGenericPort(template, field.FieldType, field.Name, field.Name, isInput, isOutput, autoAdd);
                        }
                    }
                    else if (property != null)
                    {
                        AddNonGenericProperty(template, field, field.Name, field.Name);
                    }
                }
                templates.Add(type, template);
            }
        }
예제 #22
0
 public void SaveAll(bool includeImages, NodeProvider provider)
 {
     Save();
     SaveLocalDocument(includeImages, provider);
     //if (createViews)
     //	SaveViews (codeRendererService, writePublicClassIfExists, translateLabels: translateLabels);
     Console.WriteLine($"[Done] Saved all the files from Figma Package");
 }
예제 #23
0
    static void Main(string[] args)
    {
        var provider = new NodeProvider();

        provider.LoadNodes(null, (list) => Console.WriteLine(string.Join(", ", list.Select(node => node.Name).ToArray())));

        Console.ReadLine();
    }
예제 #24
0
        public Directive KeyFrameBlock(Parser parser, string name, string identifier, int index)
        {
            if (!parser.Tokenizer.Match('{'))
            {
                return(null);
            }

            NodeList     keyFrames       = new NodeList();
            const string identifierRegEx = "from|to|([0-9]+%)";

            while (true)
            {
                GatherComments(parser);

                string keyFrameIdentifier;
                var    keyFrameIdentifier1 = parser.Tokenizer.Match(identifierRegEx);

                if (!keyFrameIdentifier1)
                {
                    break;
                }

                keyFrameIdentifier = keyFrameIdentifier1.Value;

                if (parser.Tokenizer.Match(","))
                {
                    var keyFrameIdentifier2 = parser.Tokenizer.Match(identifierRegEx);

                    if (!keyFrameIdentifier2)
                    {
                        throw new ParsingException("Comma in @keyframe followed by unknown identifier", parser.Tokenizer.Location.Index);
                    }

                    keyFrameIdentifier += "," + keyFrameIdentifier2;
                }

                var preComments = GatherAndPullComments(parser);

                var block = Block(parser);

                if (block == null)
                {
                    throw new ParsingException("Expected css block after key frame identifier", parser.Tokenizer.Location.Index);
                }

                block.PreComments  = preComments;
                block.PostComments = GatherAndPullComments(parser);

                keyFrames.Add(NodeProvider.KeyFrame(keyFrameIdentifier, block, parser.Tokenizer.Location.Index));
            }

            if (!parser.Tokenizer.Match('}'))
            {
                throw new ParsingException("Expected start, finish, % or '}'", parser.Tokenizer.Location.Index);
            }

            return(NodeProvider.Directive(name, identifier, keyFrames, index));
        }
예제 #25
0
 private ProjectGraphNodeAdapter(ProjectGraphNode adaptedNode, NodeProvider nodeProvider)
 {
     AdaptedNode = adaptedNode;
     _parents    =
         new Lazy <IReadOnlyCollection <IGraphNode> >(
             () => adaptedNode.ReferencingProjects.Select(n => nodeProvider.FromProjectGraphNode(n)).ToArray());
     _children =
         new Lazy <IReadOnlyCollection <IGraphNode> >(
             () => adaptedNode.ProjectReferences.Select(n => nodeProvider.FromProjectGraphNode(n)).ToArray());
 }
예제 #26
0
 public static bool TryGetFigmaNode(this ProjectFile sender, NodeProvider fileProvider, out FigmaNode figmaNode)
 {
     if (sender.HasFigmaDesignerFileExtension() && TryGetNodeName(sender, out var figmaName))
     {
         figmaNode = fileProvider.FindByCustomName(figmaName);
         return(figmaNode != null);
     }
     figmaNode = null;
     return(false);
 }
예제 #27
0
        public RubyConstructor(RubyGlobalScope/*!*/ scope, NodeProvider/*!*/ nodeProvider)
            : base(nodeProvider, scope) {
            
            _newSite = CallSite<Func<CallSite, RubyModule, object, object, object, object>>.Create(
                RubyCallAction.Make(scope.Context, "new", RubyCallSignature.WithImplicitSelf(3))
            ); 

            _yamlInitializeSite = CallSite<Func<CallSite, object, object, Hash, object>>.Create(
                RubyCallAction.Make(scope.Context, "yaml_initialize", RubyCallSignature.WithImplicitSelf(3))
            );
        }
예제 #28
0
파일: ItemNode.cs 프로젝트: keutmann/SPM
 /// <summary>
 /// Invoked when the child items need to be loaded on demand.
 /// Subclasses can override this to populate the Children collection.
 /// </summary>
 public override void LoadChildren()
 {
     Children.Clear();
     if (NodeProvider != null)
     {
         foreach (SharpTreeNode node in NodeProvider.LoadChildren(this))
         {
             Children.Add(node);
         }
     }
 }
예제 #29
0
        //
        // A Variable entity, such as `@fink`, in
        //
        //     width: @fink + 2px
        //
        // We use a different parser for variable definitions,
        // see `parsers.variable`.
        //
        public Variable Variable(Parser parser)
        {
            RegexMatchResult name;
            var index = parser.Tokenizer.Location.Index;

            if (parser.Tokenizer.CurrentChar == '@' && (name = parser.Tokenizer.Match(@"@?@[a-zA-Z0-9_-]+")))
            {
                return(NodeProvider.Variable(name.Value, index));
            }

            return(null);
        }
예제 #30
0
        // We create a Comment node for CSS comments `/* */`,
        // but keep the LeSS comments `//` silent, by just skipping
        // over them.
        public Comment Comment(Parser parser)
        {
            var    index   = parser.Tokenizer.Location.Index;
            string comment = parser.Tokenizer.GetComment();

            if (comment != null)
            {
                return(NodeProvider.Comment(comment, comment.StartsWith("//"), index));
            }

            return(null);
        }
예제 #31
0
파일: Library.cs 프로젝트: muntac/unitytool
 public static bool SmoothNode(Node n, NodeProvider provider, SpaceState state, bool noisy = false)
 {
     if (n.parent != null && n.parent.parent != null) {
         if (CheckCollision (n, n.parent.parent, provider, state, noisy))
             return false;
         else {
             n.parent = n.parent.parent;
             return true;
         }
     } else
         return false;
 }
예제 #32
0
        //
        // Combinators combine elements together, in a Selector.
        //
        // Because our parser isn't white-space sensitive, special care
        // has to be taken, when parsing the descendant combinator, ` `,
        // as it's an empty space. We have to check the previous character
        // in the input, to see if it's a ` ` character. More info on how
        // we deal with this in *combinator.js*.
        //
        public Combinator Combinator(Parser parser)
        {
            var index = parser.Tokenizer.Location.Index;

            Node match;

            if (match = parser.Tokenizer.Match(@"[+>~]") || parser.Tokenizer.Match(@"&\s?") || parser.Tokenizer.Match(@"::"))
            {
                return(NodeProvider.Combinator(match.ToString(), index));
            }

            return(NodeProvider.Combinator(char.IsWhiteSpace(parser.Tokenizer.GetPreviousCharIgnoringComments()) ? " " : null, index));
        }
예제 #33
0
        //
        // A catch-all word, such as:
        //
        //     black border-collapse
        //
        public Keyword Keyword(Parser parser)
        {
            var index = parser.Tokenizer.Location.Index;

            var k = parser.Tokenizer.Match(@"[A-Za-z-]+");

            if (k)
            {
                return(NodeProvider.Keyword(k.Value, index));
            }

            return(null);
        }
예제 #34
0
 public RubyConstructor(RubyGlobalScope/*!*/ scope, NodeProvider/*!*/ nodeProvider)
     : base(nodeProvider, scope) {
 }
예제 #35
0
        public RubyConstructor(RubyGlobalScope/*!*/ scope, NodeProvider/*!*/ nodeProvider)
            : base(nodeProvider, scope) {            
            AddConstructor("tag:yaml.org,2002:str", ConstructRubyScalar);
            AddConstructor("tag:ruby.yaml.org,2002:range", ConstructRubyRange);
            AddConstructor("tag:ruby.yaml.org,2002:regexp", ConstructRubyRegexp);
            AddMultiConstructor("tag:ruby.yaml.org,2002:object:", ConstructPrivateObject);            
            AddMultiConstructor("tag:ruby.yaml.org,2002:struct:", ConstructRubyStruct);
            AddConstructor("tag:yaml.org,2002:binary", ConstructRubyBinary);
            AddConstructor("tag:yaml.org,2002:timestamp#ymd", ConstructRubyTimestampYMD);

            //AddConstructor("tag:yaml.org,2002:omap", ConstructRubyOmap);
            //AddMultiConstructor("tag:yaml.org,2002:seq:", ConstructSpecializedRubySequence);
            //AddMultiConstructor("tag:yaml.org,2002:map:", ConstructSpecializedRubyMap);
        }
예제 #36
0
 public SafeConstructor(/*!*/NodeProvider nodeProvider, RubyGlobalScope/*!*/ scope)
     : base(nodeProvider, scope) {
 }
예제 #37
0
 public Constructor(NodeProvider/*!*/ nodeProvider, RubyGlobalScope/*!*/ scope)
     : base(nodeProvider, scope) {
 }