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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
private void onInBlockComment(char c) { if (c == '*' && ParserUtil.NextNonWhitespaceIs(Data, '/')) { state = FINAL; } else { result.Comment += c; } }
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); } }
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); } }
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); } }
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); } }
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 = ""; } }
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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
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; }
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); } }
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); } }