private Block HashRest(char current)
        {
            while (true)
            {
                if (current.IsName())
                {
                    _buffer.Append(current);
                }
                else if (IsValidEscape(current))
                {
                    current = _stylesheetReader.Next;
                    _buffer.Append(ConsumeEscape(current));
                }
                else if (current == Specification.ReverseSolidus)
                {
                    ErrorHandler(ParserError.InvalidCharacter, ErrorMessages.InvalidCharacterAfterHash);

                    _stylesheetReader.Back();
                    return(SymbolBlock.Hash(FlushBuffer()));
                }
                else
                {
                    _stylesheetReader.Back();
                    return(SymbolBlock.Hash(FlushBuffer()));
                }

                current = _stylesheetReader.Next;
            }
        }
Beispiel #2
0
 public FPNFeatureExpander(SymbolBlock network, string[] outputs, int[] num_filters, bool use_1x1 = true, bool use_upsample = true,
                           bool use_elewadd = true, bool use_p6        = false, bool p6_conv = true, bool no_bias       = true,
                           bool pretrained  = false, string norm_layer = null, FuncArgs norm_kwargs = null, Context ctx = null, string[] inputs = null, ParameterDict @params = null) : base(null, null, @params)
 {
     var(p_i, p_o, p_p) = __internal__.ParseNetwork(network, outputs, inputs, pretrained, ctx);
     Construct(p_o, p_i, p_p, num_filters, use_1x1, use_upsample, use_elewadd, use_p6, p6_conv, no_bias, pretrained, norm_layer, norm_kwargs, ctx);
 }
Beispiel #3
0
 private bool ParseSingleValueIdent(SymbolBlock token)
 {
     if (token.Value != "inherit")
     {
         return(AddTerm(new PrimitiveTerm(UnitType.Ident, token.Value)));
     }
     _terms.AddTerm(Term.Inherit);
     SetParsingContext(ParsingContext.AfterValue);
     return(true);
 }
        static bool TryFindSymbolBlock(TextEditorData data, char command, out SymbolBlock result)
        {
            char end, begin;

            if (!BeginToEndCharMap.TryGetValue(command, out end))
            {
                end = command;
            }
            if (!EndToBeginCharMap.TryGetValue(command, out begin))
            {
                begin = command;
            }

            var offset = data.Caret.Offset;

            var startTokenOffset = ParseForChar(data, offset, 0, end, begin, false);
            var endTokenOffset   = ParseForChar(data, offset, data.Length, begin, end, true);

            // Use the editor's FindMatchingBrace built-in functionality. It's better at handling erroneous braces
            // inside quotes. We still need to do the above paragraph because we needed to find the braces.
            var matchingStartBrace = endTokenOffset.HasValue ? data.Document.GetMatchingBracketOffset(
                endTokenOffset.GetValueOrDefault()) : -1;

            if (matchingStartBrace >= 0 && (!startTokenOffset.HasValue ||
                                            matchingStartBrace != startTokenOffset.GetValueOrDefault()))
            {
                startTokenOffset = matchingStartBrace;
            }

            var matchingEndBrace = startTokenOffset.HasValue && data.GetCharAt(offset) != end?
                                   data.Document.GetMatchingBracketOffset(startTokenOffset.GetValueOrDefault()) : -1;

            if (matchingEndBrace >= 0 && (!endTokenOffset.HasValue ||
                                          matchingEndBrace != endTokenOffset.GetValueOrDefault()))
            {
                endTokenOffset = matchingEndBrace;
            }

            if (!startTokenOffset.HasValue || !endTokenOffset.HasValue)
            {
                throw new Exception();
            }

            result = new SymbolBlock
            {
                StartOffset = startTokenOffset.GetValueOrDefault(),
                EndOffset   = endTokenOffset.GetValueOrDefault(),
                StartLine   = data.GetLineByOffset(startTokenOffset.GetValueOrDefault()),
                EndLine     = data.GetLineByOffset(endTokenOffset.GetValueOrDefault()),
            };
            return(true);
        }
