예제 #1
0
 public FileParser(ParsableData data) : base(data)
 {
     commentParser   = new CommentParser(data);
     configParser    = new ConfigParser(data);
     importParser    = new ImportParser(data);
     interfaceParser = new InterfaceParser(data);
 }
예제 #2
0
 /// Prüft das nächste Non-Whitespace-Zeichen ohne
 /// den Zeiger von data zu verändern...
 public static bool NextNonWhitespaceIs(ParsableData data, char c)
 {
     for (int i = 0; (data.Position + i) < data.Content.Length; i++)
     {
         char c2 = data.Get(i);
         if (c2 == c)
         {
             return(true);
         }
         else if (!IsNewLineOrWhitespace(c2))
         {
             return(false);
         }
     }
     return(false);
 }
예제 #3
0
        private void onInitial(char c)
        {
            if (ParserUtil.IsNewLineOrWhitespace(c) && buf.Length == 0)
            {
                result.WhitespaceBefore += c;
            }
            else if (ParserUtil.IsValidNameChar(c))
            {
                buf += c;
            }
            else if (ParserUtil.IsNewLineOrWhitespace(c) && buf.Length > 0)
            {
                if (buf == "import")
                {
                    var temp     = stringElementParser.Parse().Split('/');
                    var fileName = Path.Combine(temp); // Zum Betriebssystem passende Slashes setzen.
                    result.Path          = Path.Combine(Data.BasePath, fileName);
                    result.BaseDirectory = Data.BasePath;
                    state = FINAL;
                    buf   = "";

                    var innerData   = new ParsableData(System.IO.File.ReadAllText(result.Path), result.Path);
                    var p           = new FileParser(innerData);
                    var innerResult = p.Parse();
                    result.Content = innerResult;
                    Data.Back(1); // Bei direkt aufeinander folgenden Import-Zeilen hatte ich sonst mport!
                }
                else
                {
                    throw new InvalidTokenException($"Ungültiges Token {buf}", Data);
                }
            }
            else
            {
                throw new InvalidCharException($"Ungültiges Zeichen {c}", Data);
            }
        }
예제 #4
0
 public CommentParser(ParsableData data) : base(data)
 {
 }
 public StringElementParser(ParsableData data) : base(data)
 {
 }
예제 #6
0
 public ImportParser(ParsableData data) : base(data)
 {
     stringElementParser = new StringElementParser(data);
 }
예제 #7
0
 public AttributeParser(ParsableData data) : base(data)
 {
     this.namedParameterParser = new NamedParameterParser(data);
 }
예제 #8
0
 public ConfigParser(ParsableData data) : base(data)
 {
     this.namedParameterParser = new NamedParameterParser(data);
     this.commentParser        = new CommentParser(data);
 }
 public InterfaceParser(ParsableData data) : base(data)
 {
     this.commentParser        = new CommentParser(data);
     this.attributeParser      = new AttributeParser(data);
     this.namedParameterParser = new NamedParameterParser(data);
 }
 public NamedParameterParser(ParsableData data) : base(data)
 {
     this.stringElementParser = new StringElementParser(data);
 }