Skip to content

GSF-17 Correct parsing logic for common expressions in TemplatedExpressionParser#521

Merged
ritchiecarroll merged 4 commits intomasterfrom
GSF-17
Apr 29, 2026
Merged

GSF-17 Correct parsing logic for common expressions in TemplatedExpressionParser#521
ritchiecarroll merged 4 commits intomasterfrom
GSF-17

Conversation

@StephenCWills
Copy link
Copy Markdown
Member

This PR fixes an issue where a template with a common expression that has square brackets nested within it would not parse correctly.

I tested using the program below. Before the changes in this PR, I received the following error.

ExpressionEvaluator.Parser.ExpressionParseException: 'Error parsing token '7' at line 1 char 26'

The expected result is DAMP.MODE50.!.MAG.

using System;
using System.Collections.Generic;
using GSF.Parsing;

namespace TemplatedExpressionParserTest
{
    internal class Program
    {
        static void Main(string[] args)
        {
            TemplatedExpressionParser parser = new TemplatedExpressionParser();
            parser.TemplatedExpression = @"[?{Output}=ModeShapeMagnitude[DAMP.MODE{ModeNum}.eval{'{Input.PointTag}'[7]}.MAG]]";

            Dictionary<string, string> substitutions = new Dictionary<string, string>()
            {
                { "{Output}", "ModeShapeMagnitude" },
                { "{ModeNum}", "50" },
                { "{Input.PointTag}", "GPA_PDC!SHELBY:FREQ" }
            };

            string result = parser.Execute(substitutions);
            Console.WriteLine(result);
        }
    }
}

ritchiecarroll added a commit that referenced this pull request Apr 29, 2026
Covers operator handling, nesting and sibling conditionals, reserved-symbol
escaping, eval{} integration, and the PR #521 regression case (eval{} indexer
inside a conditional result). Also exercises four real-world point-tag
templates from production adapter code.
Copy link
Copy Markdown
Member

@ritchiecarroll ritchiecarroll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor change requested.

Comment thread Source/Libraries/GSF.Core/Parsing/TemplatedExpressionParser.cs
StephenCWills and others added 4 commits April 29, 2026 08:54
Covers operator handling, nesting and sibling conditionals, reserved-symbol
escaping, eval{} integration, and the PR #521 regression case (eval{} indexer
inside a conditional result). Also exercises four real-world point-tag
templates from production adapter code.
@ritchiecarroll ritchiecarroll merged commit ca62711 into master Apr 29, 2026
3 checks passed
@ritchiecarroll ritchiecarroll deleted the GSF-17 branch April 29, 2026 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants