Skip to content

Commit 31bf706

Browse files
author
Jan Oltmann
committed
Fixed parsing of enum definitions
Fixed the regex for parsing enum definitions, which got broken by a change related to #41.
1 parent ad2305b commit 31bf706

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

DbcParserLib/Parsers/PropertiesDefinitionLineParser.cs

+4-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ internal class PropertiesDefinitionLineParser : ILineParser
99
{
1010
private const string PropertiesDefinitionLineStarter = "BA_DEF_ ";
1111
private const string PropertiesDefinitionDefaultLineStarter = "BA_DEF_DEF_ ";
12-
private const string PropertyDefinitionParsingRegex = @"BA_DEF_(?:\s+(BU_|BO_|SG_|EV_))?\s+""([a-zA-Z_][\w]*)""\s+(?:(?:(INT|HEX)\s+(-?\d+)\s+(-?\d+))|(?:(FLOAT)\s+([\d\+\-eE.]+)\s+([\d\+\-eE.]+))|(STRING)|(?:(ENUM)\s+((?:""[^""]*"",+)*(""[^""]*""))))\s*;";
12+
// language=regex
13+
private const string PropertyDefinitionParsingRegex = @"BA_DEF_(?:\s+(BU_|BO_|SG_|EV_))?\s+""([a-zA-Z_][\w]*)""\s+(?:(?:(INT|HEX)\s+(-?\d+)\s+(-?\d+))|(?:(FLOAT)\s+([\d\+\-eE.]+)\s+([\d\+\-eE.]+))|(STRING)|(?:(ENUM)\s+((?:""[^""]*"",+)*(?:""[^""]*""))))\s*;";
14+
// language=regex
1315
private const string PropertyDefinitionDefaultParsingRegex = @"BA_DEF_DEF_\s+""([a-zA-Z_][\w]*)""\s+(-?\d+|[\d\+\-eE.]+|""[^""]*"")\s*;";
1416

1517
private readonly IParseFailureObserver m_observer;
@@ -93,10 +95,9 @@ public bool TryParse(string line, IDbcBuilder builder, INextLineProvider nextLin
9395
else if (match.Groups[10].Value.StartsWith("ENUM"))
9496
{
9597
dataType = CustomPropertyDataType.Enum;
96-
var enumDefinition = match.Groups[11].Value + match.Groups[12].Value;
9798
customProperty.EnumCustomProperty = new EnumCustomPropertyDefinition
9899
{
99-
Values = enumDefinition.Replace("\"", "").Split(',')
100+
Values = match.Groups[11].Value.Replace("\"", "").Split(',')
100101
};
101102
}
102103
customProperty.DataType = dataType;

0 commit comments

Comments
 (0)