Exemplo n.º 1
0
 private void onInDataType(char c)
 {
     if (ParserUtil.IsNewLineOrWhitespace(c) && result.DataType.Length == 0)
     {
         // Leerzeichen vor dem DataType ignorieren
     }
     else if (ParserUtil.IsValidNameChar(c))
     {
         // Zeichen in DataType schreiben
         result.DataType += c;
     }
     else if (c == '(' && ParserUtil.IsValidDataType(result.DataType))
     {
         Data.Back(1);
         state = IN_PARAMETERS;
     }
     else if (ParserUtil.IsNewLineOrWhitespace(c) && ParserUtil.IsValidDataType(result.DataType))
     {
         // TODO: Mglw. as oder mglw. blanks vor Attributparameter???
         // state => BEHIND_DATATYPE
     }
     else if (c == ';' && ParserUtil.IsValidDataType(result.DataType))
     {
         state = FINAL;
     }
     else
     {
         throw new InvalidCharException("Ungültiges Zeichen im DataType", Data);
     }
 }
Exemplo n.º 2
0
        private void onInAttributeType(char c)
        {
            if (ParserUtil.IsNewLineOrWhitespace(c))
            {
                // Trennzeichen zwischen Attributtyp und Attributname/o.ä.
                switch (result.AttributeType)
                {
                case "base":
                case "fact":
                    state = IN_ATTRIBUTE_NAME;
                    break;

                case "ref":
                    state = IN_REF_INTERFACENAME;
                    break;

                default:
                    throw new InvalidTokenException("Ungültiges Token für AttributType => nur base, fact und ref erlaubt", Data);
                }
            }
            else if (ParserUtil.IsValidNameChar(c))
            {
                // Wechsel zu InAttributeType
                this.result.AttributeType += c;
            }
            else
            {
                throw new InvalidCharException($"Ungültiges Zeichen {c} im AttributeType", Data);
            }
        }
 private void onInInterfaceName(char c)
 {
     if (ParserUtil.IsValidNameChar(c))
     {
         result.Name += c;
     }
     else if (ParserUtil.IsNewLineOrWhitespace(c) && result.Name?.Length > 0)
     {
         state = BEHIND_INTERFACE_NAME;
     }
     else if (c == '{' && result.Name.Length > 0)
     {
         state = IN_INTERFACE_BODY;
     }
     else if (c == ':' && result.Name.Length > 0)
     {
         state = IN_INTERFACE_TYPE;
     }
     else if (c == '(' && result.Name.Length > 0)
     {
         state = IN_INTERFACE_PARAMS;
     }
     else if (!ParserUtil.IsNewLineOrWhitespace(c))
     {
         throw new InvalidCharException($"Ungültiges Zeichen {c} in InterfaceParser.IN_INTERFACE_NAME", Data);
     }
 }
 private void onInInterfaceParams(char c)
 {
     if (c == '/')
     {
         Data.Back(1);
         commentParser.Parse();
     }
     else if (c == ')' || ParserUtil.NextNonWhitespaceIs(Data, ')'))
     {
         state = BEHIND_INTERFACE_PARAMS;
     }
     else if (ParserUtil.IsValidNameChar(c))
     {
         Data.Back(1);
         var param = namedParameterParser.Parse();
         result.Parameters.Add(param);
         Data.Back(1);
     }
     else if (ParserUtil.IsNewLineOrWhitespace(c) && ParserUtil.NextNonWhitespaceIs(Data, '/'))
     {
         commentParser.Parse();
     }
     else if (ParserUtil.IsNewLineOrWhitespace(c))
     {
         var param = namedParameterParser.Parse();
         result.Parameters.Add(param);
         Data.Back(1);
     }
 }
 private void onInInterfaceBody(char c)
 {
     if (c == '/')
     {
         Data.Back(1);
         var comment = commentParser.Parse();
         result.AddComment(comment);
     }
     else if (c == 'f' || c == 'b' || c == 'r')
     {
         Data.Back(1);
         var attr = attributeParser.Parse();
         result.AddAttribute(attr);
     }
     else if (c == '}')
     {
         state = FINAL;
     }
     else if (ParserUtil.IsNewLineOrWhitespace(c) && ParserUtil.NextNonWhitespaceIs(Data, '/'))
     {
         var comment = commentParser.Parse("" + c);
         result.AddComment(comment);
     }
     else if (ParserUtil.IsNewLineOrWhitespace(c) && ParserUtil.NextNonWhitespaceIs(Data, '}'))
     {
         state = BEFORE_FINAL;
     }
     else if (ParserUtil.IsNewLineOrWhitespace(c))
     {
         var attr = attributeParser.Parse("" + c);
         result.AddAttribute(attr);
     }
 }
Exemplo n.º 6
0
 private void onBehindRefFieldName(char c)
 {
     if (ParserUtil.IsNewLineOrWhitespace(c))
     {
         // Ignorieren
     }
     else if (c == 'a' && Data.Content[Data.Position] == 's')
     {
         Data.Next();
         state = IN_ALIAS;
     }
     else if (c == '(')
     {
         Data.Back(1);
         state = IN_REF_PARAMETERS;
     }
     else if (c == ';')
     {
         state = FINAL;
     }
     else
     {
         throw new InvalidCharException("Ungültiges Zeichen nach DataType", Data);
     }
 }
Exemplo n.º 7
0
 private void onInitial(char c)
 {
     if (c == '/')
     {
         char c2 = Data.Next();
         if (c2 == '/')
         {
             result.WhitespaceBefore = whitespaceBuf;
             whitespaceBuf           = "";
             state = IN_LINE_COMMENT;
             result.CommentType = TmpCommentType.LINE_COMMENT;
         }
         else if (c2 == '*')
         {
             result.WhitespaceBefore = whitespaceBuf;
             whitespaceBuf           = "";
             state = IN_BLOCK_COMMENT;
             result.CommentType = TmpCommentType.BLOCK_COMMENT;
         }
         else
         {
             throw new InvalidCharException("Ungültiges Zeichen am Beginn des Kommentars", Data);
         }
     }
     else if (ParserUtil.IsNewLineOrWhitespace(c))
     {
         whitespaceBuf += c;
     }
     else
     {
         throw new InvalidCharException($"Ungültiges Zeichen {c} vor Kommentar", Data);
     }
 }
Exemplo n.º 8
0
 private void onBeforeFinal(char c)
 {
     if (c == '}')
     {
         state = FINAL;
     }
     else if (!ParserUtil.IsNewLineOrWhitespace(c))
     {
         throw new InvalidCharException($"Ungültiges Zeichen {c} in der Parameterliste der Config", Data);
     }
 }
 private void onInitial(char c)
 {
     if (c == '"')
     {
         state = IN_STRING;
     }
     else if (!ParserUtil.IsNewLineOrWhitespace(c))
     {
         throw new InvalidCharException("Ungültiges Zeichen in String: StringElementParser.onInitial!", Data);
     }
 }
Exemplo n.º 10
0
 private void onBehindInterfaceParams(char c)
 {
     if (c == '{')
     {
         state = IN_INTERFACE_BODY;
     }
     else if (!(ParserUtil.IsNewLineOrWhitespace(c) || c == ')'))
     {
         throw new InvalidCharException($"Ungültiges Zeichen {c} in BEHIND_INTERFACE_PARAMS", Data);
     }
 }
Exemplo n.º 11
0
 private void onBeforeFinal(char c)
 {
     if (c == '}')
     {
         state = FINAL;
     }
     else if (!ParserUtil.IsNewLineOrWhitespace(c))
     {
         throw new InvalidCharException($"Ungültiges Zeichen {c} in InterfaceParser.BEFORE_FINAL", Data);
     }
 }
Exemplo n.º 12
0
 private void onInBlockComment(char c)
 {
     if (c == '*' && ParserUtil.NextNonWhitespaceIs(Data, '/'))
     {
         state = FINAL;
     }
     else
     {
         result.Comment += c;
     }
 }
Exemplo n.º 13
0
 private void onBeforeParamList(char c)
 {
     if (c == '{' && buf.Equals("config"))
     {
         state = IN_PARAMLIST;
         buf   = "";
     }
     else if (!ParserUtil.IsNewLineOrWhitespace(c))
     {
         throw new InvalidCharException($"Ungültiges Zeichen {c} vor Parameterliste der Config", Data);
     }
 }
 private void onBehindName(char c)
 {
     if (c == '=' && result.Name.Length > 0)
     {
         state        = IN_VALUE;
         result.Value = stringElementParser.Parse();
     }
     else if (!ParserUtil.IsNewLineOrWhitespace(c))
     {
         throw new InvalidCharException("Invalid char behind param name", Data);
     }
 }
 private void onInitial(char c)
 {
     if (ParserUtil.IsNewLineOrWhitespace(c))
     {
         // Ignorieren
     }
     else if (ParserUtil.IsValidNameChar(c))
     {
         state        = IN_NAME;
         result.Name += c;
     }
     else
     {
         throw new InvalidCharException($"Invalid char {c} before param name", Data);
     }
 }
