Init
This commit is contained in:
1
.vs/Supercharger/Tiger/codemap.dat
Normal file
1
.vs/Supercharger/Tiger/codemap.dat
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<ProjectData xmlns="http://schemas.datacontract.org/2004/07/BG8.Supercharger.Features.CodeMap" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><ProjectAllTimeMostUsedData xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays"><a:KeyValueOfstringProjectItemDataOfAllTimeMostUsedDataItemIPg14zztYaWdJY9w><a:Key>Program.cs</a:Key><a:Value><DataItems/><ProjectItemFileName>Program.cs</ProjectItemFileName></a:Value></a:KeyValueOfstringProjectItemDataOfAllTimeMostUsedDataItemIPg14zztYaWdJY9w></ProjectAllTimeMostUsedData><ProjectExpandedStateData xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays"><a:KeyValueOfstringProjectItemDataOfExpandedStateDataItemIPg14zztYaWdJY9w><a:Key>Program.cs</a:Key><a:Value><DataItems/><ProjectItemFileName>Program.cs</ProjectItemFileName></a:Value></a:KeyValueOfstringProjectItemDataOfExpandedStateDataItemIPg14zztYaWdJY9w></ProjectExpandedStateData><ProjectFavoriteData xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays"><a:KeyValueOfstringProjectItemDataOfFavoriteDataItemIPg14zztYaWdJY9w><a:Key>Program.cs</a:Key><a:Value><DataItems/><ProjectItemFileName>Program.cs</ProjectItemFileName></a:Value></a:KeyValueOfstringProjectItemDataOfFavoriteDataItemIPg14zztYaWdJY9w></ProjectFavoriteData><ProjectHistoryData xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays"><a:KeyValueOfstringProjectItemDataOfHistoryDataItemIPg14zztYaWdJY9w><a:Key>Program.cs</a:Key><a:Value><DataItems><HistoryDataItem><Char>3615</Char><CodeMapItemPath>Program#Main</CodeMapItemPath><HistoryLevel>1</HistoryLevel><HistoryTimeStamp>2023-09-06T08:41:47.5530823+02:00</HistoryTimeStamp><Line>0</Line><ParameterList>string[]</ParameterList></HistoryDataItem></DataItems><ProjectItemFileName>Program.cs</ProjectItemFileName></a:Value></a:KeyValueOfstringProjectItemDataOfHistoryDataItemIPg14zztYaWdJY9w></ProjectHistoryData><ProjectInCodeHighlightData xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays"><a:KeyValueOfstringProjectItemDataOfInCodeHighlightDataItemIPg14zztYaWdJY9w><a:Key>Program.cs</a:Key><a:Value><DataItems/><ProjectItemFileName>Program.cs</ProjectItemFileName></a:Value></a:KeyValueOfstringProjectItemDataOfInCodeHighlightDataItemIPg14zztYaWdJY9w></ProjectInCodeHighlightData><ProjectMiniViewData xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays"><a:KeyValueOfstringProjectItemDataOfMiniViewDataItemIPg14zztYaWdJY9w><a:Key>Program.cs</a:Key><a:Value><DataItems/><ProjectItemFileName>Program.cs</ProjectItemFileName></a:Value></a:KeyValueOfstringProjectItemDataOfMiniViewDataItemIPg14zztYaWdJY9w></ProjectMiniViewData><ProjectName>Tiger</ProjectName></ProjectData>
|
||||||
1
.vs/Supercharger/Tiger/global_history.dat
Normal file
1
.vs/Supercharger/Tiger/global_history.dat
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<ProjectData xmlns="http://schemas.datacontract.org/2004/07/BG8.Supercharger.Features.CodeMap.GlobalHistory" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><ProjectGlobalHistoryData xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays"><a:KeyValueOfstringProjectItemDatajRe1r2YW><a:Key>D:\yatc\YATC.Compiler\Program.cs</a:Key><a:Value><DataItems><GlobalHistoryDataItem><ID>YATC.Compiler.Program.Mainstatic##int#string[]</ID><ImageSource>img\tvi\x_method-s_private-i_static</ImageSource><IsPinned>false</IsPinned><IsPublic>false</IsPublic><ItemName>Main</ItemName><ItemPath>YATC.Compiler.Program</ItemPath><ProjectFullName>D:\yatc\YATC.Compiler\Tiger.csproj</ProjectFullName><ProjectItemFileName>D:\yatc\YATC.Compiler\Program.cs</ProjectItemFileName><TimeStamp>2023-09-06T08:43:08.8339312+02:00</TimeStamp></GlobalHistoryDataItem><GlobalHistoryDataItem><ID>YATC.Compiler.Program.Printstatic##void#CommonTree</ID><ImageSource>img\tvi\x_method-s_private-i_static</ImageSource><IsPinned>false</IsPinned><IsPublic>false</IsPublic><ItemName>Print</ItemName><ItemPath>YATC.Compiler.Program</ItemPath><ProjectFullName>D:\yatc\YATC.Compiler\Tiger.csproj</ProjectFullName><ProjectItemFileName>D:\yatc\YATC.Compiler\Program.cs</ProjectItemFileName><TimeStamp>2023-09-06T08:43:02.6982502+02:00</TimeStamp></GlobalHistoryDataItem></DataItems><ProjectItemFileName>D:\yatc\YATC.Compiler\Program.cs</ProjectItemFileName></a:Value></a:KeyValueOfstringProjectItemDatajRe1r2YW></ProjectGlobalHistoryData><ProjectName>Tiger</ProjectName></ProjectData>
|
||||||
1
.vs/Supercharger/Tiger/workbench.dat
Normal file
1
.vs/Supercharger/Tiger/workbench.dat
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<ProjectData xmlns="http://schemas.datacontract.org/2004/07/BG8.Supercharger.Features.CodeMap.Gss" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><DataItems/><ProjectName>Tiger</ProjectName></ProjectData>
|
||||||
1
.vs/Supercharger/YATC/codemap.dat
Normal file
1
.vs/Supercharger/YATC/codemap.dat
Normal file
File diff suppressed because one or more lines are too long
1
.vs/Supercharger/YATC/global_history.dat
Normal file
1
.vs/Supercharger/YATC/global_history.dat
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<ProjectData xmlns="http://schemas.datacontract.org/2004/07/BG8.Supercharger.Features.CodeMap.GlobalHistory" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><ProjectGlobalHistoryData xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays"><a:KeyValueOfstringProjectItemDatajRe1r2YW><a:Key>D:\yatc\Grammar\tigerLexer.cs</a:Key><a:Value><DataItems><GlobalHistoryDataItem><ID>YATC.Grammar.tigerLexer.mFUNCTIONKEY#void#</ID><ImageSource>img\tvi\x_method-s_private-i_instance</ImageSource><IsPinned>false</IsPinned><IsPublic>false</IsPublic><ItemName>mFUNCTIONKEY</ItemName><ItemPath>YATC.Grammar.tigerLexer</ItemPath><ProjectFullName>D:\yatc\YATC\YATC.csproj</ProjectFullName><ProjectItemFileName>D:\yatc\Grammar\tigerLexer.cs</ProjectItemFileName><TimeStamp>2023-09-06T09:21:05.7326172+02:00</TimeStamp></GlobalHistoryDataItem></DataItems><ProjectItemFileName>D:\yatc\Grammar\tigerLexer.cs</ProjectItemFileName></a:Value></a:KeyValueOfstringProjectItemDatajRe1r2YW><a:KeyValueOfstringProjectItemDatajRe1r2YW><a:Key>D:\yatc\Grammar\tigerParser.cs</a:Key><a:Value><DataItems><GlobalHistoryDataItem><ID>YATC.Grammar.tigerParser.GrammarFileName</ID><ImageSource>img\tvi\x_property_override-s_public-i_instance</ImageSource><IsPinned>false</IsPinned><IsPublic>true</IsPublic><ItemName>GrammarFileName</ItemName><ItemPath>YATC.Grammar.tigerParser</ItemPath><ProjectFullName>D:\yatc\YATC\YATC.csproj</ProjectFullName><ProjectItemFileName>D:\yatc\Grammar\tigerParser.cs</ProjectItemFileName><TimeStamp>2023-09-06T08:56:49.7403958+02:00</TimeStamp></GlobalHistoryDataItem></DataItems><ProjectItemFileName>D:\yatc\Grammar\tigerParser.cs</ProjectItemFileName></a:Value></a:KeyValueOfstringProjectItemDatajRe1r2YW><a:KeyValueOfstringProjectItemDatajRe1r2YW><a:Key>D:\yatc\YATC\ASTNodes\ProgramNode.cs</a:Key><a:Value><DataItems><GlobalHistoryDataItem><ID>YATC.ASTNodes.ProgramNode.AddStdLib#void#</ID><ImageSource>img\tvi\x_method-s_private-i_instance</ImageSource><IsPinned>false</IsPinned><IsPublic>false</IsPublic><ItemName>AddStdLib</ItemName><ItemPath>YATC.ASTNodes.ProgramNode</ItemPath><ProjectFullName>D:\yatc\YATC\YATC.csproj</ProjectFullName><ProjectItemFileName>D:\yatc\YATC\ASTNodes\ProgramNode.cs</ProjectItemFileName><TimeStamp>2023-09-06T08:56:15.8291369+02:00</TimeStamp></GlobalHistoryDataItem><GlobalHistoryDataItem><ID>YATC.ASTNodes.ProgramNode</ID><ImageSource>img\tvi\y_class-s_public-i_instance</ImageSource><IsPinned>false</IsPinned><IsPublic>false</IsPublic><ItemName>ProgramNode</ItemName><ItemPath>YATC.ASTNodes</ItemPath><ProjectFullName>D:\yatc\YATC\YATC.csproj</ProjectFullName><ProjectItemFileName>D:\yatc\YATC\ASTNodes\ProgramNode.cs</ProjectItemFileName><TimeStamp>2023-09-06T08:55:41.7786924+02:00</TimeStamp></GlobalHistoryDataItem></DataItems><ProjectItemFileName>D:\yatc\YATC\ASTNodes\ProgramNode.cs</ProjectItemFileName></a:Value></a:KeyValueOfstringProjectItemDatajRe1r2YW></ProjectGlobalHistoryData><ProjectName>YATC</ProjectName></ProjectData>
|
||||||
1
.vs/Supercharger/YATC/workbench.dat
Normal file
1
.vs/Supercharger/YATC/workbench.dat
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<ProjectData xmlns="http://schemas.datacontract.org/2004/07/BG8.Supercharger.Features.CodeMap.Gss" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><DataItems/><ProjectName>YATC</ProjectName></ProjectData>
|
||||||
1
.vs/Supercharger/_/DTabsHistory.dat
Normal file
1
.vs/Supercharger/_/DTabsHistory.dat
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<ArrayOfstring xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><string>D:0:0:{00000000-0000-0000-0000-000000000000}|<Solution>|Tiger||{95501C48-A850-47C1-A785-2AAA96637F81}</string><string>D:0:0:{8B1FA297-B497-4F06-A6AE-87D73920AA57}|YATC.Compiler\Tiger.csproj|d:\yatc\yatc.compiler\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}</string></ArrayOfstring>
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -11,6 +11,8 @@
|
|||||||
<AssemblyName>tiger</AssemblyName>
|
<AssemblyName>tiger</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<NuGetPackageImportStamp>
|
||||||
|
</NuGetPackageImportStamp>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
@@ -32,8 +34,8 @@
|
|||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Antlr3.Runtime">
|
<Reference Include="Antlr3.Runtime, Version=3.5.0.2, Culture=neutral, PublicKeyToken=eb42632606e9261f, processorArchitecture=MSIL">
|
||||||
<HintPath>..\Antlr3.Runtime.dll</HintPath>
|
<HintPath>..\packages\Antlr3.Runtime.3.5.1\lib\net40-client\Antlr3.Runtime.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
@@ -49,6 +51,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="App.config" />
|
<None Include="App.config" />
|
||||||
|
<None Include="packages.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\YATC\YATC.csproj">
|
<ProjectReference Include="..\YATC\YATC.csproj">
|
||||||
|
|||||||
5
YATC.Compiler/packages.config
Normal file
5
YATC.Compiler/packages.config
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="Antlr3.Runtime" version="3.5.1" targetFramework="net45" />
|
||||||
|
<package id="Antlr34" version="3.4.19004.1" targetFramework="net45" />
|
||||||
|
</packages>
|
||||||
@@ -31,8 +31,8 @@
|
|||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Antlr3.Runtime">
|
<Reference Include="Antlr3.Runtime, Version=3.5.0.2, Culture=neutral, PublicKeyToken=eb42632606e9261f, processorArchitecture=MSIL">
|
||||||
<HintPath>..\Antlr3.Runtime.dll</HintPath>
|
<HintPath>..\packages\Antlr.3.5.0.2\lib\Antlr3.Runtime.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
@@ -134,6 +134,9 @@
|
|||||||
<CustomToolNamespace>YATC.Grammar</CustomToolNamespace>
|
<CustomToolNamespace>YATC.Grammar</CustomToolNamespace>
|
||||||
</Antlr3>
|
</Antlr3>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="packages.config" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
|||||||
4
YATC/packages.config
Normal file
4
YATC/packages.config
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="Antlr" version="3.5.0.2" targetFramework="net40" />
|
||||||
|
</packages>
|
||||||
BIN
packages/Antlr.3.5.0.2/.signature.p7s
vendored
Normal file
BIN
packages/Antlr.3.5.0.2/.signature.p7s
vendored
Normal file
Binary file not shown.
BIN
packages/Antlr.3.5.0.2/Antlr.3.5.0.2.nupkg
vendored
Normal file
BIN
packages/Antlr.3.5.0.2/Antlr.3.5.0.2.nupkg
vendored
Normal file
Binary file not shown.
BIN
packages/Antlr.3.5.0.2/lib/Antlr3.Runtime.dll
vendored
Normal file
BIN
packages/Antlr.3.5.0.2/lib/Antlr3.Runtime.dll
vendored
Normal file
Binary file not shown.
BIN
packages/Antlr3.Runtime.3.5.1/.signature.p7s
vendored
Normal file
BIN
packages/Antlr3.Runtime.3.5.1/.signature.p7s
vendored
Normal file
Binary file not shown.
BIN
packages/Antlr3.Runtime.3.5.1/Antlr3.Runtime.3.5.1.nupkg
vendored
Normal file
BIN
packages/Antlr3.Runtime.3.5.1/Antlr3.Runtime.3.5.1.nupkg
vendored
Normal file
Binary file not shown.
BIN
packages/Antlr3.Runtime.3.5.1/lib/net20/Antlr3.Runtime.dll
vendored
Normal file
BIN
packages/Antlr3.Runtime.3.5.1/lib/net20/Antlr3.Runtime.dll
vendored
Normal file
Binary file not shown.
3249
packages/Antlr3.Runtime.3.5.1/lib/net20/Antlr3.Runtime.xml
vendored
Normal file
3249
packages/Antlr3.Runtime.3.5.1/lib/net20/Antlr3.Runtime.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
packages/Antlr3.Runtime.3.5.1/lib/net40-client/Antlr3.Runtime.dll
vendored
Normal file
BIN
packages/Antlr3.Runtime.3.5.1/lib/net40-client/Antlr3.Runtime.dll
vendored
Normal file
Binary file not shown.
3249
packages/Antlr3.Runtime.3.5.1/lib/net40-client/Antlr3.Runtime.xml
vendored
Normal file
3249
packages/Antlr3.Runtime.3.5.1/lib/net40-client/Antlr3.Runtime.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
packages/Antlr3.Runtime.3.5.1/lib/netstandard1.1/Antlr3.Runtime.dll
vendored
Normal file
BIN
packages/Antlr3.Runtime.3.5.1/lib/netstandard1.1/Antlr3.Runtime.dll
vendored
Normal file
Binary file not shown.
3220
packages/Antlr3.Runtime.3.5.1/lib/netstandard1.1/Antlr3.Runtime.xml
vendored
Normal file
3220
packages/Antlr3.Runtime.3.5.1/lib/netstandard1.1/Antlr3.Runtime.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
BIN
packages/Antlr34.3.4.19004.1/.signature.p7s
vendored
Normal file
BIN
packages/Antlr34.3.4.19004.1/.signature.p7s
vendored
Normal file
Binary file not shown.
BIN
packages/Antlr34.3.4.19004.1/Antlr34.3.4.19004.1.nupkg
vendored
Normal file
BIN
packages/Antlr34.3.4.19004.1/Antlr34.3.4.19004.1.nupkg
vendored
Normal file
Binary file not shown.
BIN
packages/Antlr34.3.4.19004.1/lib/Antlr3.Runtime.dll
vendored
Normal file
BIN
packages/Antlr34.3.4.19004.1/lib/Antlr3.Runtime.dll
vendored
Normal file
Binary file not shown.
BIN
packages/Antlr34.3.4.19004.1/tools/Antlr3.Runtime.Debug.dll
vendored
Normal file
BIN
packages/Antlr34.3.4.19004.1/tools/Antlr3.Runtime.Debug.dll
vendored
Normal file
Binary file not shown.
BIN
packages/Antlr34.3.4.19004.1/tools/Antlr3.Runtime.JavaExtensions.dll
vendored
Normal file
BIN
packages/Antlr34.3.4.19004.1/tools/Antlr3.Runtime.JavaExtensions.dll
vendored
Normal file
Binary file not shown.
BIN
packages/Antlr34.3.4.19004.1/tools/Antlr3.Runtime.dll
vendored
Normal file
BIN
packages/Antlr34.3.4.19004.1/tools/Antlr3.Runtime.dll
vendored
Normal file
Binary file not shown.
3
packages/Antlr34.3.4.19004.1/tools/Antlr3.exe.config
vendored
Normal file
3
packages/Antlr34.3.4.19004.1/tools/Antlr3.exe.config
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<configuration>
|
||||||
|
<startup><supportedRuntime version="v2.0.50727" sku="Client"/></startup></configuration>
|
||||||
163
packages/Antlr34.3.4.19004.1/tools/Antlr3.targets
vendored
Normal file
163
packages/Antlr34.3.4.19004.1/tools/Antlr3.targets
vendored
Normal file
@@ -0,0 +1,163 @@
|
|||||||
|
<!--
|
||||||
|
[The "BSD licence"]
|
||||||
|
Copyright (c) 2011 Sam Harwell
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions
|
||||||
|
are met:
|
||||||
|
1. Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
3. The name of the author may not be used to endorse or promote products
|
||||||
|
derived from this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
-->
|
||||||
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<BuildSystem>MSBuild</BuildSystem>
|
||||||
|
<TaskVersion>3.3.0.7239</TaskVersion>
|
||||||
|
<TaskKeyToken>eb42632606e9261f</TaskKeyToken>
|
||||||
|
<AntlrBuildTaskAssemblyName Condition="'$(AntlrBuildTaskAssemblyName)'==''">AntlrBuildTask, Version=$(TaskVersion), Culture=neutral, PublicKeyToken=$(TaskKeyToken)</AntlrBuildTaskAssemblyName>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<!--<PropertyGroup>
|
||||||
|
<LoadTimeSensitiveTargets>
|
||||||
|
$(LoadTimeSensitiveTargets);
|
||||||
|
AntlrCompile;
|
||||||
|
</LoadTimeSensitiveTargets>
|
||||||
|
<LoadTimeSensitiveProperties>
|
||||||
|
$(LoadTimeSensitiveProperties);
|
||||||
|
AntlrCompileDependsOn;
|
||||||
|
</LoadTimeSensitiveProperties>
|
||||||
|
|
||||||
|
|
||||||
|
<PrepareResourcesDependsOn>
|
||||||
|
AntlrCompile;
|
||||||
|
$(PrepareResourcesDependsOn)
|
||||||
|
</PrepareResourcesDependsOn>
|
||||||
|
</PropertyGroup>-->
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<AntlrBuildTaskLocation Condition="'$(AntlrBuildTaskPath)'==''">$(MSBuildBinPath)</AntlrBuildTaskLocation>
|
||||||
|
<AntlrBuildTaskLocation Condition="'$(AntlrBuildTaskPath)'!=''">$(AntlrBuildTaskPath)</AntlrBuildTaskLocation>
|
||||||
|
<AntlrToolLocation Condition="'$(AntlrToolPath)'==''">$(MSBuildBinPath)\Antlr3\Antlr3.exe</AntlrToolLocation>
|
||||||
|
<AntlrToolLocation Condition="'$(AntlrToolPath)'!=''">$(AntlrToolPath)</AntlrToolLocation>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<AntlrGenCodeFileNames Condition="'$(AntlrGenCodeFileNames)'==''">$(MSBuildProjectFile).AntlrGeneratedCodeFileListAbsolute.txt</AntlrGenCodeFileNames>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<UsingTask Condition="'$(AntlrBuildTaskPath)'==''" TaskName="Antlr3.Build.Tasks.AntlrClassGenerationTask" AssemblyName="$(AntlrBuildTaskAssemblyName)" />
|
||||||
|
<UsingTask Condition="'$(AntlrBuildTaskPath)'!=''" TaskName="Antlr3.Build.Tasks.AntlrClassGenerationTask" AssemblyFile="$(AntlrBuildTaskPath)\AntlrBuildTask.dll" />
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<PrepareResourcesDependsOn>
|
||||||
|
AntlrCompile;
|
||||||
|
AntlrCompileAddFilesGenerated;
|
||||||
|
$(PrepareResourcesDependsOn)
|
||||||
|
</PrepareResourcesDependsOn>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<AntlrCompileDependsOn>
|
||||||
|
AntlrCompileReadGeneratedFileList
|
||||||
|
</AntlrCompileDependsOn>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup Condition="'$(BuildingInsideVisualStudio)'=='true'">
|
||||||
|
<AvailableItemName Include="Antlr3" />
|
||||||
|
<AvailableItemName Include="AntlrTokens" />
|
||||||
|
<AvailableItemName Include="AntlrAbstractGrammar" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Target Name="AntlrCompileReadGeneratedFileList">
|
||||||
|
<ReadLinesFromFile File="$(IntermediateOutputPath)$(AntlrGenCodeFileNames)">
|
||||||
|
<Output TaskParameter="Lines" ItemName="AntlrOutputCodeFilesList"/>
|
||||||
|
</ReadLinesFromFile>
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<!-- Add grammar compilation to the CoreCompileDependsOn so that the IDE inproc compilers (particularly VB)
|
||||||
|
can "see" the generated source files. -->
|
||||||
|
<CoreCompileDependsOn Condition="'$(BuildingInsideVisualStudio)' == 'true' ">
|
||||||
|
DesignTimeGrammarCompilation;
|
||||||
|
$(CoreCompileDependsOn)
|
||||||
|
</CoreCompileDependsOn>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<Target Name="DesignTimeGrammarCompilation">
|
||||||
|
<!-- Only if we are not actually performing a compile i.e. we are in design mode -->
|
||||||
|
<CallTarget Condition="'$(BuildingProject)' != 'true'"
|
||||||
|
Targets="AntlrCompile" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="AntlrCompile"
|
||||||
|
DependsOnTargets="$(AntlrCompileDependsOn)"
|
||||||
|
Condition="'@(Antlr3)' != ''"
|
||||||
|
Inputs="@(Antlr3);@(AntlrTokens);@(AntlrAbstractGrammar)"
|
||||||
|
Outputs="@(AntlrOutputCodeFilesList);
|
||||||
|
$(IntermediateOutputPath)$(AntlrGenCodeFileNames);">
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<AntlrGeneratedCodeFiles Remove="@(AntlrGeneratedCodeFiles)" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<_IntellisenseOnlyCompile>false</_IntellisenseOnlyCompile>
|
||||||
|
<_IntellisenseOnlyCompile Condition="'$(BuildingProject)' != 'true'">true</_IntellisenseOnlyCompile>
|
||||||
|
</PropertyGroup>
|
||||||
|
<AntlrClassGenerationTask
|
||||||
|
AntlrToolPath="$(AntlrToolLocation)"
|
||||||
|
BuildTaskPath="$(AntlrBuildTaskLocation)"
|
||||||
|
OutputPath="$(IntermediateOutputPath)"
|
||||||
|
Language="$(Language)"
|
||||||
|
SourceCodeFiles="@(Antlr3)"
|
||||||
|
ContinueOnError="$(_IntellisenseOnlyCompile)"
|
||||||
|
TokensFiles="@(AntlrTokens)"
|
||||||
|
AbstractGrammarFiles="@(AntlrAbstractGrammar)">
|
||||||
|
|
||||||
|
<Output ItemName="AntlrGeneratedCodeFiles" TaskParameter="GeneratedCodeFiles" />
|
||||||
|
<Output ItemName="Compile" TaskParameter="GeneratedCodeFiles" />
|
||||||
|
</AntlrClassGenerationTask>
|
||||||
|
|
||||||
|
<WriteLinesToFile
|
||||||
|
Condition="'$(_IntellisenseOnlyCompile)' != 'true'"
|
||||||
|
File="$(IntermediateOutputPath)$(AntlrGenCodeFileNames)"
|
||||||
|
Lines="@(AntlrGeneratedCodeFiles)"
|
||||||
|
Overwrite="true"/>
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="AntlrCompileAddFilesGenerated"
|
||||||
|
DependsOnTargets="AntlrCompile"
|
||||||
|
Condition="'@(Antlr3)' != ''">
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Condition="'@(AntlrGeneratedCodeFiles)' == ''" Include="@(AntlrOutputCodeFilesList)" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<_AntlrCodeGenFileWrites Condition="'@(AntlrGeneratedCodeFiles)' != ''" Include="@(AntlrGeneratedCodeFiles)" />
|
||||||
|
<_AntlrCodeGenFileWrites Condition="'@(AntlrGeneratedCodeFiles)' == ''" Include="@(AntlrOutputCodeFilesList)" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<FileWrites Include="@(_AntlrCodeGenFileWrites);
|
||||||
|
$(IntermediateOutputPath)$(AntlrGenCodeFileNames);" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Target>
|
||||||
|
</Project>
|
||||||
BIN
packages/Antlr34.3.4.19004.1/tools/Antlr4.StringTemplate.Visualizer.dll
vendored
Normal file
BIN
packages/Antlr34.3.4.19004.1/tools/Antlr4.StringTemplate.Visualizer.dll
vendored
Normal file
Binary file not shown.
BIN
packages/Antlr34.3.4.19004.1/tools/Antlr4.StringTemplate.dll
vendored
Normal file
BIN
packages/Antlr34.3.4.19004.1/tools/Antlr4.StringTemplate.dll
vendored
Normal file
Binary file not shown.
BIN
packages/Antlr34.3.4.19004.1/tools/AntlrBuildTask.dll
vendored
Normal file
BIN
packages/Antlr34.3.4.19004.1/tools/AntlrBuildTask.dll
vendored
Normal file
Binary file not shown.
430
packages/Antlr34.3.4.19004.1/tools/Codegen/Templates/CSharp2/AST.stg
vendored
Normal file
430
packages/Antlr34.3.4.19004.1/tools/Codegen/Templates/CSharp2/AST.stg
vendored
Normal file
@@ -0,0 +1,430 @@
|
|||||||
|
/*
|
||||||
|
* [The "BSD license"]
|
||||||
|
* Copyright (c) 2007-2008 Johannes Luber
|
||||||
|
* Copyright (c) 2005-2007 Kunle Odutola
|
||||||
|
* Copyright (c) 2011 Sam Harwell
|
||||||
|
* Copyright (c) 2011 Terence Parr
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@outputFile.imports() ::= <<
|
||||||
|
<@super.imports()>
|
||||||
|
|
||||||
|
<if(!TREE_PARSER)>
|
||||||
|
<! tree parser would already have imported !>
|
||||||
|
using Antlr.Runtime.Tree;
|
||||||
|
using RewriteRuleITokenStream = Antlr.Runtime.Tree.RewriteRuleTokenStream;
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
@genericParser.members() ::= <<
|
||||||
|
<@super.members()>
|
||||||
|
<parserMembers()>
|
||||||
|
>>
|
||||||
|
|
||||||
|
parserCtorBody() ::= <%
|
||||||
|
<super.parserCtorBody()><\n>
|
||||||
|
TreeAdaptor =
|
||||||
|
<if(actions.(actionScope).treeAdaptorInitializer)>
|
||||||
|
<actions.(actionScope).treeAdaptorInitializer>
|
||||||
|
<else>
|
||||||
|
new <actions.(actionScope).treeAdaptorType; null="CommonTreeAdaptor">()
|
||||||
|
<end>
|
||||||
|
;
|
||||||
|
%>
|
||||||
|
|
||||||
|
/** Add an adaptor property that knows how to build trees */
|
||||||
|
parserMembers() ::= <<
|
||||||
|
private <treeAdaptorType()> adaptor;
|
||||||
|
|
||||||
|
public <treeAdaptorType()> TreeAdaptor
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return adaptor;
|
||||||
|
}
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this.adaptor = value;
|
||||||
|
<grammar.directDelegates:{g|<g:delegateName()>.TreeAdaptor = this.adaptor;}>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
>>
|
||||||
|
|
||||||
|
treeAdaptorType() ::= <<
|
||||||
|
<actions.(actionScope).treeAdaptorType; null="ITreeAdaptor">
|
||||||
|
>>
|
||||||
|
|
||||||
|
ruleReturnBaseType() ::= <%
|
||||||
|
Ast<if(TREE_PARSER)>Tree<else>Parser<endif>RuleReturnScope\<<ASTLabelType>, <labelType>>
|
||||||
|
%>
|
||||||
|
|
||||||
|
/** Add a variable to track rule's return AST */
|
||||||
|
ruleDeclarations() ::= <<
|
||||||
|
<super.ruleDeclarations()>
|
||||||
|
<ASTLabelType> root_0 = default(<ASTLabelType>);<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
ruleLabelDefs() ::= <<
|
||||||
|
<super.ruleLabelDefs()>
|
||||||
|
<[ruleDescriptor.tokenLabels,ruleDescriptor.wildcardTreeLabels,ruleDescriptor.wildcardTreeListLabels]
|
||||||
|
:{it|<ASTLabelType> <it.label.text>_tree = default(<ASTLabelType>);}; separator="\n">
|
||||||
|
<ruleDescriptor.tokenListLabels:{it|<ASTLabelType> <it.label.text>_tree = default(<ASTLabelType>);}; separator="\n">
|
||||||
|
<ruleDescriptor.allTokenRefsInAltsWithRewrites
|
||||||
|
:{it|RewriteRule<rewriteElementType>Stream stream_<it>=new RewriteRule<rewriteElementType>Stream(adaptor,"token <it>");}; separator="\n">
|
||||||
|
<ruleDescriptor.allRuleRefsInAltsWithRewrites
|
||||||
|
:{it|RewriteRuleSubtreeStream stream_<it>=new RewriteRuleSubtreeStream(adaptor,"rule <it>");}; separator="\n">
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** When doing auto AST construction, we must define some variables;
|
||||||
|
* These should be turned off if doing rewrites. This must be a "mode"
|
||||||
|
* as a rule could have both rewrite and AST within the same alternative
|
||||||
|
* block.
|
||||||
|
*/
|
||||||
|
@alt.declarations() ::= <<
|
||||||
|
<if(autoAST)>
|
||||||
|
<if(outerAlt)>
|
||||||
|
<if(!rewriteMode)>
|
||||||
|
root_0 = (<ASTLabelType>)adaptor.Nil();
|
||||||
|
<endif>
|
||||||
|
<endif>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
// T r a c k i n g R u l e E l e m e n t s
|
||||||
|
|
||||||
|
/** ID and track it for use in a rewrite rule */
|
||||||
|
tokenRefTrack(token,label,elementIndex,terminalOptions) ::= <<
|
||||||
|
<tokenRefBang(...)> <! Track implies no auto AST construction!>
|
||||||
|
<if(backtracking)>if (<actions.(actionScope).synpredgate>) <endif>stream_<token>.Add(<label>);<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** ids+=ID and track it for use in a rewrite rule; adds to ids *and*
|
||||||
|
* to the tracking list stream_ID for use in the rewrite.
|
||||||
|
*/
|
||||||
|
tokenRefTrackAndListLabel(token,label,elementIndex,terminalOptions) ::= <<
|
||||||
|
<tokenRefTrack(...)>
|
||||||
|
<listLabelElem(elem=label,elemType=labelType,...)>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** ^(ID ...) track for rewrite */
|
||||||
|
tokenRefRuleRootTrack(token,label,elementIndex,terminalOptions) ::= <<
|
||||||
|
<tokenRefBang(...)>
|
||||||
|
<if(backtracking)>if (<actions.(actionScope).synpredgate>) <endif>stream_<token>.Add(<label>);
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** Match ^(label+=TOKEN ...) track for rewrite */
|
||||||
|
tokenRefRuleRootTrackAndListLabel(token,label,elementIndex,terminalOptions) ::= <<
|
||||||
|
<tokenRefRuleRootTrack(...)>
|
||||||
|
<listLabelElem(elem=label,elemType=labelType,...)>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** rule when output=AST and tracking for rewrite */
|
||||||
|
ruleRefTrack(rule,label,elementIndex,args,scope) ::= <<
|
||||||
|
<super.ruleRef(...)>
|
||||||
|
<if(backtracking)>if (<actions.(actionScope).synpredgate>) <endif>stream_<rule.name>.Add(<label>.Tree);
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** x+=rule when output=AST and tracking for rewrite */
|
||||||
|
ruleRefTrackAndListLabel(rule,label,elementIndex,args,scope) ::= <<
|
||||||
|
<ruleRefTrack(...)>
|
||||||
|
<listLabelElem(elem={<label>.Tree},elemType=ASTLabelType,...)>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** ^(rule ...) rewrite */
|
||||||
|
ruleRefRuleRootTrack(rule,label,elementIndex,args,scope) ::= <<
|
||||||
|
<ruleRefRuleRoot(...)>
|
||||||
|
<if(backtracking)>if (<actions.(actionScope).synpredgate>) <endif>stream_<rule>.Add(<label>.Tree);
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** ^(x+=rule ...) rewrite */
|
||||||
|
ruleRefRuleRootTrackAndListLabel(rule,label,elementIndex,args,scope) ::= <<
|
||||||
|
<ruleRefRuleRootTrack(...)>
|
||||||
|
<listLabelElem(elem={<label>.Tree},elemType=ASTLabelType,...)>
|
||||||
|
>>
|
||||||
|
|
||||||
|
// R e w r i t e
|
||||||
|
|
||||||
|
rewriteCode(
|
||||||
|
alts, description,
|
||||||
|
referencedElementsDeep, // ALL referenced elements to right of ->
|
||||||
|
referencedTokenLabels,
|
||||||
|
referencedTokenListLabels,
|
||||||
|
referencedRuleLabels,
|
||||||
|
referencedRuleListLabels,
|
||||||
|
referencedWildcardLabels,
|
||||||
|
referencedWildcardListLabels,
|
||||||
|
rewriteBlockLevel, enclosingTreeLevel, treeLevel) ::= <<
|
||||||
|
<\n>{
|
||||||
|
// AST REWRITE
|
||||||
|
// elements: <referencedElementsDeep; separator=", ">
|
||||||
|
// token labels: <referencedTokenLabels; separator=", ">
|
||||||
|
// rule labels: <referencedRuleLabels; separator=", ">
|
||||||
|
// token list labels: <referencedTokenListLabels; separator=", ">
|
||||||
|
// rule list labels: <referencedRuleListLabels; separator=", ">
|
||||||
|
// wildcard labels: <[referencedWildcardLabels,referencedWildcardListLabels]; separator=", ">
|
||||||
|
<if(backtracking)>
|
||||||
|
if (<actions.(actionScope).synpredgate>) {
|
||||||
|
<endif>
|
||||||
|
<prevRuleRootRef()>.Tree = root_0;
|
||||||
|
<rewriteCodeLabels()>
|
||||||
|
root_0 = (<ASTLabelType>)adaptor.Nil();
|
||||||
|
<alts:rewriteAlt(); separator="else ">
|
||||||
|
<! if tree parser and rewrite=true !>
|
||||||
|
<if(TREE_PARSER&&rewriteMode)>
|
||||||
|
<prevRuleRootRef()>.Tree = (<ASTLabelType>)adaptor.RulePostProcessing(root_0);
|
||||||
|
if (<prevRuleRootRef()>.Tree != null)
|
||||||
|
input.ReplaceChildren(adaptor.GetParent(retval.Start), adaptor.GetChildIndex(retval.Start), adaptor.GetChildIndex(_last), retval.Tree);
|
||||||
|
<endif>
|
||||||
|
<! if parser or tree-parser && rewrite!=true, we need to set result !>
|
||||||
|
<if(!TREE_PARSER||!rewriteMode)>
|
||||||
|
<prevRuleRootRef()>.Tree = root_0;
|
||||||
|
<endif>
|
||||||
|
<if(backtracking)>
|
||||||
|
}
|
||||||
|
<endif>
|
||||||
|
}
|
||||||
|
|
||||||
|
>>
|
||||||
|
|
||||||
|
rewriteCodeLabels() ::= <<
|
||||||
|
<referencedTokenLabels
|
||||||
|
:{it|RewriteRule<rewriteElementType>Stream stream_<it>=new RewriteRule<rewriteElementType>Stream(adaptor,"token <it>",<it>);};
|
||||||
|
separator="\n"
|
||||||
|
>
|
||||||
|
<referencedTokenListLabels
|
||||||
|
:{it|RewriteRule<rewriteElementType>Stream stream_<it>=new RewriteRule<rewriteElementType>Stream(adaptor,"token <it>", list_<it>);};
|
||||||
|
separator="\n"
|
||||||
|
>
|
||||||
|
<referencedWildcardLabels
|
||||||
|
:{it|RewriteRuleSubtreeStream stream_<it>=new RewriteRuleSubtreeStream(adaptor,"wildcard <it>",<it>);};
|
||||||
|
separator="\n"
|
||||||
|
>
|
||||||
|
<referencedWildcardListLabels
|
||||||
|
:{it|RewriteRuleSubtreeStream stream_<it>=new RewriteRuleSubtreeStream(adaptor,"wildcard <it>",list_<it>);};
|
||||||
|
separator="\n"
|
||||||
|
>
|
||||||
|
<referencedRuleLabels
|
||||||
|
:{it|RewriteRuleSubtreeStream stream_<it>=new RewriteRuleSubtreeStream(adaptor,"rule <it>",<it>!=null?<it>.Tree:null);};
|
||||||
|
separator="\n"
|
||||||
|
>
|
||||||
|
<referencedRuleListLabels
|
||||||
|
:{it|RewriteRuleSubtreeStream stream_<it>=new RewriteRuleSubtreeStream(adaptor,"token <it>",list_<it>);};
|
||||||
|
separator="\n"
|
||||||
|
>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** Generate code for an optional rewrite block; note it uses the deep ref'd element
|
||||||
|
* list rather shallow like other blocks.
|
||||||
|
*/
|
||||||
|
rewriteOptionalBlock(
|
||||||
|
alt,rewriteBlockLevel,
|
||||||
|
referencedElementsDeep, // all nested refs
|
||||||
|
referencedElements, // elements in immediately block; no nested blocks
|
||||||
|
description) ::=
|
||||||
|
<<
|
||||||
|
// <fileName>:<description>
|
||||||
|
if (<referencedElementsDeep:{el | stream_<el>.HasNext}; separator="||">)
|
||||||
|
{
|
||||||
|
<alt>
|
||||||
|
}
|
||||||
|
<referencedElementsDeep:{el | stream_<el>.Reset();<\n>}>
|
||||||
|
>>
|
||||||
|
|
||||||
|
rewriteClosureBlock(
|
||||||
|
alt,rewriteBlockLevel,
|
||||||
|
referencedElementsDeep, // all nested refs
|
||||||
|
referencedElements, // elements in immediately block; no nested blocks
|
||||||
|
description) ::=
|
||||||
|
<<
|
||||||
|
// <fileName>:<description>
|
||||||
|
while ( <referencedElements:{el | stream_<el>.HasNext}; separator="||"> )
|
||||||
|
{
|
||||||
|
<alt>
|
||||||
|
}
|
||||||
|
<referencedElements:{el | stream_<el>.Reset();<\n>}>
|
||||||
|
>>
|
||||||
|
|
||||||
|
rewritePositiveClosureBlock(
|
||||||
|
alt,rewriteBlockLevel,
|
||||||
|
referencedElementsDeep, // all nested refs
|
||||||
|
referencedElements, // elements in immediately block; no nested blocks
|
||||||
|
description) ::=
|
||||||
|
<<
|
||||||
|
if (!(<referencedElements:{el | stream_<el>.HasNext}; separator="||">))
|
||||||
|
{
|
||||||
|
throw new RewriteEarlyExitException();
|
||||||
|
}
|
||||||
|
while ( <referencedElements:{el | stream_<el>.HasNext}; separator="||"> )
|
||||||
|
{
|
||||||
|
<alt>
|
||||||
|
}
|
||||||
|
<referencedElements:{el | stream_<el>.Reset();<\n>}>
|
||||||
|
>>
|
||||||
|
|
||||||
|
rewriteAlt(a) ::= <<
|
||||||
|
// <a.description>
|
||||||
|
<if(a.pred)>
|
||||||
|
if (<a.pred>)
|
||||||
|
{
|
||||||
|
<a.alt>
|
||||||
|
}
|
||||||
|
<else>
|
||||||
|
{
|
||||||
|
<a.alt>
|
||||||
|
}
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** For empty rewrites: "r : ... -> ;" */
|
||||||
|
rewriteEmptyAlt() ::= "root_0 = null;"
|
||||||
|
|
||||||
|
rewriteTree(root,children,description,enclosingTreeLevel,treeLevel) ::= <<
|
||||||
|
// <fileName>:<description>
|
||||||
|
{
|
||||||
|
<ASTLabelType> root_<treeLevel> = (<ASTLabelType>)adaptor.Nil();
|
||||||
|
<root:rewriteElement()>
|
||||||
|
<children:rewriteElement()>
|
||||||
|
adaptor.AddChild(root_<enclosingTreeLevel>, root_<treeLevel>);
|
||||||
|
}<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
rewriteElementList(elements) ::= "<elements:rewriteElement()>"
|
||||||
|
|
||||||
|
rewriteElement(e) ::= <%
|
||||||
|
<@pregen()>
|
||||||
|
DebugLocation(<e.line>, <e.pos>);<\n>
|
||||||
|
<e.el>
|
||||||
|
%>
|
||||||
|
|
||||||
|
/** Gen ID or ID[args] */
|
||||||
|
rewriteTokenRef(token,elementIndex,terminalOptions,args) ::= <<
|
||||||
|
adaptor.AddChild(root_<treeLevel>, <createRewriteNodeFromElement(...)>);<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** Gen $label ... where defined via label=ID */
|
||||||
|
rewriteTokenLabelRef(label,elementIndex) ::= <<
|
||||||
|
adaptor.AddChild(root_<treeLevel>, stream_<label>.NextNode());<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** Gen $label ... where defined via label+=ID */
|
||||||
|
rewriteTokenListLabelRef(label,elementIndex) ::= <<
|
||||||
|
adaptor.AddChild(root_<treeLevel>, stream_<label>.NextNode());<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** Gen ^($label ...) */
|
||||||
|
rewriteTokenLabelRefRoot(label,elementIndex) ::= <<
|
||||||
|
root_<treeLevel> = (<ASTLabelType>)adaptor.BecomeRoot(stream_<label>.NextNode(), root_<treeLevel>);<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** Gen ^($label ...) where label+=... */
|
||||||
|
rewriteTokenListLabelRefRoot ::= rewriteTokenLabelRefRoot
|
||||||
|
|
||||||
|
/** Gen ^(ID ...) or ^(ID[args] ...) */
|
||||||
|
rewriteTokenRefRoot(token,elementIndex,terminalOptions,args) ::= <<
|
||||||
|
root_<treeLevel> = (<ASTLabelType>)adaptor.BecomeRoot(<createRewriteNodeFromElement(...)>, root_<treeLevel>);<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
rewriteImaginaryTokenRef(args,token,terminalOptions,elementIndex) ::= <<
|
||||||
|
adaptor.AddChild(root_<treeLevel>, <createImaginaryNode(tokenType=token, ...)>);<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
rewriteImaginaryTokenRefRoot(args,token,terminalOptions,elementIndex) ::= <<
|
||||||
|
root_<treeLevel> = (<ASTLabelType>)adaptor.BecomeRoot(<createImaginaryNode(tokenType=token, ...)>, root_<treeLevel>);<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** plain -> {foo} action */
|
||||||
|
rewriteAction(action) ::= <<
|
||||||
|
root_0 = <action>;<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** What is the name of the previous value of this rule's root tree? This
|
||||||
|
* let's us refer to $rule to mean previous value. I am reusing the
|
||||||
|
* variable 'tree' sitting in retval struct to hold the value of root_0 right
|
||||||
|
* before I set it during rewrites. The assign will be to retval.tree.
|
||||||
|
*/
|
||||||
|
prevRuleRootRef() ::= "retval"
|
||||||
|
|
||||||
|
rewriteRuleRef(rule) ::= <<
|
||||||
|
adaptor.AddChild(root_<treeLevel>, stream_<rule>.NextTree());<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
rewriteRuleRefRoot(rule) ::= <<
|
||||||
|
root_<treeLevel> = (<ASTLabelType>)adaptor.BecomeRoot(stream_<rule>.NextNode(), root_<treeLevel>);<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
rewriteNodeAction(action) ::= <<
|
||||||
|
adaptor.AddChild(root_<treeLevel>, <action>);<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
rewriteNodeActionRoot(action) ::= <<
|
||||||
|
root_<treeLevel> = (<ASTLabelType>)adaptor.BecomeRoot(<action>, root_<treeLevel>);<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** Gen $ruleLabel ... where defined via ruleLabel=rule */
|
||||||
|
rewriteRuleLabelRef(label) ::= <<
|
||||||
|
adaptor.AddChild(root_<treeLevel>, stream_<label>.NextTree());<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** Gen $ruleLabel ... where defined via ruleLabel+=rule */
|
||||||
|
rewriteRuleListLabelRef(label) ::= <<
|
||||||
|
adaptor.AddChild(root_<treeLevel>, stream_<label>.NextTree());<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** Gen ^($ruleLabel ...) where ruleLabel=rule */
|
||||||
|
rewriteRuleLabelRefRoot(label) ::= <<
|
||||||
|
root_<treeLevel> = (<ASTLabelType>)adaptor.BecomeRoot(stream_<label>.NextNode(), root_<treeLevel>);<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** Gen ^($ruleLabel ...) where ruleLabel+=rule */
|
||||||
|
rewriteRuleListLabelRefRoot(label) ::= <<
|
||||||
|
root_<treeLevel> = (<ASTLabelType>)adaptor.BecomeRoot(stream_<label>.NextNode(), root_<treeLevel>);<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
rewriteWildcardLabelRef(label) ::= <<
|
||||||
|
adaptor.AddChild(root_<treeLevel>, stream_<label>.NextTree());<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
createImaginaryNode(tokenType,terminalOptions,args) ::= <%
|
||||||
|
<if(terminalOptions.node)>
|
||||||
|
<! new MethodNode(IDLabel, args) !>
|
||||||
|
new <terminalOptions.node>(<tokenType><if(args)>, <args; separator=", "><endif>)
|
||||||
|
<else>
|
||||||
|
(<ASTLabelType>)adaptor.Create(<tokenType>, <args; separator=", "><if(!args)>"<tokenType>"<endif>)
|
||||||
|
<endif>
|
||||||
|
%>
|
||||||
|
|
||||||
|
createRewriteNodeFromElement(token,terminalOptions,args) ::= <%
|
||||||
|
<if(terminalOptions.node)>
|
||||||
|
new <terminalOptions.node>(stream_<token>.NextToken()<if(args)>, <args; separator=", "><endif>)
|
||||||
|
<else>
|
||||||
|
<if(args)> <! must create new node from old !>
|
||||||
|
adaptor.Create(<token>, <args; separator=", ">)
|
||||||
|
<else>
|
||||||
|
stream_<token>.NextNode()
|
||||||
|
<endif>
|
||||||
|
<endif>
|
||||||
|
%>
|
||||||
94
packages/Antlr34.3.4.19004.1/tools/Codegen/Templates/CSharp2/ASTDbg.stg
vendored
Normal file
94
packages/Antlr34.3.4.19004.1/tools/Codegen/Templates/CSharp2/ASTDbg.stg
vendored
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
/*
|
||||||
|
* [The "BSD license"]
|
||||||
|
* Copyright (c) 2007-2008 Johannes Luber
|
||||||
|
* Copyright (c) 2005-2007 Kunle Odutola
|
||||||
|
* Copyright (c) 2005 Terence Parr
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** Template overrides to add debugging to AST stuff. Dynamic inheritance
|
||||||
|
* hierarchy is set up as ASTDbg : AST : Dbg : Java by code generator.
|
||||||
|
*/
|
||||||
|
|
||||||
|
parserMembers() ::= <<
|
||||||
|
protected DebugTreeAdaptor adaptor;
|
||||||
|
|
||||||
|
public ITreeAdaptor TreeAdaptor
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return adaptor;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
<if(grammar.grammarIsRoot)>
|
||||||
|
this.adaptor = new DebugTreeAdaptor(dbg,adaptor);
|
||||||
|
<else>
|
||||||
|
this.adaptor = (DebugTreeAdaptor)adaptor; // delegator sends dbg adaptor
|
||||||
|
<endif><\n>
|
||||||
|
<grammar.directDelegates:{g|<g:delegateName()>.TreeAdaptor = this.adaptor;}>
|
||||||
|
}
|
||||||
|
}<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
parserCtorBody() ::= <<
|
||||||
|
<super.parserCtorBody()>
|
||||||
|
>>
|
||||||
|
|
||||||
|
createListenerAndHandshake() ::= <<
|
||||||
|
DebugEventSocketProxy proxy = new DebugEventSocketProxy( this, port, <if(TREE_PARSER)>input.TreeAdaptor<else>adaptor<endif> );
|
||||||
|
DebugListener = proxy;
|
||||||
|
<inputStreamType> = new Debug<inputStreamType>( input, proxy );
|
||||||
|
try
|
||||||
|
{
|
||||||
|
proxy.Handshake();
|
||||||
|
}
|
||||||
|
catch ( IOException ioe )
|
||||||
|
{
|
||||||
|
ReportError( ioe );
|
||||||
|
}
|
||||||
|
>>
|
||||||
|
|
||||||
|
@ctorForRootGrammar.finally() ::= <<
|
||||||
|
ITreeAdaptor adap = new CommonTreeAdaptor();
|
||||||
|
TreeAdaptor = adap;
|
||||||
|
proxy.TreeAdaptor = adap;
|
||||||
|
>>
|
||||||
|
|
||||||
|
@ctorForProfilingRootGrammar.finally() ::=<<
|
||||||
|
ITreeAdaptor adap = new CommonTreeAdaptor();
|
||||||
|
TreeAdaptor = adap;
|
||||||
|
>>
|
||||||
|
|
||||||
|
@ctorForPredefinedListener.superClassRef() ::= ": base( input, dbg )"
|
||||||
|
|
||||||
|
@ctorForPredefinedListener.finally() ::=<<
|
||||||
|
<if(grammar.grammarIsRoot)><! don't create new adaptor for delegates !>
|
||||||
|
ITreeAdaptor adap = new CommonTreeAdaptor();
|
||||||
|
TreeAdaptor = adap;<\n>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
//@rewriteElement.pregen() ::= "dbg.Location( <e.line>, <e.pos> );"
|
||||||
192
packages/Antlr34.3.4.19004.1/tools/Codegen/Templates/CSharp2/ASTParser.stg
vendored
Normal file
192
packages/Antlr34.3.4.19004.1/tools/Codegen/Templates/CSharp2/ASTParser.stg
vendored
Normal file
@@ -0,0 +1,192 @@
|
|||||||
|
/*
|
||||||
|
* [The "BSD license"]
|
||||||
|
* Copyright (c) 2007-2008 Johannes Luber
|
||||||
|
* Copyright (c) 2005-2007 Kunle Odutola
|
||||||
|
* Copyright (c) 2011 Sam Harwell
|
||||||
|
* Copyright (c) 2011 Terence Parr
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** Templates for building ASTs during normal parsing.
|
||||||
|
*
|
||||||
|
* Deal with many combinations. Dimensions are:
|
||||||
|
* Auto build or rewrite
|
||||||
|
* no label, label, list label (label/no-label handled together)
|
||||||
|
* child, root
|
||||||
|
* token, set, rule, wildcard
|
||||||
|
*
|
||||||
|
* The situation is not too bad as rewrite (->) usage makes ^ and !
|
||||||
|
* invalid. There is no huge explosion of combinations.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@rule.setErrorReturnValue() ::= <<
|
||||||
|
retval.Tree = (<ASTLabelType>)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);
|
||||||
|
<! System.out.WriteLine("<ruleName> returns "+((CommonTree)retval.tree).toStringTree()); !>
|
||||||
|
>>
|
||||||
|
|
||||||
|
// TOKEN AST STUFF
|
||||||
|
|
||||||
|
/** ID and output=AST */
|
||||||
|
tokenRef(token,label,elementIndex,terminalOptions) ::= <<
|
||||||
|
<super.tokenRef(...)>
|
||||||
|
<if(backtracking)>if (state.backtracking == 0) {<endif>
|
||||||
|
<label>_tree = <createNodeFromToken(...)>;
|
||||||
|
adaptor.AddChild(root_0, <label>_tree);
|
||||||
|
<if(backtracking)>}<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** ID! and output=AST (same as plain tokenRef) */
|
||||||
|
tokenRefBang(token,label,elementIndex) ::= "<super.tokenRef(...)>"
|
||||||
|
|
||||||
|
/** ID^ and output=AST */
|
||||||
|
tokenRefRuleRoot(token,label,elementIndex,terminalOptions) ::= <<
|
||||||
|
<super.tokenRef(...)>
|
||||||
|
<if(backtracking)>if (<actions.(actionScope).synpredgate>) {<endif>
|
||||||
|
<label>_tree = <createNodeFromToken(...)>;
|
||||||
|
root_0 = (<ASTLabelType>)adaptor.BecomeRoot(<label>_tree, root_0);
|
||||||
|
<if(backtracking)>}<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** ids+=ID! and output=AST */
|
||||||
|
tokenRefBangAndListLabel(token,label,elementIndex,terminalOptions) ::= <<
|
||||||
|
<tokenRefBang(...)>
|
||||||
|
<listLabelElem(elem=label,elemType=labelType,...)>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** label+=TOKEN when output=AST but not rewrite alt */
|
||||||
|
tokenRefAndListLabel(token,label,elementIndex,terminalOptions) ::= <<
|
||||||
|
<tokenRef(...)>
|
||||||
|
<listLabelElem(elem=label,elemType=labelType,...)>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** Match label+=TOKEN^ when output=AST but not rewrite alt */
|
||||||
|
tokenRefRuleRootAndListLabel(token,label,terminalOptions,elementIndex) ::= <<
|
||||||
|
<tokenRefRuleRoot(...)>
|
||||||
|
<listLabelElem(elem=label,elemType=labelType,...)>
|
||||||
|
>>
|
||||||
|
|
||||||
|
// SET AST
|
||||||
|
|
||||||
|
// the match set stuff is interesting in that it uses an argument list
|
||||||
|
// to pass code to the default matchSet; another possible way to alter
|
||||||
|
// inherited code. I don't use the region stuff because I need to pass
|
||||||
|
// different chunks depending on the operator. I don't like making
|
||||||
|
// the template name have the operator as the number of templates gets
|
||||||
|
// large but this is the most flexible--this is as opposed to having
|
||||||
|
// the code generator call matchSet then add root code or ruleroot code
|
||||||
|
// plus list label plus ... The combinations might require complicated
|
||||||
|
// rather than just added on code. Investigate that refactoring when
|
||||||
|
// I have more time.
|
||||||
|
|
||||||
|
matchSet(s,label,terminalOptions,elementIndex,postmatchCode) ::= <<
|
||||||
|
<super.matchSet(postmatchCode={<if(backtracking)>if (<actions.(actionScope).synpredgate>) <endif>adaptor.AddChild(root_0, <createNodeFromToken(...)>);}, ...)>
|
||||||
|
>>
|
||||||
|
|
||||||
|
matchRuleBlockSet(s,label,terminalOptions,elementIndex,postmatchCode,treeLevel="0") ::= <<
|
||||||
|
<matchSet(...)>
|
||||||
|
>>
|
||||||
|
|
||||||
|
matchSetBang(s,label,elementIndex,terminalOptions,postmatchCode) ::= "<super.matchSet(...)>"
|
||||||
|
|
||||||
|
// note there is no matchSetTrack because -> rewrites force sets to be
|
||||||
|
// plain old blocks of alts: (A|B|...|C)
|
||||||
|
|
||||||
|
matchSetRuleRoot(s,label,terminalOptions,elementIndex,debug) ::= <<
|
||||||
|
<if(label)>
|
||||||
|
<label>=(<labelType>)input.LT(1);
|
||||||
|
<endif>
|
||||||
|
<super.matchSet(postmatchCode={<if(backtracking)>if (<actions.(actionScope).synpredgate>) <endif>root_0 = (<ASTLabelType>)adaptor.BecomeRoot(<createNodeFromToken(...)>, root_0);}, ...)>
|
||||||
|
>>
|
||||||
|
|
||||||
|
// RULE REF AST
|
||||||
|
|
||||||
|
/** rule when output=AST */
|
||||||
|
ruleRef(rule,label,elementIndex,args,scope) ::= <<
|
||||||
|
<super.ruleRef(...)>
|
||||||
|
<if(backtracking)>if (<actions.(actionScope).synpredgate>) <endif>adaptor.AddChild(root_0, <label>.Tree);
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** rule! is same as normal rule ref */
|
||||||
|
ruleRefBang(rule,label,elementIndex,args,scope) ::= "<super.ruleRef(...)>"
|
||||||
|
|
||||||
|
/** rule^ */
|
||||||
|
ruleRefRuleRoot(rule,label,elementIndex,args,scope) ::= <<
|
||||||
|
<super.ruleRef(...)>
|
||||||
|
<if(backtracking)>if (<actions.(actionScope).synpredgate>) <endif>root_0 = (<ASTLabelType>)adaptor.BecomeRoot(<label>.Tree, root_0);
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** x+=rule when output=AST */
|
||||||
|
ruleRefAndListLabel(rule,label,elementIndex,args,scope) ::= <<
|
||||||
|
<ruleRef(...)>
|
||||||
|
<listLabelElem(elem={<label>.Tree},elemType=ASTLabelType,...)>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** x+=rule! when output=AST is a rule ref with list addition */
|
||||||
|
ruleRefBangAndListLabel(rule,label,elementIndex,args,scope) ::= <<
|
||||||
|
<ruleRefBang(...)>
|
||||||
|
<listLabelElem(elem={<label>.Tree},elemType=ASTLabelType,...)>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** x+=rule^ */
|
||||||
|
ruleRefRuleRootAndListLabel(rule,label,elementIndex,args,scope) ::= <<
|
||||||
|
<ruleRefRuleRoot(...)>
|
||||||
|
<listLabelElem(elem={<label>.Tree},elemType=ASTLabelType,...)>
|
||||||
|
>>
|
||||||
|
|
||||||
|
// WILDCARD AST
|
||||||
|
|
||||||
|
wildcard(token,label,elementIndex,terminalOptions) ::= <<
|
||||||
|
<super.wildcard(...)>
|
||||||
|
<if(backtracking)>if (<actions.(actionScope).synpredgate>) {<endif>
|
||||||
|
<label>_tree = (<ASTLabelType>)adaptor.Create(<label>);
|
||||||
|
adaptor.AddChild(root_0, <label>_tree);
|
||||||
|
<if(backtracking)>}<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
wildcardBang(label,elementIndex) ::= "<super.wildcard(...)>"
|
||||||
|
|
||||||
|
wildcardRuleRoot(token,label,elementIndex,terminalOptions) ::= <<
|
||||||
|
<super.wildcard(...)>
|
||||||
|
<if(backtracking)>if (<actions.(actionScope).synpredgate>) {<endif>
|
||||||
|
<label>_tree = (<ASTLabelType>)adaptor.Create(<label>);
|
||||||
|
root_0 = (<ASTLabelType>)adaptor.BecomeRoot(<label>_tree, root_0);
|
||||||
|
<if(backtracking)>}<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
createNodeFromToken(label,terminalOptions) ::= <%
|
||||||
|
<if(terminalOptions.node)>
|
||||||
|
new <terminalOptions.node>(<if(terminalOptions.type)><terminalOptions.type>,<endif><label><if(terminalOptions.text)>,<terminalOptions.text; format="string"><endif>)
|
||||||
|
<else>
|
||||||
|
(<ASTLabelType>)adaptor.Create(<if(terminalOptions.type)><terminalOptions.type>,<endif><label><if(terminalOptions.text)>,<terminalOptions.text; format="string"><endif>)
|
||||||
|
<endif>
|
||||||
|
%>
|
||||||
|
|
||||||
|
ruleCleanUp() ::= <<
|
||||||
|
<super.ruleCleanUp()>
|
||||||
|
<if(backtracking)>if (<actions.(actionScope).synpredgate>) {<endif>
|
||||||
|
retval.Tree = (<ASTLabelType>)adaptor.RulePostProcessing(root_0);
|
||||||
|
adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);
|
||||||
|
<if(backtracking)>}<endif>
|
||||||
|
>>
|
||||||
380
packages/Antlr34.3.4.19004.1/tools/Codegen/Templates/CSharp2/ASTTreeParser.stg
vendored
Normal file
380
packages/Antlr34.3.4.19004.1/tools/Codegen/Templates/CSharp2/ASTTreeParser.stg
vendored
Normal file
@@ -0,0 +1,380 @@
|
|||||||
|
/*
|
||||||
|
* [The "BSD license"]
|
||||||
|
* Copyright (c) 2007-2008 Johannes Luber
|
||||||
|
* Copyright (c) 2005-2007 Kunle Odutola
|
||||||
|
* Copyright (c) 2011 Sam Harwell
|
||||||
|
* Copyright (c) 2011 Terence Parr
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** Templates for building ASTs during tree parsing.
|
||||||
|
*
|
||||||
|
* Deal with many combinations. Dimensions are:
|
||||||
|
* Auto build or rewrite
|
||||||
|
* no label, label, list label (label/no-label handled together)
|
||||||
|
* child, root
|
||||||
|
* token, set, rule, wildcard
|
||||||
|
*
|
||||||
|
* Each combination has its own template except that label/no label
|
||||||
|
* is combined into tokenRef, ruleRef, ...
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** Add a variable to track last element matched */
|
||||||
|
ruleDeclarations() ::= <<
|
||||||
|
<super.ruleDeclarations()>
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
<ASTLabelType> _first_0 = default(<ASTLabelType>);
|
||||||
|
<ASTLabelType> _last = default(<ASTLabelType>);
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** What to emit when there is no rewrite rule. For auto build
|
||||||
|
* mode, does nothing.
|
||||||
|
*/
|
||||||
|
noRewrite(rewriteBlockLevel, treeLevel) ::= <<
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
<if(backtracking)>if (<actions.(actionScope).synpredgate>) {<endif>
|
||||||
|
<if(rewriteMode)>
|
||||||
|
retval.Tree = (<ASTLabelType>)_first_0;
|
||||||
|
if (adaptor.GetParent(retval.Tree)!=null && adaptor.IsNil(adaptor.GetParent(retval.Tree)))
|
||||||
|
retval.Tree = (<ASTLabelType>)adaptor.GetParent(retval.Tree);
|
||||||
|
<endif>
|
||||||
|
<if(backtracking)>}<endif>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** match ^(root children) in tree parser; override here to
|
||||||
|
* add tree construction actions.
|
||||||
|
*/
|
||||||
|
tree(root, actionsAfterRoot, children, nullableChildList,
|
||||||
|
enclosingTreeLevel, treeLevel) ::= <<
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
_last = (<ASTLabelType>)input.LT(1);
|
||||||
|
{
|
||||||
|
<ASTLabelType> _save_last_<treeLevel> = _last;
|
||||||
|
<ASTLabelType> _first_<treeLevel> = default(<ASTLabelType>);
|
||||||
|
<if(!rewriteMode)>
|
||||||
|
<ASTLabelType> root_<treeLevel> = (<ASTLabelType>)adaptor.Nil();
|
||||||
|
<endif>
|
||||||
|
<root:element()>
|
||||||
|
<if(rewriteMode)>
|
||||||
|
<if(backtracking)>if (<actions.(actionScope).synpredgate>)<endif>
|
||||||
|
<if(root.el.rule)>
|
||||||
|
if (_first_<enclosingTreeLevel> == null) _first_<enclosingTreeLevel> = <root.el.label>.Tree;
|
||||||
|
<else>
|
||||||
|
if (_first_<enclosingTreeLevel> == null) _first_<enclosingTreeLevel> = <root.el.label>;
|
||||||
|
<endif>
|
||||||
|
<endif>
|
||||||
|
<actionsAfterRoot:element()>
|
||||||
|
<if(nullableChildList)>
|
||||||
|
if (input.LA(1) == TokenTypes.Down) {
|
||||||
|
Match(input, TokenTypes.Down, null); <checkRuleBacktrackFailure()>
|
||||||
|
<children:element()>
|
||||||
|
Match(input, TokenTypes.Up, null); <checkRuleBacktrackFailure()>
|
||||||
|
}
|
||||||
|
<else>
|
||||||
|
Match(input, TokenTypes.Down, null); <checkRuleBacktrackFailure()>
|
||||||
|
<children:element()>
|
||||||
|
Match(input, TokenTypes.Up, null); <checkRuleBacktrackFailure()>
|
||||||
|
<endif>
|
||||||
|
<if(!rewriteMode)>
|
||||||
|
adaptor.AddChild(root_<enclosingTreeLevel>, root_<treeLevel>);
|
||||||
|
<endif>
|
||||||
|
_last = _save_last_<treeLevel>;
|
||||||
|
}
|
||||||
|
<else>
|
||||||
|
<super.tree(...)>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
// TOKEN AST STUFF
|
||||||
|
|
||||||
|
/** ID! and output=AST (same as plain tokenRef) 'cept add
|
||||||
|
* setting of _last
|
||||||
|
*/
|
||||||
|
tokenRefBang(token,label,elementIndex,terminalOptions) ::= <<
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
_last = (<ASTLabelType>)input.LT(1);
|
||||||
|
<super.tokenRef(...)>
|
||||||
|
<else>
|
||||||
|
<super.tokenRefBang(...)>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** ID auto construct */
|
||||||
|
tokenRef(token,label,elementIndex,terminalOptions) ::= <<
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
_last = (<ASTLabelType>)input.LT(1);
|
||||||
|
<super.tokenRef(...)>
|
||||||
|
<if(!rewriteMode)>
|
||||||
|
<if(backtracking)>if (<actions.(actionScope).synpredgate>) {<endif>
|
||||||
|
<if(terminalOptions.node)>
|
||||||
|
<label>_tree = new <terminalOptions.node>(<if(terminalOptions.type)><terminalOptions.type>,<endif><label><if(terminalOptions.text)>,<terminalOptions.text; format="string"><endif>);
|
||||||
|
<else>
|
||||||
|
<label>_tree = (<ASTLabelType>)adaptor.DupNode(<if(terminalOptions.type)><terminalOptions.type>,<endif><label><if(terminalOptions.text)>,<terminalOptions.text; format="string"><endif>);
|
||||||
|
<endif><\n>
|
||||||
|
adaptor.AddChild(root_<treeLevel>, <label>_tree);
|
||||||
|
<if(backtracking)>}<endif>
|
||||||
|
<else> <! rewrite mode !>
|
||||||
|
<if(backtracking)>if (<actions.(actionScope).synpredgate>)<endif>
|
||||||
|
if (_first_<treeLevel> == null) _first_<treeLevel> = <label>;
|
||||||
|
<endif>
|
||||||
|
<else>
|
||||||
|
<super.tokenRef(...)>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** label+=TOKEN auto construct */
|
||||||
|
tokenRefAndListLabel(token,label,elementIndex,terminalOptions) ::= <<
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
<tokenRef(...)>
|
||||||
|
<listLabelElem(elem=label,...)>
|
||||||
|
<else>
|
||||||
|
<super.tokenRefAndListLabel(...)>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** ^(ID ...) auto construct */
|
||||||
|
tokenRefRuleRoot(token,label,elementIndex,terminalOptions) ::= <<
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
_last = (<ASTLabelType>)input.LT(1);
|
||||||
|
<super.tokenRef(...)>
|
||||||
|
<if(!rewriteMode)>
|
||||||
|
<if(backtracking)>if (<actions.(actionScope).synpredgate>) {<endif>
|
||||||
|
<if(terminalOptions.node)>
|
||||||
|
<label>_tree = new <terminalOptions.node>(<if(terminalOptions.type)><terminalOptions.type>,<endif><label><if(terminalOptions.text)>,<terminalOptions.text; format="string"><endif>);
|
||||||
|
<else>
|
||||||
|
<label>_tree = (<ASTLabelType>)adaptor.DupNode(<if(terminalOptions.type)><terminalOptions.type>,<endif><label><if(terminalOptions.text)>,<terminalOptions.text; format="string"><endif>);
|
||||||
|
<endif><\n>
|
||||||
|
root_<treeLevel> = (<ASTLabelType>)adaptor.BecomeRoot(<label>_tree, root_<treeLevel>);
|
||||||
|
<if(backtracking)>}<endif>
|
||||||
|
<endif>
|
||||||
|
<else>
|
||||||
|
<super.tokenRefRuleRoot(...)>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** Match ^(label+=TOKEN ...) auto construct */
|
||||||
|
tokenRefRuleRootAndListLabel(token,label,elementIndex,terminalOptions) ::= <<
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
<tokenRefRuleRoot(...)>
|
||||||
|
<listLabelElem(elem=label,...)>
|
||||||
|
<else>
|
||||||
|
<super.tokenRefRuleRootAndListLabel(...)>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** Match . wildcard and auto dup the node/subtree */
|
||||||
|
wildcard(token,label,elementIndex,terminalOptions) ::= <<
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
_last = (<ASTLabelType>)input.LT(1);
|
||||||
|
<super.wildcard(...)>
|
||||||
|
<if(!rewriteMode)>
|
||||||
|
<if(backtracking)>if (<actions.(actionScope).synpredgate>) {<endif>
|
||||||
|
<label>_tree = (<ASTLabelType>)adaptor.DupTree(<label>);
|
||||||
|
adaptor.AddChild(root_<treeLevel>, <label>_tree);
|
||||||
|
<if(backtracking)>}<endif>
|
||||||
|
<else> <! rewrite mode !>
|
||||||
|
<if(backtracking)>if (<actions.(actionScope).synpredgate>)<endif>
|
||||||
|
if (_first_<treeLevel> == null) _first_<treeLevel> = <label>;
|
||||||
|
<endif>
|
||||||
|
<else>
|
||||||
|
<super.wildcard(...)>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
// SET AST
|
||||||
|
|
||||||
|
matchSet(s,label,terminalOptions,elementIndex,postmatchCode) ::= <<
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
_last = (<ASTLabelType>)input.LT(1);
|
||||||
|
<super.matchSet(postmatchCode={
|
||||||
|
<if(!rewriteMode)>
|
||||||
|
<if(backtracking)>if (<actions.(actionScope).synpredgate>) {<endif>
|
||||||
|
<if(terminalOptions.node)>
|
||||||
|
<label>_tree = new <terminalOptions.node>(<if(terminalOptions.type)><terminalOptions.type>,<endif><label><if(terminalOptions.text)>,<terminalOptions.text; format="string"><endif>);
|
||||||
|
<else>
|
||||||
|
<label>_tree = (<ASTLabelType>)adaptor.DupNode(<if(terminalOptions.type)><terminalOptions.type>,<endif><label><if(terminalOptions.text)>,<terminalOptions.text; format="string"><endif>);
|
||||||
|
<endif><\n>
|
||||||
|
adaptor.AddChild(root_<treeLevel>, <label>_tree);
|
||||||
|
<if(backtracking)>\}<endif>
|
||||||
|
<endif>
|
||||||
|
}, ...
|
||||||
|
)>
|
||||||
|
<else>
|
||||||
|
<super.matchSet(...)>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
matchRuleBlockSet(s,label,terminalOptions,elementIndex,postmatchCode,treeLevel="0") ::= <<
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
<matchSet(...)>
|
||||||
|
<noRewrite(...)> <! set return tree !>
|
||||||
|
<else>
|
||||||
|
<super.matchRuleBlockSet(...)>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
matchSetBang(s,label,terminalOptions,elementIndex,postmatchCode) ::= <<
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
_last = (<ASTLabelType>)input.LT(1);
|
||||||
|
<super.matchSet(...)>
|
||||||
|
<else>
|
||||||
|
<super.matchSetBang(...)>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
matchSetRuleRoot(s,label,terminalOptions,elementIndex,debug) ::= <<
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
<super.matchSet(postmatchCode={
|
||||||
|
<if(!rewriteMode)>
|
||||||
|
<if(backtracking)>if (<actions.(actionScope).synpredgate>) {<endif>
|
||||||
|
<if(terminalOptions.node)>
|
||||||
|
<label>_tree = new <terminalOptions.node>(<if(terminalOptions.type)><terminalOptions.type>,<endif><label><if(terminalOptions.text)>,<terminalOptions.text; format="string"><endif>);
|
||||||
|
<else>
|
||||||
|
<label>_tree = (<ASTLabelType>)adaptor.DupNode(<if(terminalOptions.type)><terminalOptions.type>,<endif><label><if(terminalOptions.text)>,<terminalOptions.text; format="string"><endif>);
|
||||||
|
<endif><\n>
|
||||||
|
root_<treeLevel> = (<ASTLabelType>)adaptor.BecomeRoot(<label>_tree, root_<treeLevel>);
|
||||||
|
<if(backtracking)>\}<endif>
|
||||||
|
<endif>
|
||||||
|
}, ...
|
||||||
|
)>
|
||||||
|
<else>
|
||||||
|
<super.matchSetRuleRoot(...)>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
// RULE REF AST
|
||||||
|
|
||||||
|
/** rule auto construct */
|
||||||
|
ruleRef(rule,label,elementIndex,args,scope) ::= <<
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
_last = (<ASTLabelType>)input.LT(1);
|
||||||
|
<super.ruleRef(...)>
|
||||||
|
<if(backtracking)>if (<actions.(actionScope).synpredgate>)<endif>
|
||||||
|
<if(!rewriteMode)>
|
||||||
|
adaptor.AddChild(root_<treeLevel>, <label>.Tree);
|
||||||
|
<else> <! rewrite mode !>
|
||||||
|
if (_first_<treeLevel> == null) _first_<treeLevel> = <label>.Tree;
|
||||||
|
<endif>
|
||||||
|
<else>
|
||||||
|
<super.ruleRef(...)>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** x+=rule auto construct */
|
||||||
|
ruleRefAndListLabel(rule,label,elementIndex,args,scope) ::= <<
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
<ruleRef(...)>
|
||||||
|
<listLabelElem(elem={<label>.Tree},...)>
|
||||||
|
<else>
|
||||||
|
<super.ruleRefAndListLabel(...)>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** ^(rule ...) auto construct */
|
||||||
|
ruleRefRuleRoot(rule,label,elementIndex,args,scope) ::= <<
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
_last = (<ASTLabelType>)input.LT(1);
|
||||||
|
<super.ruleRef(...)>
|
||||||
|
<if(!rewriteMode)>
|
||||||
|
<if(backtracking)>if (<actions.(actionScope).synpredgate>) <endif>root_<treeLevel> = (<ASTLabelType>)adaptor.BecomeRoot(<label>.Tree, root_<treeLevel>);
|
||||||
|
<endif>
|
||||||
|
<else>
|
||||||
|
<super.ruleRefRuleRoot(...)>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** ^(x+=rule ...) auto construct */
|
||||||
|
ruleRefRuleRootAndListLabel(rule,label,elementIndex,args,scope) ::= <<
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
<ruleRefRuleRoot(...)>
|
||||||
|
<listLabelElem(elem={<label>.Tree},...)>
|
||||||
|
<else>
|
||||||
|
<super.ruleRefRuleRootAndListLabel(...)>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** rule when output=AST and tracking for rewrite */
|
||||||
|
ruleRefTrack(rule,label,elementIndex,args,scope) ::= <<
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
_last = (<ASTLabelType>)input.LT(1);
|
||||||
|
<super.ruleRefTrack(...)>
|
||||||
|
<else>
|
||||||
|
<super.ruleRefTrack(...)>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** x+=rule when output=AST and tracking for rewrite */
|
||||||
|
ruleRefTrackAndListLabel(rule,label,elementIndex,args,scope) ::= <<
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
_last = (<ASTLabelType>)input.LT(1);
|
||||||
|
<super.ruleRefTrackAndListLabel(...)>
|
||||||
|
<else>
|
||||||
|
<super.ruleRefTrackAndListLabel(...)>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** ^(rule ...) rewrite */
|
||||||
|
ruleRefRuleRootTrack(rule,label,elementIndex,args,scope) ::= <<
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
_last = (<ASTLabelType>)input.LT(1);
|
||||||
|
<super.ruleRefRootTrack(...)>
|
||||||
|
<else>
|
||||||
|
<super.ruleRefRuleRootTrack(...)>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** ^(x+=rule ...) rewrite */
|
||||||
|
ruleRefRuleRootTrackAndListLabel(rule,label,elementIndex,args,scope) ::= <<
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
_last = (<ASTLabelType>)input.LT(1);
|
||||||
|
<super.ruleRefRuleRootTrackAndListLabel(...)>
|
||||||
|
<else>
|
||||||
|
<super.ruleRefRuleRootTrackAndListLabel(...)>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** Streams for token refs are tree nodes now; override to
|
||||||
|
* change NextToken to NextNode.
|
||||||
|
*/
|
||||||
|
createRewriteNodeFromElement(token,terminalOptions,args) ::= <%
|
||||||
|
<if(terminalOptions.node)>
|
||||||
|
new <terminalOptions.node>(<if(terminalOptions.type)><terminalOptions.type>,<endif>stream_<token>.NextNode())
|
||||||
|
<else>
|
||||||
|
stream_<token>.NextNode()
|
||||||
|
<endif>
|
||||||
|
%>
|
||||||
|
|
||||||
|
ruleCleanUp() ::= <<
|
||||||
|
<super.ruleCleanUp()>
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
<if(!rewriteMode)>
|
||||||
|
<if(backtracking)>if (<actions.(actionScope).synpredgate>) {<endif>
|
||||||
|
retval.Tree = (<ASTLabelType>)adaptor.RulePostProcessing(root_0);
|
||||||
|
<if(backtracking)>}<endif>
|
||||||
|
<endif>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
1765
packages/Antlr34.3.4.19004.1/tools/Codegen/Templates/CSharp2/CSharp2.stg
vendored
Normal file
1765
packages/Antlr34.3.4.19004.1/tools/Codegen/Templates/CSharp2/CSharp2.stg
vendored
Normal file
File diff suppressed because it is too large
Load Diff
313
packages/Antlr34.3.4.19004.1/tools/Codegen/Templates/CSharp2/Dbg.stg
vendored
Normal file
313
packages/Antlr34.3.4.19004.1/tools/Codegen/Templates/CSharp2/Dbg.stg
vendored
Normal file
@@ -0,0 +1,313 @@
|
|||||||
|
/*
|
||||||
|
* [The "BSD license"]
|
||||||
|
* Copyright (c) 2007-2008 Johannes Luber
|
||||||
|
* Copyright (c) 2005-2007 Kunle Odutola
|
||||||
|
* Copyright (c) 2011 Sam Harwell
|
||||||
|
* Copyright (c) 2011 Terence Parr
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
/** Template overrides to add debugging to normal Java output;
|
||||||
|
* If ASTs are built, then you'll also get ASTDbg.stg loaded.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@outputFile.debugPreprocessor() ::= "#define ANTLR_DEBUG"
|
||||||
|
|
||||||
|
@outputFile.imports() ::= <<
|
||||||
|
<@super.imports()>
|
||||||
|
using Antlr.Runtime.Debug;
|
||||||
|
using IOException = System.IO.IOException;
|
||||||
|
>>
|
||||||
|
|
||||||
|
@genericParser.members() ::= <<
|
||||||
|
<if(grammar.grammarIsRoot)>
|
||||||
|
public static readonly string[] ruleNames =
|
||||||
|
new string[]
|
||||||
|
{
|
||||||
|
"invalidRule", <grammar.allImportedRules:{rST | "<rST.name>"}; wrap="\n ", separator=", ">
|
||||||
|
};<\n>
|
||||||
|
<endif>
|
||||||
|
<if(grammar.grammarIsRoot)><! grammar imports other grammar(s) !>
|
||||||
|
int ruleLevel = 0;
|
||||||
|
public virtual int RuleLevel { get { return ruleLevel; } }
|
||||||
|
public virtual void IncRuleLevel() { ruleLevel++; }
|
||||||
|
public virtual void DecRuleLevel() { ruleLevel--; }
|
||||||
|
<if(profile)>
|
||||||
|
<ctorForProfilingRootGrammar()>
|
||||||
|
<else>
|
||||||
|
<ctorForRootGrammar()>
|
||||||
|
<endif>
|
||||||
|
<ctorForPredefinedListener()>
|
||||||
|
<else><! imported grammar !>
|
||||||
|
public int RuleLevel { get { return <grammar.delegators:{g| <g:delegateName()>}>.RuleLevel; } }
|
||||||
|
public void IncRuleLevel() { <grammar.delegators:{g| <g:delegateName()>}>.IncRuleLevel(); }
|
||||||
|
public void DecRuleLevel() { <grammar.delegators:{g| <g:delegateName()>}>.DecRuleLevel(); }
|
||||||
|
<ctorForDelegateGrammar()>
|
||||||
|
<endif>
|
||||||
|
<if(profile)>
|
||||||
|
public override bool AlreadyParsedRule( IIntStream input, int ruleIndex )
|
||||||
|
{
|
||||||
|
int stopIndex = GetRuleMemoization(ruleIndex, input.Index);
|
||||||
|
((Profiler)dbg).ExamineRuleMemoization(input, ruleIndex, stopIndex, <grammar.composite.rootGrammar.recognizerName>.ruleNames[ruleIndex]);
|
||||||
|
return base.AlreadyParsedRule(input, ruleIndex);
|
||||||
|
}<\n>
|
||||||
|
public override void Memoize( IIntStream input, int ruleIndex, int ruleStartIndex )
|
||||||
|
{
|
||||||
|
((Profiler)dbg).Memoize(input, ruleIndex, ruleStartIndex, <grammar.composite.rootGrammar.recognizerName>.ruleNames[ruleIndex]);
|
||||||
|
base.Memoize(input, ruleIndex, ruleStartIndex);
|
||||||
|
}<\n>
|
||||||
|
<endif>
|
||||||
|
protected virtual bool EvalPredicate( bool result, string predicate )
|
||||||
|
{
|
||||||
|
dbg.SemanticPredicate( result, predicate );
|
||||||
|
return result;
|
||||||
|
}<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
ctorForRootGrammar() ::= <<
|
||||||
|
<! bug: can't use <@super.members()> cut-n-paste instead !>
|
||||||
|
<! Same except we add port number and profile stuff if root grammar !>
|
||||||
|
<actions.(actionScope).ctorModifier; null="public"> <name>( <inputStreamType> input )
|
||||||
|
: this( input, DebugEventSocketProxy.DefaultDebuggerPort, new RecognizerSharedState() )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
<actions.(actionScope).ctorModifier; null="public"> <name>( <inputStreamType> input, int port, RecognizerSharedState state )
|
||||||
|
: base( input, state )
|
||||||
|
{
|
||||||
|
<createListenerAndHandshake()>
|
||||||
|
<grammar.directDelegates:{g|<g:delegateName()> = new <g.recognizerName>( input, dbg, this.state, this<grammar.delegators:{g|, <g:delegateName()>}> );}; separator="\n">
|
||||||
|
<parserCtorBody()>
|
||||||
|
<@finally()>
|
||||||
|
}<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
ctorForProfilingRootGrammar() ::= <<
|
||||||
|
<! bug: can't use <@super.members()> cut-n-paste instead !>
|
||||||
|
<actions.(actionScope).ctorModifier; null="public"> <name>( <inputStreamType> input )
|
||||||
|
: this( input, new Profiler(null), new RecognizerSharedState() )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
<actions.(actionScope).ctorModifier; null="public"> <name>( <inputStreamType> input, IDebugEventListener dbg, RecognizerSharedState state )
|
||||||
|
: base( input, dbg, state )
|
||||||
|
{
|
||||||
|
Profiler p = (Profiler)dbg;
|
||||||
|
p.setParser(this);
|
||||||
|
<grammar.directDelegates:
|
||||||
|
{g|<g:delegateName()> = new <g.recognizerName>( input, dbg, this.state, this<grammar.delegators:{g|, <g:delegateName()>}> );}; separator="\n">
|
||||||
|
<parserCtorBody()>
|
||||||
|
<@finally()>
|
||||||
|
}
|
||||||
|
<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** Basically we don't want to set any dbg listeners are root will have it. */
|
||||||
|
ctorForDelegateGrammar() ::= <<
|
||||||
|
<actions.(actionScope).ctorModifier; null="public"> <name>( <inputStreamType> input, IDebugEventListener dbg, RecognizerSharedState state<grammar.delegators:{g|, <g.recognizerName> <g:delegateName()>}> )
|
||||||
|
: base( input, dbg, state )
|
||||||
|
{
|
||||||
|
<grammar.directDelegates:
|
||||||
|
{g|<g:delegateName()> = new <g.recognizerName>( input, this, this.state<grammar.delegators:{g|, <g:delegateName()>}> );}; separator="\n">
|
||||||
|
<parserCtorBody()>
|
||||||
|
}<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
ctorForPredefinedListener() ::= <<
|
||||||
|
<actions.(actionScope).ctorModifier; null="public"> <name>( <inputStreamType> input, IDebugEventListener dbg )
|
||||||
|
<@superClassRef>: base( input, dbg, new RecognizerSharedState() )<@end>
|
||||||
|
{
|
||||||
|
<if(profile)>
|
||||||
|
Profiler p = (Profiler)dbg;
|
||||||
|
p.setParser(this);
|
||||||
|
<endif>
|
||||||
|
<grammar.directDelegates:{g|<g:delegateName()> = new <g.recognizerName>(input, dbg, this.state, this<grammar.delegators:{g|, <g:delegateName()>}>);}; separator="\n">
|
||||||
|
<parserCtorBody()>
|
||||||
|
<@finally()>
|
||||||
|
}<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
createListenerAndHandshake() ::= <<
|
||||||
|
<if(TREE_PARSER)>
|
||||||
|
DebugEventSocketProxy proxy = new DebugEventSocketProxy( this, port, input.TreeAdaptor );<\n>
|
||||||
|
<else>
|
||||||
|
DebugEventSocketProxy proxy = new DebugEventSocketProxy( this, port, null );<\n>
|
||||||
|
<endif>
|
||||||
|
DebugListener = proxy;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
proxy.Handshake();
|
||||||
|
}
|
||||||
|
catch ( IOException ioe )
|
||||||
|
{
|
||||||
|
ReportError( ioe );
|
||||||
|
}
|
||||||
|
>>
|
||||||
|
|
||||||
|
@genericParser.superClassName() ::= "Debug<@super.superClassName()>"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Many of the following rules were merged into CSharp2.stg.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@rule.preamble() ::= <<
|
||||||
|
if (RuleLevel == 0)
|
||||||
|
DebugListener.Commence();
|
||||||
|
IncRuleLevel();
|
||||||
|
>>
|
||||||
|
//@rule.preamble() ::= <<
|
||||||
|
//try
|
||||||
|
//{
|
||||||
|
// dbg.EnterRule( GrammarFileName, "<ruleName>" );
|
||||||
|
// if ( RuleLevel == 0 )
|
||||||
|
// {
|
||||||
|
// dbg.Commence();
|
||||||
|
// }
|
||||||
|
// IncRuleLevel();
|
||||||
|
// dbg.Location( <ruleDescriptor.tree.line>, <ruleDescriptor.tree.charPositionInLine> );<\n>
|
||||||
|
//>>
|
||||||
|
|
||||||
|
@rule.postamble() ::= <<
|
||||||
|
DecRuleLevel();
|
||||||
|
if (RuleLevel == 0)
|
||||||
|
DebugListener.Terminate();
|
||||||
|
>>
|
||||||
|
//@rule.postamble() ::= <<
|
||||||
|
//dbg.Location(<ruleDescriptor.EORNode.line>, <ruleDescriptor.EORNode.charPositionInLine>);<\n>
|
||||||
|
//}
|
||||||
|
//finally
|
||||||
|
//{
|
||||||
|
// dbg.ExitRule( GrammarFileName, "<ruleName>" );
|
||||||
|
// DecRuleLevel();
|
||||||
|
// if ( RuleLevel == 0 )
|
||||||
|
// {
|
||||||
|
// dbg.Terminate();
|
||||||
|
// }
|
||||||
|
//}<\n>
|
||||||
|
//>>
|
||||||
|
|
||||||
|
//@insertSynpreds.start() ::= "dbg.BeginBacktrack( state.backtracking );"
|
||||||
|
//@insertSynpreds.stop() ::= "dbg.EndBacktrack( state.backtracking, success );"
|
||||||
|
|
||||||
|
// Common debug event triggers used by region overrides below
|
||||||
|
|
||||||
|
//enterSubRule() ::= <<
|
||||||
|
//try
|
||||||
|
//{
|
||||||
|
// dbg.EnterSubRule( <decisionNumber> );<\n>
|
||||||
|
//>>
|
||||||
|
|
||||||
|
//exitSubRule() ::= <<
|
||||||
|
//}
|
||||||
|
//finally
|
||||||
|
//{
|
||||||
|
// dbg.ExitSubRule( <decisionNumber> );
|
||||||
|
//}<\n>
|
||||||
|
//>>
|
||||||
|
|
||||||
|
//enterDecision() ::= <<
|
||||||
|
//try
|
||||||
|
//{
|
||||||
|
// dbg.EnterDecision( <decisionNumber> );<\n>
|
||||||
|
//>>
|
||||||
|
|
||||||
|
//exitDecision() ::= <<
|
||||||
|
//}
|
||||||
|
//finally
|
||||||
|
//{
|
||||||
|
// dbg.ExitDecision( <decisionNumber> );
|
||||||
|
//}<\n>
|
||||||
|
//>>
|
||||||
|
|
||||||
|
//enterAlt(n) ::= "dbg.EnterAlt( <n> );<\n>"
|
||||||
|
|
||||||
|
// Region overrides that tell various constructs to add debugging triggers
|
||||||
|
|
||||||
|
//@block.predecision() ::= "<enterSubRule()><enterDecision()>"
|
||||||
|
|
||||||
|
//@block.postdecision() ::= "<exitDecision()>"
|
||||||
|
|
||||||
|
//@block.postbranch() ::= "<exitSubRule()>"
|
||||||
|
|
||||||
|
//@ruleBlock.predecision() ::= "<enterDecision()>"
|
||||||
|
|
||||||
|
//@ruleBlock.postdecision() ::= "<exitDecision()>"
|
||||||
|
|
||||||
|
//@ruleBlockSingleAlt.prealt() ::= "<enterAlt(n=\"1\")>"
|
||||||
|
|
||||||
|
//@blockSingleAlt.prealt() ::= "<enterAlt(n=\"1\")>"
|
||||||
|
|
||||||
|
//@positiveClosureBlock.preloop() ::= "<enterSubRule()>"
|
||||||
|
|
||||||
|
//@positiveClosureBlock.postloop() ::= "<exitSubRule()>"
|
||||||
|
|
||||||
|
//@positiveClosureBlock.predecision() ::= "<enterDecision()>"
|
||||||
|
|
||||||
|
//@positiveClosureBlock.postdecision() ::= "<exitDecision()>"
|
||||||
|
|
||||||
|
//@positiveClosureBlock.earlyExitException() ::=
|
||||||
|
// "dbg.RecognitionException( eee<decisionNumber> );<\n>"
|
||||||
|
|
||||||
|
//@closureBlock.preloop() ::= "<enterSubRule()>"
|
||||||
|
|
||||||
|
//@closureBlock.postloop() ::= "<exitSubRule()>"
|
||||||
|
|
||||||
|
//@closureBlock.predecision() ::= "<enterDecision()>"
|
||||||
|
|
||||||
|
//@closureBlock.postdecision() ::= "<exitDecision()>"
|
||||||
|
|
||||||
|
//@altSwitchCase.prealt() ::= "<enterAlt(n=i)>"
|
||||||
|
|
||||||
|
//@element.prematch() ::=
|
||||||
|
// "dbg.Location( <it.line>, <it.pos> );"
|
||||||
|
|
||||||
|
//@matchSet.mismatchedSetException() ::=
|
||||||
|
// "dbg.RecognitionException( mse );"
|
||||||
|
|
||||||
|
//@dfaState.noViableAltException() ::= "dbg.RecognitionException( nvae );"
|
||||||
|
|
||||||
|
//@dfaStateSwitch.noViableAltException() ::= "dbg.RecognitionException( nvae );"
|
||||||
|
|
||||||
|
//dfaDecision(decisionNumber,description) ::= <<
|
||||||
|
//try
|
||||||
|
//{
|
||||||
|
// isCyclicDecision = true;
|
||||||
|
// <super.dfaDecision(...)>
|
||||||
|
//}
|
||||||
|
//catch ( NoViableAltException nvae )
|
||||||
|
//{
|
||||||
|
// dbg.RecognitionException( nvae );
|
||||||
|
// throw nvae;
|
||||||
|
//}
|
||||||
|
//>>
|
||||||
|
|
||||||
|
//@cyclicDFA.errorMethod() ::= <<
|
||||||
|
//public override void Error( NoViableAltException nvae )
|
||||||
|
//{
|
||||||
|
// ((DebugParser)recognizer).dbg.RecognitionException( nvae );
|
||||||
|
//}
|
||||||
|
//>>
|
||||||
|
|
||||||
|
/** Force predicate validation to trigger an event */
|
||||||
|
evalPredicate(pred,description) ::= <<
|
||||||
|
EvalPredicate(<pred>, "<description>")
|
||||||
|
>>
|
||||||
171
packages/Antlr34.3.4.19004.1/tools/Codegen/Templates/CSharp2/ST.stg
vendored
Normal file
171
packages/Antlr34.3.4.19004.1/tools/Codegen/Templates/CSharp2/ST.stg
vendored
Normal file
@@ -0,0 +1,171 @@
|
|||||||
|
/*
|
||||||
|
* [The "BSD license"]
|
||||||
|
* Copyright (c) 2007-2008 Johannes Luber
|
||||||
|
* Copyright (c) 2005-2007 Kunle Odutola
|
||||||
|
* Copyright (c) 2011 Sam Harwell
|
||||||
|
* Copyright (c) 2011 Terence Parr
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
/** Template subgroup to add template rewrite output
|
||||||
|
* If debugging, then you'll also get STDbg.stg loaded.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@outputFile.imports() ::= <<
|
||||||
|
<@super.imports()>
|
||||||
|
using Antlr.StringTemplate;
|
||||||
|
using Antlr.StringTemplate.Language;
|
||||||
|
<if(!backtracking)>
|
||||||
|
using Hashtable = System.Collections.Hashtable;
|
||||||
|
<endif>
|
||||||
|
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** Add this to each rule's return value struct */
|
||||||
|
@returnScope.ruleReturnMembers() ::= <<
|
||||||
|
private StringTemplate _st;
|
||||||
|
public StringTemplate Template { get { return _st; } set { _st = value; } }
|
||||||
|
public override string ToString() { return (Template==null) ? string.Empty : Template.ToString(); }
|
||||||
|
>>
|
||||||
|
|
||||||
|
@genericParser.members() ::= <<
|
||||||
|
<@super.members()>
|
||||||
|
protected StringTemplateGroup templateLib = new StringTemplateGroup("<name>Templates", typeof(AngleBracketTemplateLexer) );
|
||||||
|
|
||||||
|
public StringTemplateGroup TemplateLib
|
||||||
|
{
|
||||||
|
get { return this.templateLib; }
|
||||||
|
set { this.templateLib = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// \<summary> Allows convenient multi-value initialization:
|
||||||
|
/// "new STAttrMap().Add(...).Add(...)"
|
||||||
|
/// \</summary>
|
||||||
|
protected class STAttrMap : Hashtable
|
||||||
|
{
|
||||||
|
public STAttrMap Add(string attrName, object value)
|
||||||
|
{
|
||||||
|
base.Add(attrName, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public STAttrMap Add(string attrName, int value)
|
||||||
|
{
|
||||||
|
base.Add(attrName, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** x+=rule when output=template */
|
||||||
|
ruleRefAndListLabel(rule,label,elementIndex,args,scope) ::= <<
|
||||||
|
<ruleRef(...)>
|
||||||
|
<listLabel(elem=label+".Template",...)>
|
||||||
|
>>
|
||||||
|
|
||||||
|
rewriteTemplate(alts) ::= <<
|
||||||
|
|
||||||
|
// TEMPLATE REWRITE
|
||||||
|
<if(backtracking)>
|
||||||
|
if ( <actions.(actionScope).synpredgate> )
|
||||||
|
{
|
||||||
|
<alts:rewriteTemplateAlt(); separator="else ">
|
||||||
|
<if(rewriteMode)><replaceTextInLine()><endif>
|
||||||
|
}
|
||||||
|
<else>
|
||||||
|
<alts:rewriteTemplateAlt(); separator="else ">
|
||||||
|
<if(rewriteMode)><replaceTextInLine()><endif>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
replaceTextInLine() ::= <<
|
||||||
|
<if(TREE_PARSER)>
|
||||||
|
((TokenRewriteStream)input.TokenStream).Replace(
|
||||||
|
input.TreeAdaptor.GetTokenStartIndex(retval.Start),
|
||||||
|
input.TreeAdaptor.GetTokenStopIndex(retval.Start),
|
||||||
|
retval.Template);
|
||||||
|
<else>
|
||||||
|
((TokenRewriteStream)input).Replace(
|
||||||
|
((IToken)retval.Start).TokenIndex,
|
||||||
|
input.LT(-1).TokenIndex,
|
||||||
|
retval.Template);
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
rewriteTemplateAlt() ::= <<
|
||||||
|
// <it.description>
|
||||||
|
<if(it.pred)>
|
||||||
|
if (<it.pred>) {
|
||||||
|
retval.Template = <it.alt>;
|
||||||
|
}<\n>
|
||||||
|
<else>
|
||||||
|
{
|
||||||
|
retval.Template = <it.alt>;
|
||||||
|
}<\n>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
rewriteEmptyTemplate(alts) ::= <<
|
||||||
|
null;
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** Invoke a template with a set of attribute name/value pairs.
|
||||||
|
* Set the value of the rule's template *after* having set
|
||||||
|
* the attributes because the rule's template might be used as
|
||||||
|
* an attribute to build a bigger template; you get a self-embedded
|
||||||
|
* template.
|
||||||
|
*/
|
||||||
|
rewriteExternalTemplate(name,args) ::= <<
|
||||||
|
templateLib.GetInstanceOf("<name>"<if(args)>,
|
||||||
|
new STAttrMap()<args:{a | .Add("<a.name>", <a.value>)}>
|
||||||
|
<endif>)
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** expr is a string expression that says what template to load */
|
||||||
|
rewriteIndirectTemplate(expr,args) ::= <<
|
||||||
|
templateLib.GetInstanceOf(<expr><if(args)>,
|
||||||
|
new STAttrMap()<args:{a | .Add("<a.name>", <a.value>)}>
|
||||||
|
<endif>)
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** Invoke an inline template with a set of attribute name/value pairs */
|
||||||
|
rewriteInlineTemplate(args, template) ::= <<
|
||||||
|
new StringTemplate(templateLib, "<template>"<if(args)>,
|
||||||
|
new STAttrMap()<args:{a | .Add("<a.name>", <a.value>)}>
|
||||||
|
<endif>)
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** plain -> {foo} action */
|
||||||
|
rewriteAction(action) ::= <<
|
||||||
|
<action>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** An action has %st.attrName=expr; or %{st}.attrName=expr; */
|
||||||
|
actionSetAttribute(st,attrName,expr) ::= <<
|
||||||
|
(<st>).SetAttribute("<attrName>",<expr>);
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** Translate %{stringExpr} */
|
||||||
|
actionStringConstructor(stringExpr) ::= <<
|
||||||
|
new StringTemplate(templateLib,<stringExpr>)
|
||||||
|
>>
|
||||||
428
packages/Antlr34.3.4.19004.1/tools/Codegen/Templates/CSharp3/AST.stg
vendored
Normal file
428
packages/Antlr34.3.4.19004.1/tools/Codegen/Templates/CSharp3/AST.stg
vendored
Normal file
@@ -0,0 +1,428 @@
|
|||||||
|
/*
|
||||||
|
* [The "BSD license"]
|
||||||
|
* Copyright (c) 2011 Terence Parr
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Conversion to C#:
|
||||||
|
* Copyright (c) 2011 Sam Harwell, Pixel Mine, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@outputFile.imports() ::= <<
|
||||||
|
<@super.imports()>
|
||||||
|
|
||||||
|
<if(!TREE_PARSER)>
|
||||||
|
<! tree parser would already have imported !>
|
||||||
|
using Antlr.Runtime.Tree;
|
||||||
|
using RewriteRuleITokenStream = Antlr.Runtime.Tree.RewriteRuleTokenStream;
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
@genericParser.members() ::= <<
|
||||||
|
<@super.members()>
|
||||||
|
<parserMembers()>
|
||||||
|
>>
|
||||||
|
|
||||||
|
parserCtorBody() ::= <<
|
||||||
|
<super.parserCtorBody()>
|
||||||
|
<treeAdaptorType()> treeAdaptor = default(<treeAdaptorType()>);
|
||||||
|
CreateTreeAdaptor(ref treeAdaptor);
|
||||||
|
TreeAdaptor = treeAdaptor<if(!actions.(actionScope).treeAdaptorType)> ?? new CommonTreeAdaptor()<endif>;
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** Add an adaptor property that knows how to build trees */
|
||||||
|
parserMembers() ::= <<
|
||||||
|
// Implement this function in your helper file to use a custom tree adaptor
|
||||||
|
partial void CreateTreeAdaptor(ref <treeAdaptorType()> adaptor);
|
||||||
|
|
||||||
|
private <treeAdaptorType()> adaptor;
|
||||||
|
|
||||||
|
public <treeAdaptorType()> TreeAdaptor
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return adaptor;
|
||||||
|
}
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this.adaptor = value;
|
||||||
|
<grammar.directDelegates:{g|<g:delegateName()>.TreeAdaptor = this.adaptor;}>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
>>
|
||||||
|
|
||||||
|
treeAdaptorType() ::= <<
|
||||||
|
<actions.(actionScope).treeAdaptorType; null="ITreeAdaptor">
|
||||||
|
>>
|
||||||
|
|
||||||
|
ruleReturnBaseType() ::= <%
|
||||||
|
Ast<if(TREE_PARSER)>Tree<else>Parser<endif>RuleReturnScope\<<ASTLabelType>, <labelType>>
|
||||||
|
%>
|
||||||
|
|
||||||
|
/** Add a variable to track rule's return AST */
|
||||||
|
ruleDeclarations() ::= <<
|
||||||
|
<super.ruleDeclarations()>
|
||||||
|
<ASTLabelType> root_0 = default(<ASTLabelType>);<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
ruleLabelDefs(ruleDescriptor, labelType, ASTLabelType, rewriteElementType) ::= <%
|
||||||
|
<super.ruleLabelDefs(...)>
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
<[ruleDescriptor.tokenLabels,ruleDescriptor.wildcardTreeLabels,ruleDescriptor.wildcardTreeListLabels]
|
||||||
|
:{it|<\n><ASTLabelType> <it.label.text>_tree = default(<ASTLabelType>);}>
|
||||||
|
<ruleDescriptor.tokenListLabels:{it|<\n><ASTLabelType> <it.label.text>_tree = default(<ASTLabelType>);}>
|
||||||
|
<ruleDescriptor.allTokenRefsInAltsWithRewrites
|
||||||
|
:{it|<\n>RewriteRule<rewriteElementType>Stream stream_<it>=new RewriteRule<rewriteElementType>Stream(adaptor,"token <it>");}>
|
||||||
|
<ruleDescriptor.allRuleRefsInAltsWithRewrites
|
||||||
|
:{it|<\n>RewriteRuleSubtreeStream stream_<it>=new RewriteRuleSubtreeStream(adaptor,"rule <it>");}>
|
||||||
|
<endif>
|
||||||
|
%>
|
||||||
|
|
||||||
|
/** When doing auto AST construction, we must define some variables;
|
||||||
|
* These should be turned off if doing rewrites. This must be a "mode"
|
||||||
|
* as a rule could have both rewrite and AST within the same alternative
|
||||||
|
* block.
|
||||||
|
*/
|
||||||
|
@alt.declarations() ::= <<
|
||||||
|
<if(autoAST && outerAlt && !rewriteMode && !ruleDescriptor.isSynPred)>
|
||||||
|
root_0 = (<ASTLabelType>)adaptor.Nil();
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
// T r a c k i n g R u l e E l e m e n t s
|
||||||
|
|
||||||
|
/** ID and track it for use in a rewrite rule */
|
||||||
|
tokenRefTrack(token,label,elementIndex,terminalOptions) ::= <<
|
||||||
|
<tokenRefBang(...)> <! Track implies no auto AST construction!>
|
||||||
|
<if(backtracking)>if (<actions.(actionScope).synpredgate>) <endif>stream_<token>.Add(<label>);<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** ids+=ID and track it for use in a rewrite rule; adds to ids *and*
|
||||||
|
* to the tracking list stream_ID for use in the rewrite.
|
||||||
|
*/
|
||||||
|
tokenRefTrackAndListLabel(token,label,elementIndex,terminalOptions) ::= <<
|
||||||
|
<tokenRefTrack(...)>
|
||||||
|
<listLabelElem(elem=label,elemType=labelType,...)>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** ^(ID ...) track for rewrite */
|
||||||
|
tokenRefRuleRootTrack(token,label,elementIndex,terminalOptions) ::= <<
|
||||||
|
<tokenRefBang(...)>
|
||||||
|
<if(backtracking)>if (<actions.(actionScope).synpredgate>) <endif>stream_<token>.Add(<label>);
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** Match ^(label+=TOKEN ...) track for rewrite */
|
||||||
|
tokenRefRuleRootTrackAndListLabel(token,label,elementIndex,terminalOptions) ::= <<
|
||||||
|
<tokenRefRuleRootTrack(...)>
|
||||||
|
<listLabelElem(elem=label,elemType=labelType,...)>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** rule when output=AST and tracking for rewrite */
|
||||||
|
ruleRefTrack(rule,label,elementIndex,args,scope) ::= <<
|
||||||
|
<super.ruleRef(...)>
|
||||||
|
<if(backtracking)>if (<actions.(actionScope).synpredgate>) <endif>stream_<rule.name>.Add(<label>.Tree);
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** x+=rule when output=AST and tracking for rewrite */
|
||||||
|
ruleRefTrackAndListLabel(rule,label,elementIndex,args,scope) ::= <<
|
||||||
|
<ruleRefTrack(...)>
|
||||||
|
<listLabelElem(elem={<label>.Tree},elemType=ASTLabelType,...)>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** ^(rule ...) rewrite */
|
||||||
|
ruleRefRuleRootTrack(rule,label,elementIndex,args,scope) ::= <<
|
||||||
|
<ruleRefRuleRoot(...)>
|
||||||
|
<if(backtracking)>if (<actions.(actionScope).synpredgate>) <endif>stream_<rule>.Add(<label>.Tree);
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** ^(x+=rule ...) rewrite */
|
||||||
|
ruleRefRuleRootTrackAndListLabel(rule,label,elementIndex,args,scope) ::= <<
|
||||||
|
<ruleRefRuleRootTrack(...)>
|
||||||
|
<listLabelElem(elem={<label>.Tree},elemType=ASTLabelType,...)>
|
||||||
|
>>
|
||||||
|
|
||||||
|
// R e w r i t e
|
||||||
|
|
||||||
|
rewriteCode(
|
||||||
|
alts, description,
|
||||||
|
referencedElementsDeep, // ALL referenced elements to right of ->
|
||||||
|
referencedTokenLabels,
|
||||||
|
referencedTokenListLabels,
|
||||||
|
referencedRuleLabels,
|
||||||
|
referencedRuleListLabels,
|
||||||
|
referencedWildcardLabels,
|
||||||
|
referencedWildcardListLabels,
|
||||||
|
rewriteBlockLevel, enclosingTreeLevel, treeLevel) ::= <<
|
||||||
|
<\n>{
|
||||||
|
// AST REWRITE
|
||||||
|
// elements: <referencedElementsDeep; separator=", ">
|
||||||
|
// token labels: <referencedTokenLabels; separator=", ">
|
||||||
|
// rule labels: <referencedRuleLabels; separator=", ">
|
||||||
|
// token list labels: <referencedTokenListLabels; separator=", ">
|
||||||
|
// rule list labels: <referencedRuleListLabels; separator=", ">
|
||||||
|
// wildcard labels: <[referencedWildcardLabels,referencedWildcardListLabels]; separator=", ">
|
||||||
|
<if(backtracking)>
|
||||||
|
if (<actions.(actionScope).synpredgate>) {
|
||||||
|
<endif>
|
||||||
|
<prevRuleRootRef()>.Tree = root_0;
|
||||||
|
<rewriteCodeLabels()>
|
||||||
|
root_0 = (<ASTLabelType>)adaptor.Nil();
|
||||||
|
<alts:rewriteAlt(); separator="else ">
|
||||||
|
<! if tree parser and rewrite=true !>
|
||||||
|
<if(TREE_PARSER&&rewriteMode)>
|
||||||
|
<prevRuleRootRef()>.Tree = (<ASTLabelType>)adaptor.RulePostProcessing(root_0);
|
||||||
|
if (<prevRuleRootRef()>.Tree != null)
|
||||||
|
input.ReplaceChildren(adaptor.GetParent(retval.Start), adaptor.GetChildIndex(retval.Start), adaptor.GetChildIndex(_last), retval.Tree);
|
||||||
|
<endif>
|
||||||
|
<! if parser or tree-parser && rewrite!=true, we need to set result !>
|
||||||
|
<if(!TREE_PARSER||!rewriteMode)>
|
||||||
|
<prevRuleRootRef()>.Tree = root_0;
|
||||||
|
<endif>
|
||||||
|
<if(backtracking)>
|
||||||
|
}
|
||||||
|
<endif>
|
||||||
|
}
|
||||||
|
|
||||||
|
>>
|
||||||
|
|
||||||
|
rewriteCodeLabels() ::= <<
|
||||||
|
<referencedTokenLabels
|
||||||
|
:{it|RewriteRule<rewriteElementType>Stream stream_<it>=new RewriteRule<rewriteElementType>Stream(adaptor,"token <it>",<it>);};
|
||||||
|
separator="\n"
|
||||||
|
>
|
||||||
|
<referencedTokenListLabels
|
||||||
|
:{it|RewriteRule<rewriteElementType>Stream stream_<it>=new RewriteRule<rewriteElementType>Stream(adaptor,"token <it>", list_<it>);};
|
||||||
|
separator="\n"
|
||||||
|
>
|
||||||
|
<referencedWildcardLabels
|
||||||
|
:{it|RewriteRuleSubtreeStream stream_<it>=new RewriteRuleSubtreeStream(adaptor,"wildcard <it>",<it>);};
|
||||||
|
separator="\n"
|
||||||
|
>
|
||||||
|
<referencedWildcardListLabels
|
||||||
|
:{it|RewriteRuleSubtreeStream stream_<it>=new RewriteRuleSubtreeStream(adaptor,"wildcard <it>",list_<it>);};
|
||||||
|
separator="\n"
|
||||||
|
>
|
||||||
|
<referencedRuleLabels
|
||||||
|
:{it|RewriteRuleSubtreeStream stream_<it>=new RewriteRuleSubtreeStream(adaptor,"rule <it>",<it>!=null?<it>.Tree:null);};
|
||||||
|
separator="\n"
|
||||||
|
>
|
||||||
|
<referencedRuleListLabels
|
||||||
|
:{it|RewriteRuleSubtreeStream stream_<it>=new RewriteRuleSubtreeStream(adaptor,"token <it>",list_<it>);};
|
||||||
|
separator="\n"
|
||||||
|
>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** Generate code for an optional rewrite block; note it uses the deep ref'd element
|
||||||
|
* list rather shallow like other blocks.
|
||||||
|
*/
|
||||||
|
rewriteOptionalBlock(
|
||||||
|
alt,rewriteBlockLevel,
|
||||||
|
referencedElementsDeep, // all nested refs
|
||||||
|
referencedElements, // elements in immediately block; no nested blocks
|
||||||
|
description) ::=
|
||||||
|
<<
|
||||||
|
// <fileName>:<description>
|
||||||
|
if (<referencedElementsDeep:{el | stream_<el>.HasNext}; separator="||">)
|
||||||
|
{
|
||||||
|
<alt>
|
||||||
|
}
|
||||||
|
<referencedElementsDeep:{el | stream_<el>.Reset();<\n>}>
|
||||||
|
>>
|
||||||
|
|
||||||
|
rewriteClosureBlock(
|
||||||
|
alt,rewriteBlockLevel,
|
||||||
|
referencedElementsDeep, // all nested refs
|
||||||
|
referencedElements, // elements in immediately block; no nested blocks
|
||||||
|
description) ::=
|
||||||
|
<<
|
||||||
|
// <fileName>:<description>
|
||||||
|
while ( <referencedElements:{el | stream_<el>.HasNext}; separator="||"> )
|
||||||
|
{
|
||||||
|
<alt>
|
||||||
|
}
|
||||||
|
<referencedElements:{el | stream_<el>.Reset();<\n>}>
|
||||||
|
>>
|
||||||
|
|
||||||
|
rewritePositiveClosureBlock(
|
||||||
|
alt,rewriteBlockLevel,
|
||||||
|
referencedElementsDeep, // all nested refs
|
||||||
|
referencedElements, // elements in immediately block; no nested blocks
|
||||||
|
description) ::=
|
||||||
|
<<
|
||||||
|
if (!(<referencedElements:{el | stream_<el>.HasNext}; separator="||">))
|
||||||
|
{
|
||||||
|
throw new RewriteEarlyExitException();
|
||||||
|
}
|
||||||
|
while ( <referencedElements:{el | stream_<el>.HasNext}; separator="||"> )
|
||||||
|
{
|
||||||
|
<alt>
|
||||||
|
}
|
||||||
|
<referencedElements:{el | stream_<el>.Reset();<\n>}>
|
||||||
|
>>
|
||||||
|
|
||||||
|
rewriteAlt(a) ::= <<
|
||||||
|
// <a.description>
|
||||||
|
<if(a.pred)>
|
||||||
|
if (<a.pred>)
|
||||||
|
{
|
||||||
|
<a.alt>
|
||||||
|
}
|
||||||
|
<else>
|
||||||
|
{
|
||||||
|
<a.alt>
|
||||||
|
}
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** For empty rewrites: "r : ... -> ;" */
|
||||||
|
rewriteEmptyAlt() ::= "root_0 = null;"
|
||||||
|
|
||||||
|
rewriteTree(root,children,description,enclosingTreeLevel,treeLevel) ::= <<
|
||||||
|
// <fileName>:<description>
|
||||||
|
{
|
||||||
|
<ASTLabelType> root_<treeLevel> = (<ASTLabelType>)adaptor.Nil();
|
||||||
|
<root:rewriteElement()>
|
||||||
|
<children:rewriteElement()>
|
||||||
|
adaptor.AddChild(root_<enclosingTreeLevel>, root_<treeLevel>);
|
||||||
|
}<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
rewriteElementList(elements) ::= "<elements:rewriteElement()>"
|
||||||
|
|
||||||
|
rewriteElement(e) ::= <%
|
||||||
|
<@pregen()>
|
||||||
|
DebugLocation(<e.line>, <e.pos>);<\n>
|
||||||
|
<e.el>
|
||||||
|
%>
|
||||||
|
|
||||||
|
/** Gen ID or ID[args] */
|
||||||
|
rewriteTokenRef(token,elementIndex,terminalOptions,args) ::= <<
|
||||||
|
adaptor.AddChild(root_<treeLevel>, <createRewriteNodeFromElement(...)>);<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** Gen $label ... where defined via label=ID */
|
||||||
|
rewriteTokenLabelRef(label,elementIndex) ::= <<
|
||||||
|
adaptor.AddChild(root_<treeLevel>, stream_<label>.NextNode());<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** Gen $label ... where defined via label+=ID */
|
||||||
|
rewriteTokenListLabelRef(label,elementIndex) ::= <<
|
||||||
|
adaptor.AddChild(root_<treeLevel>, stream_<label>.NextNode());<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** Gen ^($label ...) */
|
||||||
|
rewriteTokenLabelRefRoot(label,elementIndex) ::= <<
|
||||||
|
root_<treeLevel> = (<ASTLabelType>)adaptor.BecomeRoot(stream_<label>.NextNode(), root_<treeLevel>);<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** Gen ^($label ...) where label+=... */
|
||||||
|
rewriteTokenListLabelRefRoot ::= rewriteTokenLabelRefRoot
|
||||||
|
|
||||||
|
/** Gen ^(ID ...) or ^(ID[args] ...) */
|
||||||
|
rewriteTokenRefRoot(token,elementIndex,terminalOptions,args) ::= <<
|
||||||
|
root_<treeLevel> = (<ASTLabelType>)adaptor.BecomeRoot(<createRewriteNodeFromElement(...)>, root_<treeLevel>);<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
rewriteImaginaryTokenRef(args,token,terminalOptions,elementIndex) ::= <<
|
||||||
|
adaptor.AddChild(root_<treeLevel>, <createImaginaryNode(tokenType=token, ...)>);<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
rewriteImaginaryTokenRefRoot(args,token,terminalOptions,elementIndex) ::= <<
|
||||||
|
root_<treeLevel> = (<ASTLabelType>)adaptor.BecomeRoot(<createImaginaryNode(tokenType=token, ...)>, root_<treeLevel>);<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** plain -> {foo} action */
|
||||||
|
rewriteAction(action) ::= <<
|
||||||
|
root_0 = <action>;<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** What is the name of the previous value of this rule's root tree? This
|
||||||
|
* let's us refer to $rule to mean previous value. I am reusing the
|
||||||
|
* variable 'tree' sitting in retval struct to hold the value of root_0 right
|
||||||
|
* before I set it during rewrites. The assign will be to retval.tree.
|
||||||
|
*/
|
||||||
|
prevRuleRootRef() ::= "retval"
|
||||||
|
|
||||||
|
rewriteRuleRef(rule) ::= <<
|
||||||
|
adaptor.AddChild(root_<treeLevel>, stream_<rule>.NextTree());<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
rewriteRuleRefRoot(rule) ::= <<
|
||||||
|
root_<treeLevel> = (<ASTLabelType>)adaptor.BecomeRoot(stream_<rule>.NextNode(), root_<treeLevel>);<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
rewriteNodeAction(action) ::= <<
|
||||||
|
adaptor.AddChild(root_<treeLevel>, <action>);<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
rewriteNodeActionRoot(action) ::= <<
|
||||||
|
root_<treeLevel> = (<ASTLabelType>)adaptor.BecomeRoot(<action>, root_<treeLevel>);<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** Gen $ruleLabel ... where defined via ruleLabel=rule */
|
||||||
|
rewriteRuleLabelRef(label) ::= <<
|
||||||
|
adaptor.AddChild(root_<treeLevel>, stream_<label>.NextTree());<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** Gen $ruleLabel ... where defined via ruleLabel+=rule */
|
||||||
|
rewriteRuleListLabelRef(label) ::= <<
|
||||||
|
adaptor.AddChild(root_<treeLevel>, stream_<label>.NextTree());<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** Gen ^($ruleLabel ...) where ruleLabel=rule */
|
||||||
|
rewriteRuleLabelRefRoot(label) ::= <<
|
||||||
|
root_<treeLevel> = (<ASTLabelType>)adaptor.BecomeRoot(stream_<label>.NextNode(), root_<treeLevel>);<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** Gen ^($ruleLabel ...) where ruleLabel+=rule */
|
||||||
|
rewriteRuleListLabelRefRoot(label) ::= <<
|
||||||
|
root_<treeLevel> = (<ASTLabelType>)adaptor.BecomeRoot(stream_<label>.NextNode(), root_<treeLevel>);<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
rewriteWildcardLabelRef(label) ::= <<
|
||||||
|
adaptor.AddChild(root_<treeLevel>, stream_<label>.NextTree());<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
createImaginaryNode(tokenType,terminalOptions,args) ::= <%
|
||||||
|
<if(terminalOptions.node)>
|
||||||
|
<! new MethodNode(IDLabel, args) !>
|
||||||
|
new <terminalOptions.node>(<tokenType><if(args)>, <args; separator=", "><endif>)
|
||||||
|
<else>
|
||||||
|
(<ASTLabelType>)adaptor.Create(<tokenType>, <args; separator=", "><if(!args)>"<tokenType>"<endif>)
|
||||||
|
<endif>
|
||||||
|
%>
|
||||||
|
|
||||||
|
createRewriteNodeFromElement(token,terminalOptions,args) ::= <%
|
||||||
|
<if(terminalOptions.node)>
|
||||||
|
new <terminalOptions.node>(stream_<token>.NextToken()<if(args)>, <args; separator=", "><endif>)
|
||||||
|
<else>
|
||||||
|
<if(args)> <! must create new node from old !>
|
||||||
|
adaptor.Create(<token>, <args; separator=", ">)
|
||||||
|
<else>
|
||||||
|
stream_<token>.NextNode()
|
||||||
|
<endif>
|
||||||
|
<endif>
|
||||||
|
%>
|
||||||
98
packages/Antlr34.3.4.19004.1/tools/Codegen/Templates/CSharp3/ASTDbg.stg
vendored
Normal file
98
packages/Antlr34.3.4.19004.1/tools/Codegen/Templates/CSharp3/ASTDbg.stg
vendored
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
/*
|
||||||
|
* [The "BSD license"]
|
||||||
|
* Copyright (c) 2005-2008 Terence Parr
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Conversion to C#:
|
||||||
|
* Copyright (c) 2008-2009 Sam Harwell, Pixel Mine, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** Template overrides to add debugging to AST stuff. Dynamic inheritance
|
||||||
|
* hierarchy is set up as ASTDbg : AST : Dbg : Java by code generator.
|
||||||
|
*/
|
||||||
|
|
||||||
|
parserMembers() ::= <<
|
||||||
|
// Implement this function in your helper file to use a custom tree adaptor
|
||||||
|
partial void InitializeTreeAdaptor();
|
||||||
|
protected DebugTreeAdaptor adaptor;
|
||||||
|
|
||||||
|
public ITreeAdaptor TreeAdaptor
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return adaptor;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
<if(grammar.grammarIsRoot)>
|
||||||
|
this.adaptor = new DebugTreeAdaptor(dbg,adaptor);
|
||||||
|
<else>
|
||||||
|
this.adaptor = (DebugTreeAdaptor)adaptor; // delegator sends dbg adaptor
|
||||||
|
<endif><\n>
|
||||||
|
<grammar.directDelegates:{g|<g:delegateName()>.TreeAdaptor = this.adaptor;}>
|
||||||
|
}
|
||||||
|
}<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
parserCtorBody() ::= <<
|
||||||
|
<super.parserCtorBody()>
|
||||||
|
>>
|
||||||
|
|
||||||
|
createListenerAndHandshake() ::= <<
|
||||||
|
DebugEventSocketProxy proxy = new DebugEventSocketProxy( this, port, <if(TREE_PARSER)>input.TreeAdaptor<else>adaptor<endif> );
|
||||||
|
DebugListener = proxy;
|
||||||
|
<inputStreamType> = new Debug<inputStreamType>( input, proxy );
|
||||||
|
try
|
||||||
|
{
|
||||||
|
proxy.Handshake();
|
||||||
|
}
|
||||||
|
catch ( IOException ioe )
|
||||||
|
{
|
||||||
|
ReportError( ioe );
|
||||||
|
}
|
||||||
|
>>
|
||||||
|
|
||||||
|
@ctorForRootGrammar.finally() ::= <<
|
||||||
|
ITreeAdaptor adap = new CommonTreeAdaptor();
|
||||||
|
TreeAdaptor = adap;
|
||||||
|
proxy.TreeAdaptor = adap;
|
||||||
|
>>
|
||||||
|
|
||||||
|
@ctorForProfilingRootGrammar.finally() ::=<<
|
||||||
|
ITreeAdaptor adap = new CommonTreeAdaptor();
|
||||||
|
TreeAdaptor = adap;
|
||||||
|
>>
|
||||||
|
|
||||||
|
@ctorForPredefinedListener.superClassRef() ::= ": base( input, dbg )"
|
||||||
|
|
||||||
|
@ctorForPredefinedListener.finally() ::=<<
|
||||||
|
<if(grammar.grammarIsRoot)><! don't create new adaptor for delegates !>
|
||||||
|
ITreeAdaptor adap = new CommonTreeAdaptor();
|
||||||
|
TreeAdaptor = adap;<\n>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
//@rewriteElement.pregen() ::= "dbg.Location( <e.line>, <e.pos> );"
|
||||||
203
packages/Antlr34.3.4.19004.1/tools/Codegen/Templates/CSharp3/ASTParser.stg
vendored
Normal file
203
packages/Antlr34.3.4.19004.1/tools/Codegen/Templates/CSharp3/ASTParser.stg
vendored
Normal file
@@ -0,0 +1,203 @@
|
|||||||
|
/*
|
||||||
|
* [The "BSD license"]
|
||||||
|
* Copyright (c) 2011 Terence Parr
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Conversion to C#:
|
||||||
|
* Copyright (c) 2011 Sam Harwell, Pixel Mine, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** Templates for building ASTs during normal parsing.
|
||||||
|
*
|
||||||
|
* Deal with many combinations. Dimensions are:
|
||||||
|
* Auto build or rewrite
|
||||||
|
* no label, label, list label (label/no-label handled together)
|
||||||
|
* child, root
|
||||||
|
* token, set, rule, wildcard
|
||||||
|
*
|
||||||
|
* The situation is not too bad as rewrite (->) usage makes ^ and !
|
||||||
|
* invalid. There is no huge explosion of combinations.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@rule.setErrorReturnValue() ::= <<
|
||||||
|
retval.Tree = (<ASTLabelType>)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);
|
||||||
|
<! System.out.WriteLine("<ruleName> returns "+((CommonTree)retval.tree).toStringTree()); !>
|
||||||
|
>>
|
||||||
|
|
||||||
|
// TOKEN AST STUFF
|
||||||
|
|
||||||
|
/** ID and output=AST */
|
||||||
|
tokenRef(token,label,elementIndex,terminalOptions) ::= <%
|
||||||
|
<super.tokenRef(...)>
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
<if(backtracking)><\n>if (state.backtracking == 0) {<endif>
|
||||||
|
<\n><label>_tree = <createNodeFromToken(...)>;
|
||||||
|
<\n>adaptor.AddChild(root_0, <label>_tree);
|
||||||
|
<if(backtracking)><\n>}<endif>
|
||||||
|
<endif>
|
||||||
|
%>
|
||||||
|
|
||||||
|
/** ID! and output=AST (same as plain tokenRef) */
|
||||||
|
tokenRefBang(token,label,elementIndex,terminalOptions) ::= "<super.tokenRef(...)>"
|
||||||
|
|
||||||
|
/** ID^ and output=AST */
|
||||||
|
tokenRefRuleRoot(token,label,elementIndex,terminalOptions) ::= <%
|
||||||
|
<super.tokenRef(...)>
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
<if(backtracking)><\n>if (<actions.(actionScope).synpredgate>) {<endif>
|
||||||
|
<\n><label>_tree = <createNodeFromToken(...)>;
|
||||||
|
<\n>root_0 = (<ASTLabelType>)adaptor.BecomeRoot(<label>_tree, root_0);
|
||||||
|
<if(backtracking)><\n>}<endif>
|
||||||
|
<endif>
|
||||||
|
%>
|
||||||
|
|
||||||
|
/** ids+=ID! and output=AST */
|
||||||
|
tokenRefBangAndListLabel(token,label,elementIndex,terminalOptions) ::= <<
|
||||||
|
<tokenRefBang(...)>
|
||||||
|
<listLabelElem(elem=label,elemType=labelType,...)>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** label+=TOKEN when output=AST but not rewrite alt */
|
||||||
|
tokenRefAndListLabel(token,label,elementIndex,terminalOptions) ::= <<
|
||||||
|
<tokenRef(...)>
|
||||||
|
<listLabelElem(elem=label,elemType=labelType,...)>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** Match label+=TOKEN^ when output=AST but not rewrite alt */
|
||||||
|
tokenRefRuleRootAndListLabel(token,label,terminalOptions,elementIndex) ::= <<
|
||||||
|
<tokenRefRuleRoot(...)>
|
||||||
|
<listLabelElem(elem=label,elemType=labelType,...)>
|
||||||
|
>>
|
||||||
|
|
||||||
|
// SET AST
|
||||||
|
|
||||||
|
// the match set stuff is interesting in that it uses an argument list
|
||||||
|
// to pass code to the default matchSet; another possible way to alter
|
||||||
|
// inherited code. I don't use the region stuff because I need to pass
|
||||||
|
// different chunks depending on the operator. I don't like making
|
||||||
|
// the template name have the operator as the number of templates gets
|
||||||
|
// large but this is the most flexible--this is as opposed to having
|
||||||
|
// the code generator call matchSet then add root code or ruleroot code
|
||||||
|
// plus list label plus ... The combinations might require complicated
|
||||||
|
// rather than just added on code. Investigate that refactoring when
|
||||||
|
// I have more time.
|
||||||
|
|
||||||
|
matchSet(s,label,terminalOptions,elementIndex,postmatchCode) ::= <<
|
||||||
|
<super.matchSet(postmatchCode={<if(!ruleDescriptor.isSynPred)><if(backtracking)>if (<actions.(actionScope).synpredgate>) <endif>adaptor.AddChild(root_0, <createNodeFromToken(...)>);<endif>}, ...)>
|
||||||
|
>>
|
||||||
|
|
||||||
|
matchRuleBlockSet(s,label,terminalOptions,elementIndex,postmatchCode,treeLevel="0") ::= <<
|
||||||
|
<matchSet(...)>
|
||||||
|
>>
|
||||||
|
|
||||||
|
matchSetBang(s,label,elementIndex,terminalOptions,postmatchCode) ::= "<super.matchSet(...)>"
|
||||||
|
|
||||||
|
// note there is no matchSetTrack because -> rewrites force sets to be
|
||||||
|
// plain old blocks of alts: (A|B|...|C)
|
||||||
|
|
||||||
|
matchSetRuleRoot(s,label,terminalOptions,elementIndex,debug) ::= <<
|
||||||
|
<if(label)>
|
||||||
|
<label>=(<labelType>)input.LT(1);
|
||||||
|
<endif>
|
||||||
|
<super.matchSet(postmatchCode={<if(!ruleDescriptor.isSynPred)><if(backtracking)>if (<actions.(actionScope).synpredgate>) <endif>root_0 = (<ASTLabelType>)adaptor.BecomeRoot(<createNodeFromToken(...)>, root_0);<endif>}, ...)>
|
||||||
|
>>
|
||||||
|
|
||||||
|
// RULE REF AST
|
||||||
|
|
||||||
|
/** rule when output=AST */
|
||||||
|
ruleRef(rule,label,elementIndex,args,scope) ::= <%
|
||||||
|
<super.ruleRef(...)>
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
<\n><if(backtracking)>if (<actions.(actionScope).synpredgate>) <endif>adaptor.AddChild(root_0, <label>.Tree);
|
||||||
|
<endif>
|
||||||
|
%>
|
||||||
|
|
||||||
|
/** rule! is same as normal rule ref */
|
||||||
|
ruleRefBang(rule,label,elementIndex,args,scope) ::= "<super.ruleRef(...)>"
|
||||||
|
|
||||||
|
/** rule^ */
|
||||||
|
ruleRefRuleRoot(rule,label,elementIndex,args,scope) ::= <<
|
||||||
|
<super.ruleRef(...)>
|
||||||
|
<if(backtracking)>if (<actions.(actionScope).synpredgate>) <endif>root_0 = (<ASTLabelType>)adaptor.BecomeRoot(<label>.Tree, root_0);
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** x+=rule when output=AST */
|
||||||
|
ruleRefAndListLabel(rule,label,elementIndex,args,scope) ::= <<
|
||||||
|
<ruleRef(...)>
|
||||||
|
<listLabelElem(elem={<label>.Tree},elemType=ASTLabelType,...)>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** x+=rule! when output=AST is a rule ref with list addition */
|
||||||
|
ruleRefBangAndListLabel(rule,label,elementIndex,args,scope) ::= <<
|
||||||
|
<ruleRefBang(...)>
|
||||||
|
<listLabelElem(elem={<label>.Tree},elemType=ASTLabelType,...)>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** x+=rule^ */
|
||||||
|
ruleRefRuleRootAndListLabel(rule,label,elementIndex,args,scope) ::= <<
|
||||||
|
<ruleRefRuleRoot(...)>
|
||||||
|
<listLabelElem(elem={<label>.Tree},elemType=ASTLabelType,...)>
|
||||||
|
>>
|
||||||
|
|
||||||
|
// WILDCARD AST
|
||||||
|
|
||||||
|
wildcard(token,label,elementIndex,terminalOptions) ::= <<
|
||||||
|
<super.wildcard(...)>
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
<if(backtracking)>if (<actions.(actionScope).synpredgate>) {<endif>
|
||||||
|
<label>_tree = (<ASTLabelType>)adaptor.Create(<label>);
|
||||||
|
adaptor.AddChild(root_0, <label>_tree);
|
||||||
|
<if(backtracking)>}<endif>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
wildcardBang(label,elementIndex) ::= "<super.wildcard(...)>"
|
||||||
|
|
||||||
|
wildcardRuleRoot(token,label,elementIndex,terminalOptions) ::= <<
|
||||||
|
<super.wildcard(...)>
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
<if(backtracking)>if (<actions.(actionScope).synpredgate>) {<endif>
|
||||||
|
<label>_tree = (<ASTLabelType>)adaptor.Create(<label>);
|
||||||
|
root_0 = (<ASTLabelType>)adaptor.BecomeRoot(<label>_tree, root_0);
|
||||||
|
<if(backtracking)>}<endif>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
createNodeFromToken(label,terminalOptions) ::= <%
|
||||||
|
<if(terminalOptions.node)>
|
||||||
|
new <terminalOptions.node>(<if(terminalOptions.type)><terminalOptions.type>,<endif><label><if(terminalOptions.text)>,<terminalOptions.text; format="string"><endif>)
|
||||||
|
<else>
|
||||||
|
(<ASTLabelType>)adaptor.Create(<if(terminalOptions.type)><terminalOptions.type>,<endif><label><if(terminalOptions.text)>,<terminalOptions.text; format="string"><endif>)
|
||||||
|
<endif>
|
||||||
|
%>
|
||||||
|
|
||||||
|
ruleCleanUp() ::= <<
|
||||||
|
<super.ruleCleanUp()>
|
||||||
|
<if(backtracking)>if (<actions.(actionScope).synpredgate>) {<endif>
|
||||||
|
retval.Tree = (<ASTLabelType>)adaptor.RulePostProcessing(root_0);
|
||||||
|
adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);
|
||||||
|
<if(backtracking)>}<endif>
|
||||||
|
>>
|
||||||
377
packages/Antlr34.3.4.19004.1/tools/Codegen/Templates/CSharp3/ASTTreeParser.stg
vendored
Normal file
377
packages/Antlr34.3.4.19004.1/tools/Codegen/Templates/CSharp3/ASTTreeParser.stg
vendored
Normal file
@@ -0,0 +1,377 @@
|
|||||||
|
/*
|
||||||
|
* [The "BSD license"]
|
||||||
|
* Copyright (c) 2011 Terence Parr
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Conversion to C#:
|
||||||
|
* Copyright (c) 2011 Sam Harwell, Pixel Mine, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** Templates for building ASTs during tree parsing.
|
||||||
|
*
|
||||||
|
* Deal with many combinations. Dimensions are:
|
||||||
|
* Auto build or rewrite
|
||||||
|
* no label, label, list label (label/no-label handled together)
|
||||||
|
* child, root
|
||||||
|
* token, set, rule, wildcard
|
||||||
|
*
|
||||||
|
* Each combination has its own template except that label/no label
|
||||||
|
* is combined into tokenRef, ruleRef, ...
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** Add a variable to track last element matched */
|
||||||
|
ruleDeclarations() ::= <<
|
||||||
|
<super.ruleDeclarations()>
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
<ASTLabelType> _first_0 = default(<ASTLabelType>);
|
||||||
|
<ASTLabelType> _last = default(<ASTLabelType>);
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** What to emit when there is no rewrite rule. For auto build
|
||||||
|
* mode, does nothing.
|
||||||
|
*/
|
||||||
|
noRewrite(rewriteBlockLevel, treeLevel) ::= <<
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
<if(backtracking)>if (<actions.(actionScope).synpredgate>) {<endif>
|
||||||
|
<if(rewriteMode)>
|
||||||
|
retval.Tree = (<ASTLabelType>)_first_0;
|
||||||
|
if (adaptor.GetParent(retval.Tree)!=null && adaptor.IsNil(adaptor.GetParent(retval.Tree)))
|
||||||
|
retval.Tree = (<ASTLabelType>)adaptor.GetParent(retval.Tree);
|
||||||
|
<endif>
|
||||||
|
<if(backtracking)>}<endif>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** match ^(root children) in tree parser; override here to
|
||||||
|
* add tree construction actions.
|
||||||
|
*/
|
||||||
|
tree(root, actionsAfterRoot, children, nullableChildList,
|
||||||
|
enclosingTreeLevel, treeLevel) ::= <<
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
_last = (<ASTLabelType>)input.LT(1);
|
||||||
|
{
|
||||||
|
<ASTLabelType> _save_last_<treeLevel> = _last;
|
||||||
|
<ASTLabelType> _first_<treeLevel> = default(<ASTLabelType>);
|
||||||
|
<if(!rewriteMode)>
|
||||||
|
<ASTLabelType> root_<treeLevel> = (<ASTLabelType>)adaptor.Nil();
|
||||||
|
<endif>
|
||||||
|
<root:element()>
|
||||||
|
<if(rewriteMode)>
|
||||||
|
<if(backtracking)>if (<actions.(actionScope).synpredgate>)<endif>
|
||||||
|
<if(root.el.rule)>
|
||||||
|
if (_first_<enclosingTreeLevel> == null) _first_<enclosingTreeLevel> = <root.el.label>.Tree;
|
||||||
|
<else>
|
||||||
|
if (_first_<enclosingTreeLevel> == null) _first_<enclosingTreeLevel> = <root.el.label>;
|
||||||
|
<endif>
|
||||||
|
<endif>
|
||||||
|
<actionsAfterRoot:element()>
|
||||||
|
<if(nullableChildList)>
|
||||||
|
if (input.LA(1) == TokenTypes.Down) {
|
||||||
|
Match(input, TokenTypes.Down, null); <checkRuleBacktrackFailure()>
|
||||||
|
<children:element()>
|
||||||
|
Match(input, TokenTypes.Up, null); <checkRuleBacktrackFailure()>
|
||||||
|
}
|
||||||
|
<else>
|
||||||
|
Match(input, TokenTypes.Down, null); <checkRuleBacktrackFailure()>
|
||||||
|
<children:element()>
|
||||||
|
Match(input, TokenTypes.Up, null); <checkRuleBacktrackFailure()>
|
||||||
|
<endif>
|
||||||
|
<if(!rewriteMode)>
|
||||||
|
adaptor.AddChild(root_<enclosingTreeLevel>, root_<treeLevel>);
|
||||||
|
<endif>
|
||||||
|
_last = _save_last_<treeLevel>;
|
||||||
|
}
|
||||||
|
<else>
|
||||||
|
<super.tree(...)>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
// TOKEN AST STUFF
|
||||||
|
|
||||||
|
/** ID! and output=AST (same as plain tokenRef) 'cept add
|
||||||
|
* setting of _last
|
||||||
|
*/
|
||||||
|
tokenRefBang(token,label,elementIndex,terminalOptions) ::= <<
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
_last = (<ASTLabelType>)input.LT(1);
|
||||||
|
<super.tokenRef(...)>
|
||||||
|
<else>
|
||||||
|
<super.tokenRefBang(...)>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** ID auto construct */
|
||||||
|
tokenRef(token,label,elementIndex,terminalOptions) ::= <<
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
_last = (<ASTLabelType>)input.LT(1);
|
||||||
|
<super.tokenRef(...)>
|
||||||
|
<if(!rewriteMode)>
|
||||||
|
<if(backtracking)>if (<actions.(actionScope).synpredgate>) {<endif>
|
||||||
|
<if(terminalOptions.node)>
|
||||||
|
<label>_tree = new <terminalOptions.node>(<if(terminalOptions.type)><terminalOptions.type>,<endif><label><if(terminalOptions.text)>,<terminalOptions.text; format="string"><endif>);
|
||||||
|
<else>
|
||||||
|
<label>_tree = (<ASTLabelType>)adaptor.DupNode(<if(terminalOptions.type)><terminalOptions.type>,<endif><label><if(terminalOptions.text)>,<terminalOptions.text; format="string"><endif>);
|
||||||
|
<endif><\n>
|
||||||
|
adaptor.AddChild(root_<treeLevel>, <label>_tree);
|
||||||
|
<if(backtracking)>}<endif>
|
||||||
|
<else> <! rewrite mode !>
|
||||||
|
<if(backtracking)>if (<actions.(actionScope).synpredgate>)<endif>
|
||||||
|
if (_first_<treeLevel> == null) _first_<treeLevel> = <label>;
|
||||||
|
<endif>
|
||||||
|
<else>
|
||||||
|
<super.tokenRef(...)>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** label+=TOKEN auto construct */
|
||||||
|
tokenRefAndListLabel(token,label,elementIndex,terminalOptions) ::= <<
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
<tokenRef(...)>
|
||||||
|
<listLabelElem(elem=label,...)>
|
||||||
|
<else>
|
||||||
|
<super.tokenRefAndListLabel(...)>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** ^(ID ...) auto construct */
|
||||||
|
tokenRefRuleRoot(token,label,elementIndex,terminalOptions) ::= <<
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
_last = (<ASTLabelType>)input.LT(1);
|
||||||
|
<super.tokenRef(...)>
|
||||||
|
<if(!rewriteMode)>
|
||||||
|
<if(backtracking)>if (<actions.(actionScope).synpredgate>) {<endif>
|
||||||
|
<if(terminalOptions.node)>
|
||||||
|
<label>_tree = new <terminalOptions.node>(<if(terminalOptions.type)><terminalOptions.type>,<endif><label><if(terminalOptions.text)>,<terminalOptions.text; format="string"><endif>);
|
||||||
|
<else>
|
||||||
|
<label>_tree = (<ASTLabelType>)adaptor.DupNode(<if(terminalOptions.type)><terminalOptions.type>,<endif><label><if(terminalOptions.text)>,<terminalOptions.text; format="string"><endif>);
|
||||||
|
<endif><\n>
|
||||||
|
root_<treeLevel> = (<ASTLabelType>)adaptor.BecomeRoot(<label>_tree, root_<treeLevel>);
|
||||||
|
<if(backtracking)>}<endif>
|
||||||
|
<endif>
|
||||||
|
<else>
|
||||||
|
<super.tokenRefRuleRoot(...)>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** Match ^(label+=TOKEN ...) auto construct */
|
||||||
|
tokenRefRuleRootAndListLabel(token,label,elementIndex,terminalOptions) ::= <<
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
<tokenRefRuleRoot(...)>
|
||||||
|
<listLabelElem(elem=label,...)>
|
||||||
|
<else>
|
||||||
|
<super.tokenRefRuleRootAndListLabel(...)>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** Match . wildcard and auto dup the node/subtree */
|
||||||
|
wildcard(token,label,elementIndex,terminalOptions) ::= <<
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
_last = (<ASTLabelType>)input.LT(1);
|
||||||
|
<super.wildcard(...)>
|
||||||
|
<if(!rewriteMode)>
|
||||||
|
<if(backtracking)>if (<actions.(actionScope).synpredgate>) {<endif>
|
||||||
|
<label>_tree = (<ASTLabelType>)adaptor.DupTree(<label>);
|
||||||
|
adaptor.AddChild(root_<treeLevel>, <label>_tree);
|
||||||
|
<if(backtracking)>}<endif>
|
||||||
|
<else> <! rewrite mode !>
|
||||||
|
<if(backtracking)>if (<actions.(actionScope).synpredgate>)<endif>
|
||||||
|
if (_first_<treeLevel> == null) _first_<treeLevel> = <label>;
|
||||||
|
<endif>
|
||||||
|
<else>
|
||||||
|
<super.wildcard(...)>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
// SET AST
|
||||||
|
|
||||||
|
matchSet(s,label,terminalOptions,elementIndex,postmatchCode) ::= <<
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
_last = (<ASTLabelType>)input.LT(1);
|
||||||
|
<super.matchSet(postmatchCode={
|
||||||
|
<if(!rewriteMode)>
|
||||||
|
<if(backtracking)>if (<actions.(actionScope).synpredgate>) {<endif>
|
||||||
|
<if(terminalOptions.node)>
|
||||||
|
<label>_tree = new <terminalOptions.node>(<if(terminalOptions.type)><terminalOptions.type>,<endif><label><if(terminalOptions.text)>,<terminalOptions.text; format="string"><endif>);
|
||||||
|
<else>
|
||||||
|
<label>_tree = (<ASTLabelType>)adaptor.DupNode(<if(terminalOptions.type)><terminalOptions.type>,<endif><label><if(terminalOptions.text)>,<terminalOptions.text; format="string"><endif>);
|
||||||
|
<endif><\n>
|
||||||
|
adaptor.AddChild(root_<treeLevel>, <label>_tree);
|
||||||
|
<if(backtracking)>\}<endif>
|
||||||
|
<endif>
|
||||||
|
}, ...
|
||||||
|
)>
|
||||||
|
<else>
|
||||||
|
<super.matchSet(...)>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
matchRuleBlockSet(s,label,terminalOptions,elementIndex,postmatchCode,treeLevel="0") ::= <<
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
<matchSet(...)>
|
||||||
|
<noRewrite(...)> <! set return tree !>
|
||||||
|
<else>
|
||||||
|
<super.matchRuleBlockSet(...)>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
matchSetBang(s,label,terminalOptions,elementIndex,postmatchCode) ::= <<
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
_last = (<ASTLabelType>)input.LT(1);
|
||||||
|
<super.matchSet(...)>
|
||||||
|
<else>
|
||||||
|
<super.matchSetBang(...)>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
matchSetRuleRoot(s,label,terminalOptions,elementIndex,debug) ::= <<
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
<super.matchSet(postmatchCode={
|
||||||
|
<if(!rewriteMode)>
|
||||||
|
<if(backtracking)>if (<actions.(actionScope).synpredgate>) {<endif>
|
||||||
|
<if(terminalOptions.node)>
|
||||||
|
<label>_tree = new <terminalOptions.node>(<if(terminalOptions.type)><terminalOptions.type>,<endif><label><if(terminalOptions.text)>,<terminalOptions.text; format="string"><endif>);
|
||||||
|
<else>
|
||||||
|
<label>_tree = (<ASTLabelType>)adaptor.DupNode(<if(terminalOptions.type)><terminalOptions.type>,<endif><label><if(terminalOptions.text)>,<terminalOptions.text; format="string"><endif>);
|
||||||
|
<endif><\n>
|
||||||
|
root_<treeLevel> = (<ASTLabelType>)adaptor.BecomeRoot(<label>_tree, root_<treeLevel>);
|
||||||
|
<if(backtracking)>\}<endif>
|
||||||
|
<endif>
|
||||||
|
}, ...
|
||||||
|
)>
|
||||||
|
<else>
|
||||||
|
<super.matchSetRuleRoot(...)>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
// RULE REF AST
|
||||||
|
|
||||||
|
/** rule auto construct */
|
||||||
|
ruleRef(rule,label,elementIndex,args,scope) ::= <<
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
_last = (<ASTLabelType>)input.LT(1);
|
||||||
|
<super.ruleRef(...)>
|
||||||
|
<if(backtracking)>if (<actions.(actionScope).synpredgate>)<endif>
|
||||||
|
<if(!rewriteMode)>
|
||||||
|
adaptor.AddChild(root_<treeLevel>, <label>.Tree);
|
||||||
|
<else> <! rewrite mode !>
|
||||||
|
if (_first_<treeLevel> == null) _first_<treeLevel> = <label>.Tree;
|
||||||
|
<endif>
|
||||||
|
<else>
|
||||||
|
<super.ruleRef(...)>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** x+=rule auto construct */
|
||||||
|
ruleRefAndListLabel(rule,label,elementIndex,args,scope) ::= <<
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
<ruleRef(...)>
|
||||||
|
<listLabelElem(elem={<label>.Tree},...)>
|
||||||
|
<else>
|
||||||
|
<super.ruleRefAndListLabel(...)>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** ^(rule ...) auto construct */
|
||||||
|
ruleRefRuleRoot(rule,label,elementIndex,args,scope) ::= <<
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
_last = (<ASTLabelType>)input.LT(1);
|
||||||
|
<super.ruleRef(...)>
|
||||||
|
<if(!rewriteMode)>
|
||||||
|
<if(backtracking)>if (<actions.(actionScope).synpredgate>) <endif>root_<treeLevel> = (<ASTLabelType>)adaptor.BecomeRoot(<label>.Tree, root_<treeLevel>);
|
||||||
|
<endif>
|
||||||
|
<else>
|
||||||
|
<super.ruleRefRuleRoot(...)>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** ^(x+=rule ...) auto construct */
|
||||||
|
ruleRefRuleRootAndListLabel(rule,label,elementIndex,args,scope) ::= <<
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
<ruleRefRuleRoot(...)>
|
||||||
|
<listLabelElem(elem={<label>.Tree},...)>
|
||||||
|
<else>
|
||||||
|
<super.ruleRefRuleRootAndListLabel(...)>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** rule when output=AST and tracking for rewrite */
|
||||||
|
ruleRefTrack(rule,label,elementIndex,args,scope) ::= <<
|
||||||
|
_last = (<ASTLabelType>)input.LT(1);
|
||||||
|
<super.ruleRefTrack(...)>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** x+=rule when output=AST and tracking for rewrite */
|
||||||
|
ruleRefTrackAndListLabel(rule,label,elementIndex,args,scope) ::= <<
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
_last = (<ASTLabelType>)input.LT(1);
|
||||||
|
<super.ruleRefTrackAndListLabel(...)>
|
||||||
|
<else>
|
||||||
|
<super.ruleRefTrackAndListLabel(...)>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** ^(rule ...) rewrite */
|
||||||
|
ruleRefRuleRootTrack(rule,label,elementIndex,args,scope) ::= <<
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
_last = (<ASTLabelType>)input.LT(1);
|
||||||
|
<super.ruleRefRootTrack(...)>
|
||||||
|
<else>
|
||||||
|
<super.ruleRefRuleRootTrack(...)>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** ^(x+=rule ...) rewrite */
|
||||||
|
ruleRefRuleRootTrackAndListLabel(rule,label,elementIndex,args,scope) ::= <<
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
_last = (<ASTLabelType>)input.LT(1);
|
||||||
|
<super.ruleRefRuleRootTrackAndListLabel(...)>
|
||||||
|
<else>
|
||||||
|
<super.ruleRefRuleRootTrackAndListLabel(...)>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** Streams for token refs are tree nodes now; override to
|
||||||
|
* change NextToken to NextNode.
|
||||||
|
*/
|
||||||
|
createRewriteNodeFromElement(token,terminalOptions,args) ::= <%
|
||||||
|
<if(terminalOptions.node)>
|
||||||
|
new <terminalOptions.node>(<if(terminalOptions.type)><terminalOptions.type>,<endif>stream_<token>.NextNode())
|
||||||
|
<else>
|
||||||
|
stream_<token>.NextNode()
|
||||||
|
<endif>
|
||||||
|
%>
|
||||||
|
|
||||||
|
ruleCleanUp() ::= <<
|
||||||
|
<super.ruleCleanUp()>
|
||||||
|
<if(!ruleDescriptor.isSynPred)>
|
||||||
|
<if(!rewriteMode)>
|
||||||
|
<if(backtracking)>if (<actions.(actionScope).synpredgate>) {<endif>
|
||||||
|
retval.Tree = (<ASTLabelType>)adaptor.RulePostProcessing(root_0);
|
||||||
|
<if(backtracking)>}<endif>
|
||||||
|
<endif>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
1749
packages/Antlr34.3.4.19004.1/tools/Codegen/Templates/CSharp3/CSharp3.stg
vendored
Normal file
1749
packages/Antlr34.3.4.19004.1/tools/Codegen/Templates/CSharp3/CSharp3.stg
vendored
Normal file
File diff suppressed because it is too large
Load Diff
312
packages/Antlr34.3.4.19004.1/tools/Codegen/Templates/CSharp3/Dbg.stg
vendored
Normal file
312
packages/Antlr34.3.4.19004.1/tools/Codegen/Templates/CSharp3/Dbg.stg
vendored
Normal file
@@ -0,0 +1,312 @@
|
|||||||
|
/*
|
||||||
|
* [The "BSD license"]
|
||||||
|
* Copyright (c) 2005-2008 Terence Parr
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Conversion to C#:
|
||||||
|
* Copyright (c) 2008-2009 Sam Harwell, Pixel Mine, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
/** Template overrides to add debugging to normal Java output;
|
||||||
|
* If ASTs are built, then you'll also get ASTDbg.stg loaded.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@outputFile.imports() ::= <<
|
||||||
|
<@super.imports()>
|
||||||
|
using Antlr.Runtime.Debug;
|
||||||
|
using IOException = System.IO.IOException;
|
||||||
|
>>
|
||||||
|
|
||||||
|
@genericParser.members() ::= <<
|
||||||
|
<if(grammar.grammarIsRoot)>
|
||||||
|
public static readonly string[] ruleNames =
|
||||||
|
new string[]
|
||||||
|
{
|
||||||
|
"invalidRule", <grammar.allImportedRules:{rST | "<rST.name>"}; wrap="\n ", separator=", ">
|
||||||
|
};<\n>
|
||||||
|
<endif>
|
||||||
|
<if(grammar.grammarIsRoot)><! grammar imports other grammar(s) !>
|
||||||
|
int ruleLevel = 0;
|
||||||
|
public virtual int RuleLevel { get { return ruleLevel; } }
|
||||||
|
public virtual void IncRuleLevel() { ruleLevel++; }
|
||||||
|
public virtual void DecRuleLevel() { ruleLevel--; }
|
||||||
|
<if(profile)>
|
||||||
|
<ctorForProfilingRootGrammar()>
|
||||||
|
<else>
|
||||||
|
<ctorForRootGrammar()>
|
||||||
|
<endif>
|
||||||
|
<ctorForPredefinedListener()>
|
||||||
|
<else><! imported grammar !>
|
||||||
|
public int RuleLevel { get { return <grammar.delegators:{g| <g:delegateName()>}>.RuleLevel; } }
|
||||||
|
public void IncRuleLevel() { <grammar.delegators:{g| <g:delegateName()>}>.IncRuleLevel(); }
|
||||||
|
public void DecRuleLevel() { <grammar.delegators:{g| <g:delegateName()>}>.DecRuleLevel(); }
|
||||||
|
<ctorForDelegateGrammar()>
|
||||||
|
<endif>
|
||||||
|
<if(profile)>
|
||||||
|
public override bool AlreadyParsedRule( IIntStream input, int ruleIndex )
|
||||||
|
{
|
||||||
|
int stopIndex = GetRuleMemoization(ruleIndex, input.Index);
|
||||||
|
((Profiler)dbg).ExamineRuleMemoization(input, ruleIndex, stopIndex, <grammar.composite.rootGrammar.recognizerName>.ruleNames[ruleIndex]);
|
||||||
|
return base.AlreadyParsedRule(input, ruleIndex);
|
||||||
|
}<\n>
|
||||||
|
public override void Memoize( IIntStream input, int ruleIndex, int ruleStartIndex )
|
||||||
|
{
|
||||||
|
((Profiler)dbg).Memoize(input, ruleIndex, ruleStartIndex, <grammar.composite.rootGrammar.recognizerName>.ruleNames[ruleIndex]);
|
||||||
|
base.Memoize(input, ruleIndex, ruleStartIndex);
|
||||||
|
}<\n>
|
||||||
|
<endif>
|
||||||
|
protected virtual bool EvalPredicate( bool result, string predicate )
|
||||||
|
{
|
||||||
|
dbg.SemanticPredicate( result, predicate );
|
||||||
|
return result;
|
||||||
|
}<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
ctorForRootGrammar() ::= <<
|
||||||
|
<! bug: can't use <@super.members()> cut-n-paste instead !>
|
||||||
|
<! Same except we add port number and profile stuff if root grammar !>
|
||||||
|
<actions.(actionScope).ctorModifier; null="public"> <name>( <inputStreamType> input )
|
||||||
|
: this( input, DebugEventSocketProxy.DefaultDebuggerPort, new RecognizerSharedState() )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
<actions.(actionScope).ctorModifier; null="public"> <name>( <inputStreamType> input, int port, RecognizerSharedState state )
|
||||||
|
: base( input, state )
|
||||||
|
{
|
||||||
|
<createListenerAndHandshake()>
|
||||||
|
<grammar.directDelegates:{g|<g:delegateName()> = new <g.recognizerName>( input, dbg, this.state, this<grammar.delegators:{g|, <g:delegateName()>}> );}; separator="\n">
|
||||||
|
<parserCtorBody()>
|
||||||
|
<@finally()>
|
||||||
|
}<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
ctorForProfilingRootGrammar() ::= <<
|
||||||
|
<! bug: can't use <@super.members()> cut-n-paste instead !>
|
||||||
|
<actions.(actionScope).ctorModifier; null="public"> <name>( <inputStreamType> input )
|
||||||
|
: this( input, new Profiler(null), new RecognizerSharedState() )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
<actions.(actionScope).ctorModifier; null="public"> <name>( <inputStreamType> input, IDebugEventListener dbg, RecognizerSharedState state )
|
||||||
|
: base( input, dbg, state )
|
||||||
|
{
|
||||||
|
Profiler p = (Profiler)dbg;
|
||||||
|
p.setParser(this);
|
||||||
|
<grammar.directDelegates:
|
||||||
|
{g|<g:delegateName()> = new <g.recognizerName>( input, dbg, this.state, this<grammar.delegators:{g|, <g:delegateName()>}> );}; separator="\n">
|
||||||
|
<parserCtorBody()>
|
||||||
|
<@finally()>
|
||||||
|
}
|
||||||
|
<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** Basically we don't want to set any dbg listeners are root will have it. */
|
||||||
|
ctorForDelegateGrammar() ::= <<
|
||||||
|
<actions.(actionScope).ctorModifier; null="public"> <name>( <inputStreamType> input, IDebugEventListener dbg, RecognizerSharedState state<grammar.delegators:{g|, <g.recognizerName> <g:delegateName()>}> )
|
||||||
|
: base( input, dbg, state )
|
||||||
|
{
|
||||||
|
<grammar.directDelegates:
|
||||||
|
{g|<g:delegateName()> = new <g.recognizerName>( input, this, this.state<grammar.delegators:{g|, <g:delegateName()>}> );}; separator="\n">
|
||||||
|
<parserCtorBody()>
|
||||||
|
}<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
ctorForPredefinedListener() ::= <<
|
||||||
|
<actions.(actionScope).ctorModifier; null="public"> <name>( <inputStreamType> input, IDebugEventListener dbg )
|
||||||
|
<@superClassRef>: base( input, dbg, new RecognizerSharedState() )<@end>
|
||||||
|
{
|
||||||
|
<if(profile)>
|
||||||
|
Profiler p = (Profiler)dbg;
|
||||||
|
p.setParser(this);
|
||||||
|
<endif>
|
||||||
|
<grammar.directDelegates:{g|<g:delegateName()> = new <g.recognizerName>(input, dbg, this.state, this<grammar.delegators:{g|, <g:delegateName()>}>);}; separator="\n">
|
||||||
|
<parserCtorBody()>
|
||||||
|
<@finally()>
|
||||||
|
}<\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
createListenerAndHandshake() ::= <<
|
||||||
|
<if(TREE_PARSER)>
|
||||||
|
DebugEventSocketProxy proxy = new DebugEventSocketProxy( this, port, input.TreeAdaptor );<\n>
|
||||||
|
<else>
|
||||||
|
DebugEventSocketProxy proxy = new DebugEventSocketProxy( this, port, null );<\n>
|
||||||
|
<endif>
|
||||||
|
DebugListener = proxy;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
proxy.Handshake();
|
||||||
|
}
|
||||||
|
catch ( IOException ioe )
|
||||||
|
{
|
||||||
|
ReportError( ioe );
|
||||||
|
}
|
||||||
|
>>
|
||||||
|
|
||||||
|
@genericParser.superClassName() ::= "Debug<@super.superClassName()>"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Much of the following rules were merged into CSharp3.stg.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@rule.preamble() ::= <<
|
||||||
|
if (RuleLevel == 0)
|
||||||
|
DebugListener.Commence();
|
||||||
|
IncRuleLevel();
|
||||||
|
>>
|
||||||
|
//@rule.preamble() ::= <<
|
||||||
|
//try
|
||||||
|
//{
|
||||||
|
// dbg.EnterRule( GrammarFileName, "<ruleName>" );
|
||||||
|
// if ( RuleLevel == 0 )
|
||||||
|
// {
|
||||||
|
// dbg.Commence();
|
||||||
|
// }
|
||||||
|
// IncRuleLevel();
|
||||||
|
// dbg.Location( <ruleDescriptor.tree.line>, <ruleDescriptor.tree.charPositionInLine> );<\n>
|
||||||
|
//>>
|
||||||
|
|
||||||
|
@rule.postamble() ::= <<
|
||||||
|
DecRuleLevel();
|
||||||
|
if (RuleLevel == 0)
|
||||||
|
DebugListener.Terminate();
|
||||||
|
>>
|
||||||
|
//@rule.postamble() ::= <<
|
||||||
|
//dbg.Location(<ruleDescriptor.EORNode.line>, <ruleDescriptor.EORNode.charPositionInLine>);<\n>
|
||||||
|
//}
|
||||||
|
//finally
|
||||||
|
//{
|
||||||
|
// dbg.ExitRule( GrammarFileName, "<ruleName>" );
|
||||||
|
// DecRuleLevel();
|
||||||
|
// if ( RuleLevel == 0 )
|
||||||
|
// {
|
||||||
|
// dbg.Terminate();
|
||||||
|
// }
|
||||||
|
//}<\n>
|
||||||
|
//>>
|
||||||
|
|
||||||
|
//@insertSynpreds.start() ::= "dbg.BeginBacktrack( state.backtracking );"
|
||||||
|
//@insertSynpreds.stop() ::= "dbg.EndBacktrack( state.backtracking, success );"
|
||||||
|
|
||||||
|
// Common debug event triggers used by region overrides below
|
||||||
|
|
||||||
|
//enterSubRule() ::= <<
|
||||||
|
//try
|
||||||
|
//{
|
||||||
|
// dbg.EnterSubRule( <decisionNumber> );<\n>
|
||||||
|
//>>
|
||||||
|
|
||||||
|
//exitSubRule() ::= <<
|
||||||
|
//}
|
||||||
|
//finally
|
||||||
|
//{
|
||||||
|
// dbg.ExitSubRule( <decisionNumber> );
|
||||||
|
//}<\n>
|
||||||
|
//>>
|
||||||
|
|
||||||
|
//enterDecision() ::= <<
|
||||||
|
//try
|
||||||
|
//{
|
||||||
|
// dbg.EnterDecision( <decisionNumber> );<\n>
|
||||||
|
//>>
|
||||||
|
|
||||||
|
//exitDecision() ::= <<
|
||||||
|
//}
|
||||||
|
//finally
|
||||||
|
//{
|
||||||
|
// dbg.ExitDecision( <decisionNumber> );
|
||||||
|
//}<\n>
|
||||||
|
//>>
|
||||||
|
|
||||||
|
//enterAlt(n) ::= "dbg.EnterAlt( <n> );<\n>"
|
||||||
|
|
||||||
|
// Region overrides that tell various constructs to add debugging triggers
|
||||||
|
|
||||||
|
//@block.predecision() ::= "<enterSubRule()><enterDecision()>"
|
||||||
|
|
||||||
|
//@block.postdecision() ::= "<exitDecision()>"
|
||||||
|
|
||||||
|
//@block.postbranch() ::= "<exitSubRule()>"
|
||||||
|
|
||||||
|
//@ruleBlock.predecision() ::= "<enterDecision()>"
|
||||||
|
|
||||||
|
//@ruleBlock.postdecision() ::= "<exitDecision()>"
|
||||||
|
|
||||||
|
//@ruleBlockSingleAlt.prealt() ::= "<enterAlt(n=\"1\")>"
|
||||||
|
|
||||||
|
//@blockSingleAlt.prealt() ::= "<enterAlt(n=\"1\")>"
|
||||||
|
|
||||||
|
//@positiveClosureBlock.preloop() ::= "<enterSubRule()>"
|
||||||
|
|
||||||
|
//@positiveClosureBlock.postloop() ::= "<exitSubRule()>"
|
||||||
|
|
||||||
|
//@positiveClosureBlock.predecision() ::= "<enterDecision()>"
|
||||||
|
|
||||||
|
//@positiveClosureBlock.postdecision() ::= "<exitDecision()>"
|
||||||
|
|
||||||
|
//@positiveClosureBlock.earlyExitException() ::=
|
||||||
|
// "dbg.RecognitionException( eee<decisionNumber> );<\n>"
|
||||||
|
|
||||||
|
//@closureBlock.preloop() ::= "<enterSubRule()>"
|
||||||
|
|
||||||
|
//@closureBlock.postloop() ::= "<exitSubRule()>"
|
||||||
|
|
||||||
|
//@closureBlock.predecision() ::= "<enterDecision()>"
|
||||||
|
|
||||||
|
//@closureBlock.postdecision() ::= "<exitDecision()>"
|
||||||
|
|
||||||
|
//@altSwitchCase.prealt() ::= "<enterAlt(n=i)>"
|
||||||
|
|
||||||
|
//@element.prematch() ::=
|
||||||
|
// "dbg.Location( <it.line>, <it.pos> );"
|
||||||
|
|
||||||
|
//@matchSet.mismatchedSetException() ::=
|
||||||
|
// "dbg.RecognitionException( mse );"
|
||||||
|
|
||||||
|
//@dfaState.noViableAltException() ::= "dbg.RecognitionException( nvae );"
|
||||||
|
|
||||||
|
//@dfaStateSwitch.noViableAltException() ::= "dbg.RecognitionException( nvae );"
|
||||||
|
|
||||||
|
//dfaDecision(decisionNumber,description) ::= <<
|
||||||
|
//try
|
||||||
|
//{
|
||||||
|
// isCyclicDecision = true;
|
||||||
|
// <super.dfaDecision(...)>
|
||||||
|
//}
|
||||||
|
//catch ( NoViableAltException nvae )
|
||||||
|
//{
|
||||||
|
// dbg.RecognitionException( nvae );
|
||||||
|
// throw nvae;
|
||||||
|
//}
|
||||||
|
//>>
|
||||||
|
|
||||||
|
//@cyclicDFA.errorMethod() ::= <<
|
||||||
|
//public override void Error( NoViableAltException nvae )
|
||||||
|
//{
|
||||||
|
// ((DebugParser)recognizer).dbg.RecognitionException( nvae );
|
||||||
|
//}
|
||||||
|
//>>
|
||||||
|
|
||||||
|
/** Force predicate validation to trigger an event */
|
||||||
|
evalPredicate(pred,description) ::= <<
|
||||||
|
EvalPredicate(<pred>, "<description>")
|
||||||
|
>>
|
||||||
153
packages/Antlr34.3.4.19004.1/tools/Codegen/Templates/CSharp3/ST.stg
vendored
Normal file
153
packages/Antlr34.3.4.19004.1/tools/Codegen/Templates/CSharp3/ST.stg
vendored
Normal file
@@ -0,0 +1,153 @@
|
|||||||
|
/*
|
||||||
|
* [The "BSD license"]
|
||||||
|
* Copyright (c) 2011 Terence Parr
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Conversion to C#:
|
||||||
|
* Copyright (c) 2011 Sam Harwell, Pixel Mine, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
/** Template subgroup to add template rewrite output
|
||||||
|
* If debugging, then you'll also get STDbg.stg loaded.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@outputFile.imports() ::= <<
|
||||||
|
<@super.imports()>
|
||||||
|
using Antlr3.ST;
|
||||||
|
using Antlr3.ST.Language;
|
||||||
|
>>
|
||||||
|
|
||||||
|
@genericParser.members() ::= <<
|
||||||
|
<@super.members()>
|
||||||
|
private StringTemplateGroup _templateGroup = new StringTemplateGroup("<name>Templates", typeof(AngleBracketTemplateLexer) );
|
||||||
|
|
||||||
|
public StringTemplateGroup TemplateGroup
|
||||||
|
{
|
||||||
|
get { return _templateGroup; }
|
||||||
|
set { _templateGroup = value; }
|
||||||
|
}
|
||||||
|
>>
|
||||||
|
|
||||||
|
ruleReturnBaseType() ::= <%
|
||||||
|
Template<if(TREE_PARSER)>Tree<else>Parser<endif>RuleReturnScope\<StringTemplate, <labelType>>
|
||||||
|
%>
|
||||||
|
|
||||||
|
/** x+=rule when output=template */
|
||||||
|
ruleRefAndListLabel(rule,label,elementIndex,args,scope) ::= <<
|
||||||
|
<ruleRef(...)>
|
||||||
|
<listLabelElem(elem={<label>.Template},elemType="StringTemplate",...)>
|
||||||
|
>>
|
||||||
|
|
||||||
|
rewriteTemplate(alts) ::= <<
|
||||||
|
|
||||||
|
// TEMPLATE REWRITE
|
||||||
|
<if(backtracking)>
|
||||||
|
if (<actions.(actionScope).synpredgate>)
|
||||||
|
{
|
||||||
|
<alts:rewriteTemplateAlt(); separator="else ">
|
||||||
|
<if(rewriteMode)><replaceTextInLine()><endif>
|
||||||
|
}
|
||||||
|
<else>
|
||||||
|
<alts:rewriteTemplateAlt(); separator="else ">
|
||||||
|
<if(rewriteMode)><replaceTextInLine()><endif>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
replaceTextInLine() ::= <<
|
||||||
|
<if(TREE_PARSER)>
|
||||||
|
((TokenRewriteStream)input.TokenStream).Replace(
|
||||||
|
input.TreeAdaptor.GetTokenStartIndex(retval.Start),
|
||||||
|
input.TreeAdaptor.GetTokenStopIndex(retval.Start),
|
||||||
|
retval.Template);
|
||||||
|
<else>
|
||||||
|
((TokenRewriteStream)input).Replace(
|
||||||
|
retval.Start.TokenIndex,
|
||||||
|
input.LT(-1).TokenIndex,
|
||||||
|
retval.Template);
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
rewriteTemplateAlt(it) ::= <<
|
||||||
|
// <it.description>
|
||||||
|
<if(it.pred)>
|
||||||
|
if (<it.pred>)
|
||||||
|
{
|
||||||
|
retval.Template = <it.alt>;
|
||||||
|
}<\n>
|
||||||
|
<else>
|
||||||
|
{
|
||||||
|
retval.Template = <it.alt>;
|
||||||
|
}<\n>
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
rewriteEmptyTemplate(alts) ::= <<
|
||||||
|
null;
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** Invoke a template with a set of attribute name/value pairs.
|
||||||
|
* Set the value of the rule's template *after* having set
|
||||||
|
* the attributes because the rule's template might be used as
|
||||||
|
* an attribute to build a bigger template; you get a self-embedded
|
||||||
|
* template.
|
||||||
|
*/
|
||||||
|
rewriteExternalTemplate(name,args) ::= <%
|
||||||
|
TemplateGroup.GetInstanceOf("<name>"<optionalArguments(args)>)
|
||||||
|
%>
|
||||||
|
|
||||||
|
/** expr is a string expression that says what template to load */
|
||||||
|
rewriteIndirectTemplate(expr,args) ::= <%
|
||||||
|
TemplateGroup.GetInstanceOf(<expr><optionalArguments(args)>)
|
||||||
|
%>
|
||||||
|
|
||||||
|
/** Invoke an inline template with a set of attribute name/value pairs */
|
||||||
|
rewriteInlineTemplate(args, template) ::= <%
|
||||||
|
new StringTemplate(TemplateGroup, "<template>"<optionalArguments(args)>)
|
||||||
|
%>
|
||||||
|
|
||||||
|
optionalArguments(args) ::= <<
|
||||||
|
<if(args)>,
|
||||||
|
new Dictionary\<string, object>() { <args:optionalArgument(); separator=", "> }
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
optionalArgument(it) ::= <<
|
||||||
|
{"<it.name>", <it.value>}
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** plain -> {foo} action */
|
||||||
|
rewriteAction(action) ::= <<
|
||||||
|
<action>
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** An action has %st.attrName=expr; or %{st}.attrName=expr; */
|
||||||
|
actionSetAttribute(st,attrName,expr) ::= <<
|
||||||
|
(<st>).SetAttribute("<attrName>",<expr>);
|
||||||
|
>>
|
||||||
|
|
||||||
|
/** Translate %{stringExpr} */
|
||||||
|
actionStringConstructor(stringExpr) ::= <<
|
||||||
|
new StringTemplate(TemplateGroup,<stringExpr>)
|
||||||
|
>>
|
||||||
82
packages/Antlr34.3.4.19004.1/tools/Codegen/Templates/LeftRecursiveRules.stg
vendored
Normal file
82
packages/Antlr34.3.4.19004.1/tools/Codegen/Templates/LeftRecursiveRules.stg
vendored
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
/*
|
||||||
|
[The "BSD license"]
|
||||||
|
Copyright (c) 2010 Terence Parr
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions
|
||||||
|
are met:
|
||||||
|
1. Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
3. The name of the author may not be used to endorse or promote products
|
||||||
|
derived from this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** How to generate rules derived from left-recursive rules.
|
||||||
|
* These rely on recRuleDefArg(), recRuleAltPredicate(),
|
||||||
|
* recRuleArg(), recRuleSetResultAction(), recRuleSetReturnAction()
|
||||||
|
* templates in main language.stg
|
||||||
|
*/
|
||||||
|
group LeftRecursiveRules;
|
||||||
|
|
||||||
|
recRuleName(ruleName) ::= "<ruleName>_"
|
||||||
|
recPrimaryName(ruleName) ::= "<ruleName>_primary"
|
||||||
|
|
||||||
|
recRuleStart(ruleName, minPrec, userRetvals, userRetvalAssignments) ::= <<
|
||||||
|
<ruleName><if(userRetvals)> returns [<userRetvals>]<endif>
|
||||||
|
: <recRuleName(...)>[<minPrec>]
|
||||||
|
<if(userRetvals)>
|
||||||
|
{
|
||||||
|
<userRetvalAssignments; separator="\n">
|
||||||
|
}
|
||||||
|
<endif>
|
||||||
|
;
|
||||||
|
>>
|
||||||
|
|
||||||
|
recRule(ruleName, precArgDef, argName, alts, setResultAction, buildAST,
|
||||||
|
userRetvals, userRetvalAssignments) ::= <<
|
||||||
|
<recRuleName(...)>[<precArgDef>]<if(userRetvals)> returns [<userRetvals>]<endif>
|
||||||
|
: <recPrimaryName(...)>
|
||||||
|
<if(buildAST)>
|
||||||
|
{
|
||||||
|
<setResultAction>
|
||||||
|
}
|
||||||
|
<endif>
|
||||||
|
<if(userRetvals)>
|
||||||
|
{
|
||||||
|
<userRetvalAssignments; separator="\n">
|
||||||
|
}
|
||||||
|
<endif>
|
||||||
|
( options {backtrack=false;}
|
||||||
|
: ( options {backtrack=false;}
|
||||||
|
: <alts; separator="\n | ">
|
||||||
|
)
|
||||||
|
)*
|
||||||
|
;
|
||||||
|
>>
|
||||||
|
|
||||||
|
recPrimaryRule(ruleName, alts, userRetvals) ::= <<
|
||||||
|
<recPrimaryName(...)><if(userRetvals)> returns [<userRetvals>]<endif>
|
||||||
|
options {backtrack=true;}
|
||||||
|
: <alts; separator="\n | ">
|
||||||
|
;
|
||||||
|
>>
|
||||||
|
|
||||||
|
recRuleAlt(alt, pred) ::= "{<pred>}?=> <alt>"
|
||||||
|
|
||||||
|
recRuleRef(ruleName, arg) ::= "<recRuleName(...)>[<arg>]"
|
||||||
|
|
||||||
27
packages/Antlr34.3.4.19004.1/tools/LICENSE.txt
vendored
Normal file
27
packages/Antlr34.3.4.19004.1/tools/LICENSE.txt
vendored
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
[The "BSD license"]
|
||||||
|
Copyright (c) 2011 Terence Parr
|
||||||
|
C# Port (c) 2011 Sam Harwell, Tunnel Vision Laboratories, LLC
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions
|
||||||
|
are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
3. The name of the author may not be used to endorse or promote products
|
||||||
|
derived from this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
BIN
packages/Antlr34.3.4.19004.1/tools/Targets/Antlr3.Targets.CSharp2.dll
vendored
Normal file
BIN
packages/Antlr34.3.4.19004.1/tools/Targets/Antlr3.Targets.CSharp2.dll
vendored
Normal file
Binary file not shown.
BIN
packages/Antlr34.3.4.19004.1/tools/Targets/Antlr3.Targets.CSharp3.dll
vendored
Normal file
BIN
packages/Antlr34.3.4.19004.1/tools/Targets/Antlr3.Targets.CSharp3.dll
vendored
Normal file
Binary file not shown.
12
packages/Antlr34.3.4.19004.1/tools/Tool/Templates/depend.stg
vendored
Normal file
12
packages/Antlr34.3.4.19004.1/tools/Tool/Templates/depend.stg
vendored
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
/** templates used to generate make-compatible dependencies */
|
||||||
|
group depend;
|
||||||
|
|
||||||
|
/** Generate "f : x, y, z" dependencies for input
|
||||||
|
* dependencies and generated files. in and out
|
||||||
|
* are File objects. For example, you can say
|
||||||
|
* <f.canonicalPath>
|
||||||
|
*/
|
||||||
|
dependencies(grammarFileName,in,out) ::= <<
|
||||||
|
<if(in)><grammarFileName>: <in; separator=", "><endif>
|
||||||
|
<out:{f | <f> : <grammarFileName>}; separator="\n">
|
||||||
|
>>
|
||||||
73
packages/Antlr34.3.4.19004.1/tools/Tool/Templates/dot/dot.stg
vendored
Normal file
73
packages/Antlr34.3.4.19004.1/tools/Tool/Templates/dot/dot.stg
vendored
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
/*
|
||||||
|
* [The "BSD license"]
|
||||||
|
* Copyright (c) 2011 Terence Parr
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Conversion to C#:
|
||||||
|
* Copyright (c) 2011 Sam Harwell, Tunnel Vision Laboratories, LLC.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
dfa(decisionRanks,states,edges,rankdir,startState,useBox) ::= <<
|
||||||
|
digraph NFA {
|
||||||
|
<if(rankdir)>rankdir=<rankdir>;<endif>
|
||||||
|
<decisionRanks; separator="\n">
|
||||||
|
<states; separator="\n">
|
||||||
|
<edges; separator="\n">
|
||||||
|
}
|
||||||
|
>>
|
||||||
|
|
||||||
|
nfa(decisionRanks,states,edges,rankdir,startState) ::= <<
|
||||||
|
digraph NFA {
|
||||||
|
rankdir=LR;
|
||||||
|
<decisionRanks; separator="\n">
|
||||||
|
<states; separator="\n">
|
||||||
|
<edges; separator="\n">
|
||||||
|
}
|
||||||
|
>>
|
||||||
|
|
||||||
|
decision_rank(states) ::= <<
|
||||||
|
{rank=same; rankdir=TB; <states; separator="; ">}
|
||||||
|
>>
|
||||||
|
|
||||||
|
edge(src,target,label,arrowhead) ::= <<
|
||||||
|
<src> -> <target> [fontsize=11, fontname="Courier", arrowsize=.7, label = "<label>"<if(arrowhead)>, arrowhead = <arrowhead><endif>];
|
||||||
|
>>
|
||||||
|
|
||||||
|
action_edge(src,target,label,arrowhead) ::= <<
|
||||||
|
<src> -> <target> [fontsize=11, fontname="Courier", arrowsize=.7, label = "<label>"<if(arrowhead)>, arrowhead = <arrowhead><endif>];
|
||||||
|
>>
|
||||||
|
|
||||||
|
epsilon_edge(src,target,label,arrowhead) ::= <<
|
||||||
|
<src> -> <target> [fontname="Times-Italic", label = "e"];
|
||||||
|
>>
|
||||||
|
|
||||||
|
state(name,useBox) ::= <<
|
||||||
|
node [fontsize=11, shape = <if(useBox)>box<else>circle, fixedsize=true, width=.4<endif>]; <name>
|
||||||
|
>>
|
||||||
|
|
||||||
|
stopstate(name,useBox) ::= <<
|
||||||
|
node [fontsize=11, shape = <if(useBox)>polygon,sides=4,peripheries=2<else>doublecircle, fixedsize=true, width=.6<endif>]; <name>
|
||||||
|
>>
|
||||||
42
packages/Antlr34.3.4.19004.1/tools/Tool/Templates/messages/formats/antlr.stg
vendored
Normal file
42
packages/Antlr34.3.4.19004.1/tools/Tool/Templates/messages/formats/antlr.stg
vendored
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
[The "BSD license"]
|
||||||
|
Copyright (c) 2006 Kay Roepke
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions
|
||||||
|
are met:
|
||||||
|
1. Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
3. The name of the author may not be used to endorse or promote products
|
||||||
|
derived from this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
New style messages. This file contains the actual layout of the messages emitted by ANTLR.
|
||||||
|
The text itself is coming out of the languages/*stg files, according to the chosen locale.
|
||||||
|
This file contains the default format ANTLR uses.
|
||||||
|
*/
|
||||||
|
|
||||||
|
group antlr;
|
||||||
|
|
||||||
|
location(file, line, column) ::= "<file>:<line>:<column>:"
|
||||||
|
|
||||||
|
message(id, text) ::= "(<id>) <text>"
|
||||||
|
|
||||||
|
report(location, message, type) ::= "<type>(<message.id>): <location> <message.text>"
|
||||||
|
|
||||||
|
wantsSingleLineMessage() ::= "false"
|
||||||
42
packages/Antlr34.3.4.19004.1/tools/Tool/Templates/messages/formats/vs2005.stg
vendored
Normal file
42
packages/Antlr34.3.4.19004.1/tools/Tool/Templates/messages/formats/vs2005.stg
vendored
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
[The "BSD license"]
|
||||||
|
Copyright (c) 2006 Kay Roepke
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions
|
||||||
|
are met:
|
||||||
|
1. Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
3. The name of the author may not be used to endorse or promote products
|
||||||
|
derived from this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
New style messages. This file contains the actual layout of the messages emitted by ANTLR.
|
||||||
|
The text itself is coming out of the languages/*stg files, according to the chosen locale.
|
||||||
|
This file contains the default format ANTLR uses.
|
||||||
|
*/
|
||||||
|
|
||||||
|
group antlr;
|
||||||
|
|
||||||
|
location(file, line, column) ::= "<file>(<line>,<column>)"
|
||||||
|
|
||||||
|
message(id, text) ::= "error <id> : <text>"
|
||||||
|
|
||||||
|
report(location, message, type) ::= "<location> : <type> <message.id> : <message.text>"
|
||||||
|
|
||||||
|
wantsSingleLineMessage() ::= "true"
|
||||||
297
packages/Antlr34.3.4.19004.1/tools/Tool/Templates/messages/languages/en.stg
vendored
Normal file
297
packages/Antlr34.3.4.19004.1/tools/Tool/Templates/messages/languages/en.stg
vendored
Normal file
@@ -0,0 +1,297 @@
|
|||||||
|
/*
|
||||||
|
[The "BSD license"]
|
||||||
|
Copyright (c) 2010 Terence Parr
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions
|
||||||
|
are met:
|
||||||
|
1. Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
3. The name of the author may not be used to endorse or promote products
|
||||||
|
derived from this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
New style messages. This file only contains the messages in English, but no
|
||||||
|
information about which file, line, or column it occurred in.
|
||||||
|
The location and message ids are taken out of the formats directory.
|
||||||
|
Kay Roepke
|
||||||
|
*/
|
||||||
|
group en_US;
|
||||||
|
|
||||||
|
// TOOL ERRORS
|
||||||
|
// file errors
|
||||||
|
CANNOT_WRITE_FILE(arg,exception,stackTrace) ::= <<
|
||||||
|
cannot write file <arg>: <exception>
|
||||||
|
<stackTrace; separator="\n">
|
||||||
|
>>
|
||||||
|
CANNOT_CLOSE_FILE(arg,exception,stackTrace) ::= "cannot close file <arg>: <exception>"
|
||||||
|
CANNOT_FIND_TOKENS_FILE(arg) ::= "cannot find tokens file <arg>"
|
||||||
|
ERROR_READING_TOKENS_FILE(arg,exception,stackTrace) ::= <<
|
||||||
|
problem reading token vocabulary file <arg>: <exception>
|
||||||
|
<stackTrace; separator="\n">
|
||||||
|
>>
|
||||||
|
DIR_NOT_FOUND(arg,exception,stackTrace) ::= "directory not found: <arg>"
|
||||||
|
OUTPUT_DIR_IS_FILE(arg,exception,stackTrace) ::= "output directory is a file: <arg>"
|
||||||
|
CANNOT_OPEN_FILE(arg,exception,stackTrace) ::= "cannot find or open file: <arg><if(exception)>; reason: <exception><endif>"
|
||||||
|
CIRCULAR_DEPENDENCY() ::= "your grammars contain a circular dependency and cannot be sorted into a valid build order."
|
||||||
|
|
||||||
|
INTERNAL_ERROR(arg,arg2,exception,stackTrace) ::= <<
|
||||||
|
internal error: <arg> <arg2><if(exception)>: <exception><endif>
|
||||||
|
<stackTrace; separator="\n">
|
||||||
|
>>
|
||||||
|
INTERNAL_WARNING(arg) ::= "internal warning: <arg>"
|
||||||
|
ERROR_CREATING_ARTIFICIAL_RULE(arg,exception,stackTrace) ::= <<
|
||||||
|
problems creating lexer rule listing all tokens: <exception>
|
||||||
|
<stackTrace; separator="\n">
|
||||||
|
>>
|
||||||
|
TOKENS_FILE_SYNTAX_ERROR(arg,arg2) ::=
|
||||||
|
"problems parsing token vocabulary file <arg> on line <arg2>"
|
||||||
|
CANNOT_GEN_DOT_FILE(arg,exception,stackTrace) ::=
|
||||||
|
"cannot write DFA DOT file <arg>: <exception>"
|
||||||
|
BAD_ACTION_AST_STRUCTURE(exception,stackTrace) ::=
|
||||||
|
"bad internal tree structure for action '<arg>': <exception>"
|
||||||
|
BAD_AST_STRUCTURE(arg,exception,stackTrace) ::= <<
|
||||||
|
bad internal tree structure '<arg>': <exception>
|
||||||
|
<stackTrace; separator="\n">
|
||||||
|
>>
|
||||||
|
FILE_AND_GRAMMAR_NAME_DIFFER(arg,arg2) ::=
|
||||||
|
"file <arg2> contains grammar <arg>; names must be identical"
|
||||||
|
FILENAME_EXTENSION_ERROR(arg) ::=
|
||||||
|
"file <arg> must end in a file extension, normally .g"
|
||||||
|
|
||||||
|
// code gen errors
|
||||||
|
MISSING_CODE_GEN_TEMPLATES(arg) ::=
|
||||||
|
"cannot find code generation templates <arg>.stg"
|
||||||
|
MISSING_CYCLIC_DFA_CODE_GEN_TEMPLATES() ::=
|
||||||
|
"cannot find code generation cyclic DFA templates for language <arg>"
|
||||||
|
CODE_GEN_TEMPLATES_INCOMPLETE(arg) ::=
|
||||||
|
"at least one code generation template missing for language <arg>"
|
||||||
|
CANNOT_CREATE_TARGET_GENERATOR(arg,exception,stackTrace) ::=
|
||||||
|
"cannot create target <arg> code generator: <exception>"
|
||||||
|
CANNOT_COMPUTE_SAMPLE_INPUT_SEQ() ::=
|
||||||
|
"cannot generate a sample input sequence from lookahead DFA"
|
||||||
|
|
||||||
|
// grammar interpretation errors
|
||||||
|
/*
|
||||||
|
NO_VIABLE_DFA_ALT(arg,arg2) ::=
|
||||||
|
"no viable transition from state <arg> on <arg2> while interpreting DFA"
|
||||||
|
*/
|
||||||
|
|
||||||
|
// GRAMMAR ERRORS
|
||||||
|
SYNTAX_ERROR(arg) ::= "syntax error: <arg>"
|
||||||
|
RULE_REDEFINITION(arg) ::=
|
||||||
|
"rule <arg> redefinition"
|
||||||
|
LEXER_RULES_NOT_ALLOWED(arg) ::=
|
||||||
|
"lexer rule <arg> not allowed in parser"
|
||||||
|
PARSER_RULES_NOT_ALLOWED(arg) ::=
|
||||||
|
"parser rule <arg> not allowed in lexer"
|
||||||
|
CANNOT_FIND_ATTRIBUTE_NAME_IN_DECL(arg) ::=
|
||||||
|
"cannot find an attribute name in attribute declaration"
|
||||||
|
NO_TOKEN_DEFINITION(arg) ::=
|
||||||
|
"no lexer rule corresponding to token: <arg>"
|
||||||
|
UNDEFINED_RULE_REF(arg) ::=
|
||||||
|
"reference to undefined rule: <arg>"
|
||||||
|
LITERAL_NOT_ASSOCIATED_WITH_LEXER_RULE(arg) ::=
|
||||||
|
"literal has no associated lexer rule: <arg>"
|
||||||
|
CANNOT_ALIAS_TOKENS_IN_LEXER(arg) ::=
|
||||||
|
"literals are illegal in lexer tokens{} section: <arg>"
|
||||||
|
ATTRIBUTE_REF_NOT_IN_RULE(arg,arg2) ::=
|
||||||
|
"reference to attribute outside of a rule: <arg><if(arg2)>.<arg2><endif>"
|
||||||
|
UNKNOWN_ATTRIBUTE_IN_SCOPE(arg,arg2) ::=
|
||||||
|
"unknown attribute for <arg>: <arg2>"
|
||||||
|
UNKNOWN_RULE_ATTRIBUTE(arg,arg2) ::=
|
||||||
|
"unknown attribute for rule <arg>: <arg2>"
|
||||||
|
UNKNOWN_SIMPLE_ATTRIBUTE(arg,args2) ::=
|
||||||
|
"attribute is not a token, parameter, or return value: <arg>"
|
||||||
|
ISOLATED_RULE_SCOPE(arg) ::=
|
||||||
|
"missing attribute access on rule scope: <arg>"
|
||||||
|
INVALID_RULE_PARAMETER_REF(arg,arg2) ::=
|
||||||
|
"cannot access rule <arg>'s parameter: <arg2>"
|
||||||
|
INVALID_RULE_SCOPE_ATTRIBUTE_REF(arg,arg2) ::=
|
||||||
|
"cannot access rule <arg>'s dynamically-scoped attribute: <arg2>"
|
||||||
|
SYMBOL_CONFLICTS_WITH_GLOBAL_SCOPE(arg) ::=
|
||||||
|
"symbol <arg> conflicts with global dynamic scope with same name"
|
||||||
|
WRITE_TO_READONLY_ATTR(arg,arg2,arg3) ::=
|
||||||
|
"cannot write to read only attribute: $<arg><if(arg2)>.<arg2><endif>"
|
||||||
|
LABEL_CONFLICTS_WITH_RULE(arg) ::=
|
||||||
|
"label <arg> conflicts with rule with same name"
|
||||||
|
LABEL_CONFLICTS_WITH_TOKEN(arg) ::=
|
||||||
|
"label <arg> conflicts with token with same name"
|
||||||
|
LABEL_CONFLICTS_WITH_RULE_SCOPE_ATTRIBUTE(arg,arg2) ::=
|
||||||
|
"label <arg> conflicts with rule <arg2>'s dynamically-scoped attribute with same name"
|
||||||
|
LABEL_CONFLICTS_WITH_RULE_ARG_RETVAL(arg,arg2) ::=
|
||||||
|
"label <arg> conflicts with rule <arg2>'s return value or parameter with same name"
|
||||||
|
ATTRIBUTE_CONFLICTS_WITH_RULE(arg,arg2) ::=
|
||||||
|
"rule <arg2>'s dynamically-scoped attribute <arg> conflicts with the rule name"
|
||||||
|
ATTRIBUTE_CONFLICTS_WITH_RULE_ARG_RETVAL(arg,arg2) ::=
|
||||||
|
"rule <arg2>'s dynamically-scoped attribute <arg> conflicts with<arg2>'s return value or parameter with same name"
|
||||||
|
LABEL_TYPE_CONFLICT(arg,arg2) ::=
|
||||||
|
"label <arg> type mismatch with previous definition: <arg2>"
|
||||||
|
ARG_RETVAL_CONFLICT(arg,arg2) ::=
|
||||||
|
"rule <arg2>'s argument <arg> conflicts a return value with same name"
|
||||||
|
NONUNIQUE_REF(arg) ::=
|
||||||
|
"<arg> is a non-unique reference"
|
||||||
|
FORWARD_ELEMENT_REF(arg) ::=
|
||||||
|
"illegal forward reference: <arg>"
|
||||||
|
MISSING_RULE_ARGS(arg) ::=
|
||||||
|
"missing parameter(s) on rule reference: <arg>"
|
||||||
|
RULE_HAS_NO_ARGS(arg) ::=
|
||||||
|
"rule <arg> has no defined parameters"
|
||||||
|
ARGS_ON_TOKEN_REF(arg) ::=
|
||||||
|
"token reference <arg> may not have parameters"
|
||||||
|
ILLEGAL_OPTION(arg) ::=
|
||||||
|
"illegal option <arg>"
|
||||||
|
LIST_LABEL_INVALID_UNLESS_RETVAL_STRUCT(arg) ::=
|
||||||
|
"rule '+=' list labels are not allowed w/o output option: <arg>"
|
||||||
|
UNDEFINED_TOKEN_REF_IN_REWRITE(arg) ::=
|
||||||
|
"reference to undefined token in rewrite rule: <arg>"
|
||||||
|
REWRITE_ELEMENT_NOT_PRESENT_ON_LHS(arg) ::=
|
||||||
|
"reference to rewrite element <arg> without reference on left of ->"
|
||||||
|
UNDEFINED_LABEL_REF_IN_REWRITE(arg) ::=
|
||||||
|
"reference to undefined label in rewrite rule: $<arg>"
|
||||||
|
NO_GRAMMAR_START_RULE (arg) ::=
|
||||||
|
"grammar <arg>: no start rule (no rule can obviously be followed by EOF)"
|
||||||
|
EMPTY_COMPLEMENT(arg) ::= <<
|
||||||
|
<if(arg)>
|
||||||
|
set complement ~<arg> is empty
|
||||||
|
<else>
|
||||||
|
set complement is empty
|
||||||
|
<endif>
|
||||||
|
>>
|
||||||
|
UNKNOWN_DYNAMIC_SCOPE(arg) ::=
|
||||||
|
"unknown dynamic scope: <arg>"
|
||||||
|
UNKNOWN_DYNAMIC_SCOPE_ATTRIBUTE(arg,arg2) ::=
|
||||||
|
"unknown dynamically-scoped attribute for scope <arg>: <arg2>"
|
||||||
|
RULE_REF_AMBIG_WITH_RULE_IN_ALT(arg) ::=
|
||||||
|
"reference $<arg> is ambiguous; rule <arg> is enclosing rule and referenced in the production (assuming enclosing rule)"
|
||||||
|
ISOLATED_RULE_ATTRIBUTE(arg) ::=
|
||||||
|
"reference to locally-defined rule scope attribute without rule name: <arg>"
|
||||||
|
INVALID_ACTION_SCOPE(arg,arg2) ::=
|
||||||
|
"unknown or invalid action scope for <arg2> grammar: <arg>"
|
||||||
|
ACTION_REDEFINITION(arg) ::=
|
||||||
|
"redefinition of <arg> action"
|
||||||
|
DOUBLE_QUOTES_ILLEGAL(arg) ::=
|
||||||
|
"string literals must use single quotes (such as \'begin\'): <arg>"
|
||||||
|
INVALID_TEMPLATE_ACTION(arg) ::=
|
||||||
|
"invalid StringTemplate % shorthand syntax: '<arg>'"
|
||||||
|
MISSING_ATTRIBUTE_NAME() ::=
|
||||||
|
"missing attribute name on $ reference"
|
||||||
|
ARG_INIT_VALUES_ILLEGAL(arg) ::=
|
||||||
|
"rule parameters may not have init values: <arg>"
|
||||||
|
REWRITE_OR_OP_WITH_NO_OUTPUT_OPTION(arg) ::=
|
||||||
|
"<if(arg)>rule <arg> uses <endif>rewrite syntax or operator with no output option; setting output=AST"
|
||||||
|
AST_OP_WITH_NON_AST_OUTPUT_OPTION(arg) ::=
|
||||||
|
"AST operator with non-AST output option: <arg>"
|
||||||
|
NO_RULES(arg) ::= "grammar file <arg> has no rules"
|
||||||
|
MISSING_AST_TYPE_IN_TREE_GRAMMAR(arg) ::=
|
||||||
|
"tree grammar <arg> has no ASTLabelType option"
|
||||||
|
REWRITE_FOR_MULTI_ELEMENT_ALT(arg) ::=
|
||||||
|
"with rewrite=true, alt <arg> not simple node or obvious tree element; text attribute for rule not guaranteed to be correct"
|
||||||
|
RULE_INVALID_SET(arg) ::=
|
||||||
|
"Cannot complement rule <arg>; not a simple set or element"
|
||||||
|
HETERO_ILLEGAL_IN_REWRITE_ALT(arg) ::=
|
||||||
|
"alts with rewrites can't use heterogeneous types left of ->"
|
||||||
|
NO_SUCH_GRAMMAR_SCOPE(arg,arg2) ::=
|
||||||
|
"reference to undefined grammar in rule reference: <arg>.<arg2>"
|
||||||
|
NO_SUCH_RULE_IN_SCOPE(arg,arg2) ::=
|
||||||
|
"rule <arg2> is not defined in grammar <arg>"
|
||||||
|
TOKEN_ALIAS_CONFLICT(arg,arg2) ::=
|
||||||
|
"cannot alias <arg>; string already assigned to <arg2>"
|
||||||
|
TOKEN_ALIAS_REASSIGNMENT(arg,arg2) ::=
|
||||||
|
"cannot alias <arg>; token name already assigned to <arg2>"
|
||||||
|
TOKEN_VOCAB_IN_DELEGATE(arg,arg2) ::=
|
||||||
|
"tokenVocab option ignored in imported grammar <arg>"
|
||||||
|
INVALID_IMPORT(arg,arg2) ::=
|
||||||
|
"<arg.grammarTypeString> grammar <arg.name> cannot import <arg2.grammarTypeString> grammar <arg2.name>"
|
||||||
|
IMPORTED_TOKENS_RULE_EMPTY(arg,arg2) ::=
|
||||||
|
"no lexer rules contributed to <arg> from imported grammar <arg2>"
|
||||||
|
IMPORT_NAME_CLASH(arg,arg2) ::=
|
||||||
|
"combined grammar <arg.name> and imported <arg2.grammarTypeString> grammar <arg2.name> both generate <arg2.recognizerName>; import ignored"
|
||||||
|
AST_OP_IN_ALT_WITH_REWRITE(arg,arg2) ::=
|
||||||
|
"rule <arg> alt <arg2> uses rewrite syntax and also an AST operator"
|
||||||
|
WILDCARD_AS_ROOT(arg) ::= "Wildcard invalid as root; wildcard can itself be a tree"
|
||||||
|
CONFLICTING_OPTION_IN_TREE_FILTER(arg,arg2) ::= "option <arg>=<arg2> conflicts with tree grammar filter mode"
|
||||||
|
ILLEGAL_OPTION_VALUE(arg, arg2) ::= "value '<arg2>' invalid for option <arg>"
|
||||||
|
ALL_OPS_NEED_SAME_ASSOC(arg) ::= "all operators of alt <alt> of left-recursive rule must have same associativity"
|
||||||
|
|
||||||
|
// GRAMMAR WARNINGS
|
||||||
|
|
||||||
|
GRAMMAR_NONDETERMINISM(input,conflictingAlts,paths,disabled,hasPredicateBlockedByAction) ::=
|
||||||
|
<<
|
||||||
|
<if(paths)>
|
||||||
|
Decision can match input such as "<input>" using multiple alternatives:
|
||||||
|
<paths:{ it | alt <it.alt> via NFA path <it.states; separator=","><\n>}>
|
||||||
|
<else>
|
||||||
|
Decision can match input such as "<input>" using multiple alternatives: <conflictingAlts; separator=", ">
|
||||||
|
<endif>
|
||||||
|
<if(disabled)><\n>As a result, alternative(s) <disabled; separator=","> were disabled for that input<endif><if(hasPredicateBlockedByAction)><\n>Semantic predicates were present but were hidden by actions.<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
DANGLING_STATE(danglingAlts,input) ::= <<
|
||||||
|
the decision cannot distinguish between alternative(s) <danglingAlts; separator=","> for input such as "<input>"
|
||||||
|
>>
|
||||||
|
|
||||||
|
UNREACHABLE_ALTS(alts) ::= <<
|
||||||
|
The following alternatives can never be matched: <alts; separator=","><\n>
|
||||||
|
>>
|
||||||
|
|
||||||
|
INSUFFICIENT_PREDICATES(upon,altToLocations,hasPredicateBlockedByAction) ::= <<
|
||||||
|
Input such as "<upon>" is insufficiently covered with predicates at locations: <altToLocations.keys:{alt|alt <alt>: <altToLocations.(alt):{loc| line <loc.line>:<loc.column> at <loc.text>}; separator=", ">}; separator=", "><if(hasPredicateBlockedByAction)><\n>Semantic predicates were present but were hidden by actions.<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
DUPLICATE_SET_ENTRY(arg) ::=
|
||||||
|
"duplicate token type <arg> when collapsing subrule into set"
|
||||||
|
|
||||||
|
ANALYSIS_ABORTED(enclosingRule) ::= <<
|
||||||
|
ANTLR could not analyze this decision in rule <enclosingRule>; often this is because of recursive rule references visible from the left edge of alternatives. ANTLR will re-analyze the decision with a fixed lookahead of k=1. Consider using "options {k=1;}" for that decision and possibly adding a syntactic predicate.
|
||||||
|
>>
|
||||||
|
|
||||||
|
RECURSION_OVERLOW(alt,input,targetRules,callSiteStates) ::= <<
|
||||||
|
Alternative <alt>: after matching input such as <input> decision cannot predict what comes next due to recursion overflow <targetRules,callSiteStates:{t,c|to <t> from <c:{s|<s.enclosingRule.name>};separator=", ">}; separator=" and ">
|
||||||
|
>>
|
||||||
|
|
||||||
|
LEFT_RECURSION(targetRules,alt,callSiteStates) ::= <<
|
||||||
|
Alternative <alt> discovers infinite left-recursion <targetRules,callSiteStates:{t,c|to <t> from <c:{s|<s.enclosingRule>};separator=", ">}; separator=" and ">
|
||||||
|
>>
|
||||||
|
|
||||||
|
UNREACHABLE_TOKENS(tokens) ::= <<
|
||||||
|
The following token definitions can never be matched because prior tokens match the same input: <tokens; separator=",">
|
||||||
|
>>
|
||||||
|
|
||||||
|
TOKEN_NONDETERMINISM(input,conflictingTokens,paths,disabled,hasPredicateBlockedByAction) ::=
|
||||||
|
<<
|
||||||
|
<if(paths)>
|
||||||
|
Decision can match input such as "<input>" using multiple alternatives:
|
||||||
|
<paths:{ it | alt <it.alt> via NFA path <it.states; separator=","><\n>}>
|
||||||
|
<else>
|
||||||
|
Multiple token rules can match input such as "<input>": <conflictingTokens; separator=", "><\n>
|
||||||
|
<endif>
|
||||||
|
<if(disabled)><\n>As a result, token(s) <disabled; separator=","> were disabled for that input<endif><if(hasPredicateBlockedByAction)><\n>Semantic predicates were present but were hidden by actions.<endif>
|
||||||
|
>>
|
||||||
|
|
||||||
|
LEFT_RECURSION_CYCLES(listOfCycles) ::= <<
|
||||||
|
The following sets of rules are mutually left-recursive <listOfCycles:{c| [<c:{r|<r.name>}; separator=", ">]}; separator=" and ">
|
||||||
|
>>
|
||||||
|
|
||||||
|
NONREGULAR_DECISION(ruleName,alts) ::= <<
|
||||||
|
[fatal] rule <ruleName> has non-LL(*) decision due to recursive rule invocations reachable from alts <alts; separator=",">. Resolve by left-factoring or using syntactic predicates or using backtrack=true option.
|
||||||
|
>>
|
||||||
|
|
||||||
|
/* l10n for message levels */
|
||||||
|
warning() ::= "warning"
|
||||||
|
error() ::= "error"
|
||||||
Reference in New Issue
Block a user