1
0
mirror of https://github.com/twiglet/cs2j.git synced 2025-01-18 13:15:17 +01:00

Rename SignatureExtracter -> TemplateExtracter (will I ever make my mind up?)

This commit is contained in:
Kevin Glynn 2010-10-22 20:27:47 +02:00
parent 916eca5eac
commit 7f6eda7e9b
3 changed files with 74 additions and 69 deletions

View File

@ -1,64 +1,65 @@
// SignatureExtracter.g
//
// Crawler that extracts the signatures (typereptemplates) from a CSharp AST
//
// Kevin Glynn
// kevin.glynn@twigletsoftware.com
// June 2010
tree grammar SignatureExtracter;
options {
tokenVocab=cs;
ASTLabelType=CommonTree;
language=CSharp2;
superClass='RusticiSoftware.Translator.CSharp.CommonWalker';
//backtrack=true;
}
@namespace { RusticiSoftware.Translator.CSharp }
@header
{
using System.Text;
using RusticiSoftware.Translator.CLR;
}
@members
{
// As we scan the AST we collect these features until
// we reach the end, then calculate the TypeRep and insert it into
// the TypeEnv
private IList<PropRepTemplate> Properties = new List<PropRepTemplate>();
private IList<MethodRepTemplate> Methods = new List<MethodRepTemplate>();
private IList<ConstructorRepTemplate> Constructors = new List<ConstructorRepTemplate>();
private IList<FieldRepTemplate> Fields = new List<FieldRepTemplate>();
private IList<CastRepTemplate> Casts = new List<CastRepTemplate>();
}
/********************************************************************************************
Parser section
*********************************************************************************************/
///////////////////////////////////////////////////////
compilation_unit:
{ Debug("start"); } using_directives
;
using_directives:
^(USING_DIRECTIVE 'using' namespace_name ';' { Debug("using " + $namespace_name.namespaceText); })
;
namespace_name returns [string namespaceText]:
^(NAMESPACE_OR_TYPE_NAME nsc=namespace_component { namespaceText = $nsc.idText; }
(nscp=namespace_component { namespaceText = namespaceText + "." + $nscp.idText; } )* )
;
namespace_component returns [string idText]:
^(NSTN identifier { idText=$identifier.idText; } )
;
identifier returns [string idText]:
^(ID IDENTIFIER { idText = $IDENTIFIER.Text; Debug("Identifier: " + $IDENTIFIER.Text); } )
;
// SignatureExtracter.g
//
// Crawler that extracts the signatures (typereptemplates) from a CSharp AST
//
// Kevin Glynn
// kevin.glynn@twigletsoftware.com
// June 2010
tree grammar TemplateExtracter;
options {
tokenVocab=cs;
ASTLabelType=CommonTree;
language=CSharp2;
superClass='RusticiSoftware.Translator.CSharp.CommonWalker';
//backtrack=true;
}
@namespace { RusticiSoftware.Translator.CSharp }
@header
{
using System.Text;
using System.Collections.Generic;
using RusticiSoftware.Translator.CLR;
}
@members
{
// As we scan the AST we collect these features until
// we reach the end, then calculate the TypeRep and insert it into
// the TypeEnv
private IList<PropRepTemplate> Properties = new List<PropRepTemplate>();
private IList<MethodRepTemplate> Methods = new List<MethodRepTemplate>();
private IList<ConstructorRepTemplate> Constructors = new List<ConstructorRepTemplate>();
private IList<FieldRepTemplate> Fields = new List<FieldRepTemplate>();
private IList<CastRepTemplate> Casts = new List<CastRepTemplate>();
}
/********************************************************************************************
Parser section
*********************************************************************************************/
///////////////////////////////////////////////////////
compilation_unit:
{ Debug("start"); } using_directives
;
using_directives:
^(USING_DIRECTIVE 'using' namespace_name ';' { Debug("using " + $namespace_name.namespaceText); })
;
namespace_name returns [string namespaceText]:
^(NAMESPACE_OR_TYPE_NAME nsc=namespace_component { namespaceText = $nsc.idText; }
(nscp=namespace_component { namespaceText = namespaceText + "." + $nscp.idText; } )* )
;
namespace_component returns [string idText]:
^(NSTN identifier { idText=$identifier.idText; } )
;
identifier returns [string idText]:
^(ID IDENTIFIER { idText = $IDENTIFIER.Text; Debug("Identifier: " + $IDENTIFIER.Text); } )
;

View File

@ -50,9 +50,9 @@ namespace RusticiSoftware.Translator.CSharp
BufferedTreeNodeStream nodes = new BufferedTreeNodeStream(parse_tree);
SignatureExtracter sigWalker = new SignatureExtracter(nodes);
sigWalker.DebugLevel = 10;
sigWalker.compilation_unit();
TemplateExtracter templateWalker = new TemplateExtracter(nodes);
templateWalker.DebugLevel = 10;
templateWalker.compilation_unit();
}
}

View File

@ -61,16 +61,16 @@
<Compile Include="CSharp\minDriver.cs" />
<Compile Include="CSharp\PreProcessor.cs" />
<Compile Include="CLR\TranslationTemplate.cs" />
<Compile Include="CSharp\SignatureExtracter.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Utils\DirectoryHT.cs" />
<Compile Include="Utils\Constants.cs" />
<Compile Include="Utils\TypeHelper.cs" />
<Compile Include="CSharp\TemplateExtracter.cs" />
</ItemGroup>
<ItemGroup>
<None Include="CSharp\SignatureExtracter.g" />
<None Include="CSharp\csCrawl.g" />
<None Include="CSharp\cs.g" />
<None Include="CSharp\TemplateExtracter.g" />
</ItemGroup>
<ItemGroup>
<Content Include="README.txt" />
@ -102,6 +102,10 @@
<Project>{CF15D0D5-BE72-4F98-B70F-229ABA1DF0E8}</Project>
<Name>Antlr3.Runtime</Name>
</ProjectReference>
<ProjectReference Include="..\NDesk.Options\NDesk.Options.csproj">
<Project>{E6ACBB37-AF38-45E1-B399-0CEE63809A15}</Project>
<Name>NDesk.Options</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.