Exemplo n.º 16
0
 private void onBehindParam(char c)
 {
     if (c == ';' && ParserUtil.NextNonWhitespaceIs(Data, '}'))
     {
         state = BEFORE_FINAL;
     }
     else if (c == ';')
     {
         state = IN_PARAMLIST;
         Data.Back(1);
     }
     else if (!ParserUtil.IsNewLineOrWhitespace(c))
     {
         throw new InvalidCharException("Ungültiges Zeichen in der Parameterliste der Config", Data);
     }
 }
Exemplo n.º 17
0
 private void onInitial(char c)
 {
     if (c == '/' || ParserUtil.IsValidNameChar(c))
     {
         buf  += c;
         state = IN_TOKEN;
     }
     else if (ParserUtil.IsNewLineOrWhitespace(c) && buf.Length == 0)
     {
         // Sammeln der Leerzeichen vor dem Token
         whitespaceBuf += c;
     }
     else
     {
         throw new InvalidCharException($"Ungültiges Zeichen {c} in FileParser", Data);
     }
 }
Exemplo n.º 18
0
 private void onInRefParameters(char c)
 {
     if (c == '(' || c == ',')
     {
         var param = namedParameterParser.Parse();
         result.Parameters.Add(param);
         Data.Back(1);
     }
     else if (c == ')')
     {
         state = BEHIND_REF_PARAMETERS;
     }
     else if (!ParserUtil.IsNewLineOrWhitespace(c))
     {
         throw new InvalidCharException("Ungültiges Zeichen in Parameterliste", Data);
     }
 }
Exemplo n.º 19
0
 private void onInToken(char c)
 {
     if (c == '/' || c == '*' || ParserUtil.IsValidNameChar(c))
     {
         buf += c;
     }
     else if (ParserUtil.IsNewLineOrWhitespace(c) && buf.Length > 0)
     {
         Data.Back(buf.Length + 1);
         if (buf.Equals("interface"))
         {
             var ifa = interfaceParser.Parse(whitespaceBuf);
             result.AddInterface(ifa);
             whitespaceBuf = "";
         }
         else if (buf.Equals("config"))
         {
             if (result.Config != null)
             {
                 throw new InvalidTokenException("Es wurde eine zweite config-Section in einer CEUSDL-Datei gefunden", Data);
             }
             result.Config = configParser.Parse(whitespaceBuf);
             result.Objects.Add(new TmpMainLevelObject(result.Config));
             whitespaceBuf = "";
         }
         else if (buf.Equals("import"))
         {
             var import = importParser.Parse(whitespaceBuf);
             result.Objects.Add(new TmpMainLevelObject(import));
             whitespaceBuf = "";
         }
         else if (buf.StartsWith("//") || buf.StartsWith("/*"))
         {
             var comment = commentParser.Parse(whitespaceBuf);
             result.AddComment(comment);
             whitespaceBuf = "";
         }
         else
         {
             throw new InvalidTokenException($"Ungültiges Schlüsselwort {buf} gefunden", Data);
         }
         state = INITIAL;
         buf   = "";
     }
 }
Exemplo n.º 20
0
 private void onInitial(char c)
 {
     if (ParserUtil.IsValidNameChar(c))
     {
         buf += c;
     }
     else if (c == '{')
     {
         state = IN_PARAMLIST;
     }
     else if (ParserUtil.IsNewLineOrWhitespace(c) && buf.Length > 0)
     {
         state = BEFORE_PARAMLIST;
     }
     else if (!ParserUtil.IsNewLineOrWhitespace(c))
     {
         throw new InvalidCharException($"Ungültiges Zeichen {c} vor Parameterliste der Config", Data);
     }
 }
Exemplo n.º 21
0
 private void onInRefInterfaceName(char c)
 {
     if (ParserUtil.IsNewLineOrWhitespace(c) && string.IsNullOrEmpty(result.InterfaceName))
     {
         // Ignorieren
     }
     else if (ParserUtil.IsValidNameChar(c))
     {
         result.InterfaceName += c;
     }
     else if (c == '.' && result.InterfaceName.Length > 0)
     {
         state = IN_REF_FIELDNAME;
     }
     else
     {
         throw new InvalidCharException("Ungültiges Zeichen im RefInterfaceName", Data);
     }
 }
