Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Allow ValueTableLineParser to handle the case of (number " ") without… #55

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion DbcParserLib/Parsers/ValueTableLineParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ internal class ValueTableLineParser : ILineParser
private const string ValueTableLineStarter = "VAL_ ";
private const string ValueTableLinkParsingRegex = @"VAL_\s+(\d+)\s+([a-zA-Z_][\w]*)\s+([a-zA-Z_][\w]*)\s*;";
private const string ValueTableParsingRegex = @"VAL_\s+(?:(?:(\d+)\s+([a-zA-Z_][\w]*))|([a-zA-Z_][\w]*))\s+((?:(?:-?\d+)\s+(?:""[^""]*"")\s+)*)\s*;";
private const string ValueTableNewLineRegex = @"(""[^""]*""\s+)";
private const string ValueTableNewLineRegexReplace = "$1\n";

private readonly IParseFailureObserver m_observer;

Expand All @@ -34,7 +36,7 @@ public bool TryParse(string line, IDbcBuilder builder, INextLineProvider nextLin
match = Regex.Match(cleanLine, ValueTableParsingRegex);
if (match.Success)
{
var valueTable = match.Groups[4].Value.TrimStart().Replace("\" ", "\"" + Environment.NewLine);
var valueTable = Regex.Replace(match.Groups[4].Value.TrimStart(), ValueTableNewLineRegex, ValueTableNewLineRegexReplace);
var valueTableDictionary = valueTable.ToDictionary();
if (match.Groups[3].Value != "")
builder.LinkTableValuesToEnvironmentVariable(match.Groups[3].Value, valueTableDictionary);
Expand Down