Issue with plcncli deploy parsing

Hi,
I am trying to build a gRPC (present in axc f 2152 sdk) application. The problem is that a header file generated by protoc will generate this error when running the plcncli deploy command:
"src/rpc/exchange.pb.h(352,0): error CPP0005: A parsing exception was thrown.
parsing exception occured while parsing ‘brace_group’ expected ‘(skip([}]) + skip(multiline_ws*))’ at
line number 352, and character number 0

^
Unexpected exception during execution
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter ‘start’)
at PlcNext.Common.Tools.UI.ConsoleUserInterface.g__WrappedConsoleErrorWrite|24_1(Boolean withNewLine, String s) in /builds/toolchains/plcnexttoolchain/P/PlcNextCli/PlcNext.Common/Tools/UI/ConsoleUserInterface.cs:line 242
at PlcNext.Common.Tools.UI.ConsoleUserInterface.PostMessage(ValueTuple3 message) in /builds/toolchains/plcnexttoolchain/P/PlcNextCli/PlcNext.Common/Tools/UI/ConsoleUserInterface.cs:line 193 at PlcNext.Common.Tools.UI.ConsoleUserInterface.WriteError(String message, Boolean withNewLine) in /builds/toolchains/plcnexttoolchain/P/PlcNextCli/PlcNext.Common/Tools/UI/ConsoleUserInterface.cs:line 128 at PlcNext.Common.Tools.ExecutionContext.WriteError(String message, Boolean showUser, Boolean withNewLine) in /builds/toolchains/plcnexttoolchain/P/PlcNextCli/PlcNext.Common/Tools/ExecutionContext.cs:line 97 at PlcNext.Common.Tools.FormattableExceptionHandler.<HandleException>g__WriteError|2_0(FormattableException exception) in /builds/toolchains/plcnexttoolchain/P/PlcNextCli/PlcNext.Common/Tools/FormattableExceptionHandler.cs:line 41 at PlcNext.Common.Tools.FormattableExceptionHandler.HandleException(Exception e) in /builds/toolchains/plcnexttoolchain/P/PlcNextCli/PlcNext.Common/Tools/FormattableExceptionHandler.cs:line 23 at PlcNext.Common.Tools.FormattableExceptionHandler.HandleException(Exception e) in /builds/toolchains/plcnexttoolchain/P/PlcNextCli/PlcNext.Common/Tools/FormattableExceptionHandler.cs:line 32 at PlcNext.Common.Commands.Command1.Execute(CommandArgs args) in /builds/toolchains/plcnexttoolchain/P/PlcNextCli/PlcNext.Common/Commands/Command.cs:line 66
at PlcNext.Common.Commands.CommandManager.Execute(CommandArgs commandArgs) in /builds/toolchains/plcnexttoolchain/P/PlcNextCli/PlcNext.Common/Commands/CommandManager.cs:line 23
at PlcNext.CommandLine.DynamicVerb.Execute(ICommandManager commandManager) in /builds/toolchains/plcnexttoolchain/P/PlcNextCli/PlcNext/CommandLine/DynamicVerb.cs:line 21
at PlcNext.CommandLine.VerbBase.Execute() in /builds/toolchains/plcnexttoolchain/P/PlcNextCli/PlcNext/CommandLine/VerbBase.cs:line 40
at PlcNext.CommandLine.CommandLineParser.Execute(Object verb) in /builds/toolchains/plcnexttoolchain/P/PlcNextCli/PlcNext/CommandLine/CommandLineParser.cs:line 478
at PlcNext.Program.MainAsync(String args) in /builds/toolchains/plcnexttoolchain/P/PlcNextCli/PlcNext/Program.cs:line 62"
The application compiles without error (plcncli build) and the generated header file doesn’t seem to have a brace issue. In any case, the compiler would return an error.
I am using the 2024.0 LTS toolchain.
Can you please help me?
Thank you in advance.

What plcncli project template are you using for this project?
Are you able to give the minimum steps required to reproduce this error, including (minimum) custom code?

Hi,
Thanks for the quick answer.
The project template is “project” (for a RT user program).
To generate the file that gives me the issue (exchange.pb.h), I use protoc 24.4 (it should be compatible with the gRPC version in the SDK according to the PROTOBUF_VERSION const) with the following protobuf “exchange.proto” file:
syntax = “proto3”;

package exchange;

service ExchangeService {
rpc GetState (Empty) returns (State);
}

message Empty {}

message State {
bool input1 = 1;
}

Hi,
I tried “plcncli generate all” with the same file using the latest toolchain 2025.0 preview version and I got the exact same parsing error.

I’m afraid that I’m still not clear on the exact steps to reproduce this error.
For example:
Generate a project using the command
1. plcncli new project --name TestProject
2. ???
3. Generate the intermediate code: plcncli generate code
4. Generate the configuration files: plcncli generate config
What exact steps are required between steps 1 and 3 to reproduce the error?

Step 2 corresponds to the following:
create a “exchange.proto” protobuf file in “src/” which contains:
"
syntax = “proto3”;

package exchange;

service ExchangeService {
rpc GetState (Empty) returns (State);
}

message Empty {}

message State {
bool input1 = 1;
}
"
CD to “src/” directory
generate C++ code with “protoc --cpp_out=./ exchange.proto” using protoc 24.4 (which seems to be compatible with the gRPC version in axc f 2152 sdk 2024.0)
Then step 3: plcncli generate config/code/all (I get the same error whichever I try). Returned error is:
“exchange.pb.h(407,0): error CPP0005: A parsing exception was thrown.
parsing exception occured while parsing ‘brace_group’ expected ‘(skip([}]) + skip(multiline_ws*))’ at line number 407, and character number 0”

Ok, I have reproduced this and I can see the issue.
The plcncli code parser looks for certain patterns in the source files (in the src folder), in order to generate the intermediate code and configuration files. The contents of the file exchange.pb.h seem to be confusing the plcncli parser.
It’s not necessary for the parser to look at any files other than the Program and Component files in the src folder. In the absence of an “ignore” option in the plcncli command, there are two options:

                * Generate the code and config files first, then generate the other files in the src directory using protoc.
                * Put the protobuf files in a different directory - alongside the "src" and "intermediate" directories, both of which contain source code - and edit the CMakeLists.txt file to include that new source directory in the build.

If the protobuf files aren’t in the src folder, then they shouldn’t cause a problem for the plcncli parser.

I moved the protoc generated files to another folder and updated CMakeList and it finally works, thanks a lot!
Do you want me to open an issue on the plcncli github repo?

It’s more a documentation issue than anything else - the plcncli code parser is relatively simple, it’s only a support tool (not a requirement) to help with initial project setup, and it will never be able to anticipate all the possible constructs in third-party source code that might cause it problems. It would be a good idea if issues like this were documented, so yes - feel free to open an issue in Github.