Beispiel #5
0
        private Block IdentRest(char current)
        {
            while (true)
            {
                if (current.IsName())
                {
                    _buffer.Append(current);
                }
                else if (IsValidEscape(current))
                {
                    current = _stylesheetReader.Next;
                    _buffer.Append(ConsumeEscape(current));
                }
                else if (current == Specification.ParenOpen)
                {
                    switch (_buffer.ToString().ToLower())
                    {
                    case "url":
                        _buffer.Clear();
                        return(UrlStart(_stylesheetReader.Next));   //, GrammarSegment.Url);

                    case "domain":
                        _buffer.Clear();
                        return(UrlStart(_stylesheetReader.Next));   //, GrammarSegment.Domain);

                    case "url-prefix":
                        _buffer.Clear();
                        return(UrlStart(_stylesheetReader.Next));   //, GrammarSegment.UrlPrefix);

                    default:
                        return(SymbolBlock.Function(FlushBuffer()));
                    }
                }
                else if (current == Specification.Period)
                {
                    _buffer.Append(current);
                }
                else
                {
                    _stylesheetReader.Back();
                    return(SymbolBlock.Ident(FlushBuffer()));
                }

                current = _stylesheetReader.Next;
            }
        }
        private Block AtKeywordRest(char current)
        {
            while (true)
            {
                if (current.IsName())
                {
                    _buffer.Append(current);
                }
                else if (IsValidEscape(current))
                {
                    current = _stylesheetReader.Next;
                    _buffer.Append(ConsumeEscape(current));
                }
                else
                {
                    _stylesheetReader.Back();
                    return(SymbolBlock.At(FlushBuffer()));
                }

                current = _stylesheetReader.Next;
            }
        }
		static bool TryFindSymbolBlock (TextEditorData data, char command, out SymbolBlock result)
		{
			char end, begin;
			if (!BeginToEndCharMap.TryGetValue (command, out end)) end = command;
			if (!EndToBeginCharMap.TryGetValue (command, out begin)) begin = command;

			var offset = data.Caret.Offset;

			var startTokenOffset = ParseForChar(data, offset, 0, end, begin, false);
			var endTokenOffset = ParseForChar(data, offset, data.Length, begin, end, true);

			// Use the editor's FindMatchingBrace built-in functionality. It's better at handling erroneous braces
			// inside quotes. We still need to do the above paragraph because we needed to find the braces.
			var matchingStartBrace = endTokenOffset.HasValue ? data.Document.GetMatchingBracketOffset(
				endTokenOffset.GetValueOrDefault ()) : -1;
			if (matchingStartBrace >= 0 && (!startTokenOffset.HasValue 
			                                || matchingStartBrace != startTokenOffset.GetValueOrDefault ()))
				startTokenOffset = matchingStartBrace;

			var matchingEndBrace = startTokenOffset.HasValue && data.GetCharAt (offset) != end ? 
				data.Document.GetMatchingBracketOffset(startTokenOffset.GetValueOrDefault ()) : -1;
			if (matchingEndBrace >= 0 && (!endTokenOffset.HasValue 
			                              || matchingEndBrace != endTokenOffset.GetValueOrDefault ()))
				endTokenOffset = matchingEndBrace;

			if (!startTokenOffset.HasValue || !endTokenOffset.HasValue) throw new ViModeAbortException();

			result = new SymbolBlock 
			{ 
				StartOffset = startTokenOffset.GetValueOrDefault (),
				EndOffset = endTokenOffset.GetValueOrDefault (),
				StartLine = data.GetLineByOffset (startTokenOffset.GetValueOrDefault()),
				EndLine = data.GetLineByOffset (endTokenOffset.GetValueOrDefault()),
			};
			return true;
		}
Beispiel #8
0
 public FPNFeatureExpander(SymbolBlock network, string[] outputs, int num_filters, bool use_1x1 = true, bool use_upsample = true,
                           bool use_elewadd = true, bool use_p6             = false, bool p6_conv = true, bool no_bias = true,
                           bool pretrained  = false, HybridBlock norm_layer = null, FuncArgs norm_kwargs = null, Context ctx = null, string[] inputs = null, ParameterDict @params = null) : base(null, null, @params)
 {
     throw new NotImplementedException();
 }
 private bool ParseSingleValueIdent(SymbolBlock token)
 {
   if (token.Value != "inherit")
   {
     return AddTerm(new PrimitiveTerm(UnitType.Ident, token.Value));
   }
   _terms.AddTerm(Term.Inherit);
   SetParsingContext(ParsingContext.AfterValue);
   return true;
 }