Exemplo n.º 22
0
 private void onInAlias(char c)
 {
     if (ParserUtil.IsValidNameChar(c))
     {
         result.Alias += c;
     }
     else if (ParserUtil.IsNewLineOrWhitespace(c) && String.IsNullOrEmpty(result.Alias))
     {
         // Ignorieren
     }
     else if (c == ';')
     {
         state = FINAL;
     }
     else
     {
         throw new InvalidCharException("Ungültiges Zeichen im Alias", Data);
     }
 }
 private void onInName(char c)
 {
     if (c == '=' && result.Name.Length > 0)
     {
         state        = IN_VALUE;
         result.Value = stringElementParser.Parse();
     }
     else if (ParserUtil.IsNewLineOrWhitespace(c) && result.Name.Length > 0)
     {
         state = BEHIND_NAME;
     }
     else if (ParserUtil.IsValidNameChar(c))
     {
         result.Name += c;
     }
     else
     {
         throw new InvalidCharException("Invalid char in param name", Data);
     }
 }
Exemplo n.º 24
0
 private void onInitial(char c)
 {
     if (ParserUtil.IsNewLineOrWhitespace(c) && result.AttributeType.Length == 0)
     {
         // Vorangestellte unsichtbare Zeichen erfassen
         whitespaceBuf += c;
     }
     else if (ParserUtil.IsValidNameChar(c))
     {
         // Wechsel zu InAttributeType
         this.result.WhitespaceBefore = whitespaceBuf;
         this.result.AttributeType   += c;
         this.state    = IN_ATTRIBUTE_TYPE;
         whitespaceBuf = "";
     }
     else
     {
         throw new InvalidCharException("Ungültiges Zeichen ...", Data);
     }
 }
Exemplo n.º 25
0
 private void onInAttributeName(char c)
 {
     if (ParserUtil.IsNewLineOrWhitespace(c) && result.Name.Length == 0)
     {
         // Leerzeichen vor dem Attributnamen ignorieren
     }
     else if (ParserUtil.IsValidNameChar(c))
     {
         // Zeichen ins Namensfeld schreiben
         result.Name += c;
     }
     else if (c == ':')
     {
         state = IN_DATATYPE;
     }
     else
     {
         throw new InvalidCharException("Ungültiges Zeichen im AttributeName", Data);
     }
 }
Exemplo n.º 26
0
 private void onBehindDataType(char c)
 {
     if (ParserUtil.IsNewLineOrWhitespace(c))
     {
         // Ignorieren
     }
     else if (c == 'a' && Data.Content[Data.Position] == 's' && ParserUtil.IsValidDataType(result.DataType))
     {
         Data.Next();
         state = IN_ALIAS;
     }
     else if (c == ';')
     {
         state = FINAL;
     }
     else
     {
         throw new InvalidCharException("Ungültiges Zeichen nach DataType", Data);
     }
 }
Exemplo n.º 27
0
 private void onBehindRefParameters(char c)
 {
     if (ParserUtil.IsNewLineOrWhitespace(c))
     {
         // Ignorieren
     }
     else if (c == 'a' && Data.Content[Data.Position] == 's')
     {
         Data.Next();
         state = IN_ALIAS;
     }
     else if (c == ';')
     {
         state = FINAL;
     }
     else
     {
         throw new InvalidCharException($"Ungültiges Zeichen {c} nach Attribut-Parameterliste", Data);
     }
 }
Exemplo n.º 28
0
        private void onInParamList(char c)
        {
            while (c == '/' || ParserUtil.NextNonWhitespaceIs(Data, '/'))
            {
                if (c == '/')
                {
                    Data.Back(1);
                }
                commentParser.Parse();
                c = ' ';
            }

            var p = this.namedParameterParser.Parse();

            if (p != null)
            {
                this.result.Parameters.Add(p);
            }
            Data.Back(1);
            state = BEHIND_PARAM;
        }
Exemplo n.º 29
0
 private void onInitial(char c)
 {
     if (ParserUtil.IsValidNameChar(c))
     {
         buf += c;
     }
     else if (ParserUtil.IsNewLineOrWhitespace(c) && buf.Length > 0)
     {
         if (buf.Equals("interface"))
         {
             state = IN_INTERFACE_NAME;
         }
         else
         {
             throw new InvalidTokenException($"Ungültiges Token {buf} in InterfaceParser.INITIAL", Data);
         }
         buf = "";
     }
     else
     {
         throw new InvalidCharException($"Ungültiges Zeichen {c} in InterfaceParser.INITIAL", Data);
     }
 }
Exemplo n.º 30
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);
            }
        }