YaccLexTools icon indicating copy to clipboard operation
YaccLexTools copied to clipboard

Buffer Class Visibility

Open Capranaut opened this issue 3 months ago • 2 comments

Section 3.3 of the GPLEX docs call out ScanBuff as "an abstract, public class." I see you overrode that in commit 647ef58. This is causing CS0053 build errors when the .lex file contains the "%visibility public" flag. The .lex file in question works fine with manual builds of GPLEX. Do you have a suggestions for a work around? I tired setting the /noEmbedBuffers flag and adjusting GplexBuffers.cs manually, but it seems gets overridden on build by YaccLexTools.Gplex

Capranaut avatar Nov 16 '25 03:11 Capranaut

Hi @Capranaut, thank you for reporting this issue. I have identified how to fix it, but is needs a patch to the package. In the meanwhile you can patch manually the file GplexBuffers.cs by replacing line 29 with

#if EXPORT_GPPG
public abstract class ScanBuff
#else
internal abstract class ScanBuff
#endif

Then build with defining the constant EXPORT_GPPG

dotnet build /p:DefineConstants=EXPORT_GPPG

ernstc avatar Nov 17 '25 14:11 ernstc

@ernstc Thanks so much! That's certainly a more elegant solution than what I had come up with

<PropertyGroup>
   <BuffFile>GplexBuffers.cs</BuffFile>
 </PropertyGroup>
 <!-- Patches https://github.com/ernstc/YaccLexTools/issues/8 -->
 <Target Name="PatchYaccLexBuild" AfterTargets="YaccLexToolsGplexSingleTarget" BeforeTargets="CoreCompile">
   <CallTarget Targets="YaccLexToolsGplexSingleTarget"/>
   <Message Text="Diagnostic Message: $(BuffFile) not found" Importance="high" Condition="!Exists('$(BuffFile)')"/>
   <Message Text="Patching $(BuffFile) visibility mismatch. Remove once https://github.com/ernstc/YaccLexTools/issues/8 has been resolved." Importance="high" Condition="Exists('$(BuffFile)')"/>
   <Exec Command="powershell -NoProfile -ExecutionPolicy Bypass -Command &quot;(Get-Content -Path '$(BuffFile)' -Raw) -replace 'internal abstract class ScanBuff', 'public abstract class ScanBuff' | Set-Content -Path '$(BuffFile)'&quot;" Condition="Exists('$(BuffFile)')"/>
   <Exec Command="powershell -NoProfile -ExecutionPolicy Bypass -Command &quot;(Get-Content -Path '$(BuffFile)' -Raw) -replace 'internal class BufferException', 'public class BufferException' | Set-Content -Path '$(BuffFile)'&quot;" Condition="Exists('$(BuffFile)')"/>
 </Target>

Capranaut avatar Nov 17 '25 17:11 Capranaut