Skip to content

Commit

Permalink
Fixed parsing of enum definitions
Browse files Browse the repository at this point in the history
Fixed the regex for parsing enum definitions, which got broken by a change related to EFeru#41.
  • Loading branch information
Jan Oltmann committed Sep 25, 2023
1 parent ad2305b commit 31bf706
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions DbcParserLib/Parsers/PropertiesDefinitionLineParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ internal class PropertiesDefinitionLineParser : ILineParser
{
private const string PropertiesDefinitionLineStarter = "BA_DEF_ ";
private const string PropertiesDefinitionDefaultLineStarter = "BA_DEF_DEF_ ";
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*;";
// language=regex
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*;";
// language=regex
private const string PropertyDefinitionDefaultParsingRegex = @"BA_DEF_DEF_\s+""([a-zA-Z_][\w]*)""\s+(-?\d+|[\d\+\-eE.]+|""[^""]*"")\s*;";

private readonly IParseFailureObserver m_observer;
Expand Down Expand Up @@ -93,10 +95,9 @@ public bool TryParse(string line, IDbcBuilder builder, INextLineProvider nextLin
else if (match.Groups[10].Value.StartsWith("ENUM"))
{
dataType = CustomPropertyDataType.Enum;
var enumDefinition = match.Groups[11].Value + match.Groups[12].Value;
customProperty.EnumCustomProperty = new EnumCustomPropertyDefinition
{
Values = enumDefinition.Replace("\"", "").Split(',')
Values = match.Groups[11].Value.Replace("\"", "").Split(',')
};
}
customProperty.DataType = dataType;
Expand Down

0 comments on commit 31bf706

Please sign in to comment.