private NodeProperty ParseNodeProperty(Lexer lexer) { NodeProperty result = null; if (lexer.Peek().Type == LexemeType.Letters) { Lexeme identLexeme = lexer.Read(); Lexeme valueLexeme = lexer.Read(); if (valueLexeme.Type == LexemeType.Value) { NodePropertyIdent ident = new NodePropertyIdent(identLexeme.Value); List <string> values = new List <string>(); values.Add(valueLexeme.Value); while (lexer.Peek().Type == LexemeType.Value) { valueLexeme = lexer.Read(); values.Add(valueLexeme.Value); } result = new NodeProperty(ident, values); } else { throw new ArgumentException("Property value expected"); } } return(result); }
private NodeProperties ParseNodeProperties(Lexer lexer) { NodeProperties result = new NodeProperties(); NodeProperty property = ParseNodeProperty(lexer); while (property != null) { result.Add(property); property = ParseNodeProperty(lexer); } return(result); }
private void WriteNodeProperty(NodeProperty nodeProperty, StreamWriter writer) { string[] escapedProperties = new string[] { "RU", "PW" }; if (escapedProperties.Contains(nodeProperty.Ident.Text)) { writer.Write("\n"); } writer.Write(nodeProperty.Ident.Text); nodeProperty.Values.ForEach(value => { writer.Write("["); writer.Write(value); writer.Write("]"); }); }