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:
parent
916eca5eac
commit
7f6eda7e9b
@ -1,64 +1,65 @@
|
|||||||
// SignatureExtracter.g
|
// SignatureExtracter.g
|
||||||
//
|
//
|
||||||
// Crawler that extracts the signatures (typereptemplates) from a CSharp AST
|
// Crawler that extracts the signatures (typereptemplates) from a CSharp AST
|
||||||
//
|
//
|
||||||
// Kevin Glynn
|
// Kevin Glynn
|
||||||
// kevin.glynn@twigletsoftware.com
|
// kevin.glynn@twigletsoftware.com
|
||||||
// June 2010
|
// June 2010
|
||||||
|
|
||||||
tree grammar SignatureExtracter;
|
tree grammar TemplateExtracter;
|
||||||
|
|
||||||
options {
|
options {
|
||||||
tokenVocab=cs;
|
tokenVocab=cs;
|
||||||
ASTLabelType=CommonTree;
|
ASTLabelType=CommonTree;
|
||||||
language=CSharp2;
|
language=CSharp2;
|
||||||
superClass='RusticiSoftware.Translator.CSharp.CommonWalker';
|
superClass='RusticiSoftware.Translator.CSharp.CommonWalker';
|
||||||
//backtrack=true;
|
//backtrack=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@namespace { RusticiSoftware.Translator.CSharp }
|
@namespace { RusticiSoftware.Translator.CSharp }
|
||||||
|
|
||||||
@header
|
@header
|
||||||
{
|
{
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using RusticiSoftware.Translator.CLR;
|
using System.Collections.Generic;
|
||||||
}
|
using RusticiSoftware.Translator.CLR;
|
||||||
|
}
|
||||||
@members
|
|
||||||
{
|
@members
|
||||||
// As we scan the AST we collect these features until
|
{
|
||||||
// we reach the end, then calculate the TypeRep and insert it into
|
// As we scan the AST we collect these features until
|
||||||
// the TypeEnv
|
// we reach the end, then calculate the TypeRep and insert it into
|
||||||
private IList<PropRepTemplate> Properties = new List<PropRepTemplate>();
|
// the TypeEnv
|
||||||
private IList<MethodRepTemplate> Methods = new List<MethodRepTemplate>();
|
private IList<PropRepTemplate> Properties = new List<PropRepTemplate>();
|
||||||
private IList<ConstructorRepTemplate> Constructors = new List<ConstructorRepTemplate>();
|
private IList<MethodRepTemplate> Methods = new List<MethodRepTemplate>();
|
||||||
private IList<FieldRepTemplate> Fields = new List<FieldRepTemplate>();
|
private IList<ConstructorRepTemplate> Constructors = new List<ConstructorRepTemplate>();
|
||||||
private IList<CastRepTemplate> Casts = new List<CastRepTemplate>();
|
private IList<FieldRepTemplate> Fields = new List<FieldRepTemplate>();
|
||||||
}
|
private IList<CastRepTemplate> Casts = new List<CastRepTemplate>();
|
||||||
|
}
|
||||||
/********************************************************************************************
|
|
||||||
Parser section
|
/********************************************************************************************
|
||||||
*********************************************************************************************/
|
Parser section
|
||||||
|
*********************************************************************************************/
|
||||||
///////////////////////////////////////////////////////
|
|
||||||
compilation_unit:
|
///////////////////////////////////////////////////////
|
||||||
{ Debug("start"); } using_directives
|
compilation_unit:
|
||||||
;
|
{ Debug("start"); } using_directives
|
||||||
|
;
|
||||||
using_directives:
|
|
||||||
^(USING_DIRECTIVE 'using' namespace_name ';' { Debug("using " + $namespace_name.namespaceText); })
|
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; }
|
namespace_name returns [string namespaceText]:
|
||||||
(nscp=namespace_component { namespaceText = namespaceText + "." + $nscp.idText; } )* )
|
^(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; } )
|
namespace_component returns [string idText]:
|
||||||
;
|
^(NSTN identifier { idText=$identifier.idText; } )
|
||||||
|
;
|
||||||
identifier returns [string idText]:
|
|
||||||
^(ID IDENTIFIER { idText = $IDENTIFIER.Text; Debug("Identifier: " + $IDENTIFIER.Text); } )
|
identifier returns [string idText]:
|
||||||
;
|
^(ID IDENTIFIER { idText = $IDENTIFIER.Text; Debug("Identifier: " + $IDENTIFIER.Text); } )
|
||||||
|
;
|
||||||
|
|
@ -50,9 +50,9 @@ namespace RusticiSoftware.Translator.CSharp
|
|||||||
BufferedTreeNodeStream nodes = new BufferedTreeNodeStream(parse_tree);
|
BufferedTreeNodeStream nodes = new BufferedTreeNodeStream(parse_tree);
|
||||||
|
|
||||||
|
|
||||||
SignatureExtracter sigWalker = new SignatureExtracter(nodes);
|
TemplateExtracter templateWalker = new TemplateExtracter(nodes);
|
||||||
sigWalker.DebugLevel = 10;
|
templateWalker.DebugLevel = 10;
|
||||||
sigWalker.compilation_unit();
|
templateWalker.compilation_unit();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,16 +61,16 @@
|
|||||||
<Compile Include="CSharp\minDriver.cs" />
|
<Compile Include="CSharp\minDriver.cs" />
|
||||||
<Compile Include="CSharp\PreProcessor.cs" />
|
<Compile Include="CSharp\PreProcessor.cs" />
|
||||||
<Compile Include="CLR\TranslationTemplate.cs" />
|
<Compile Include="CLR\TranslationTemplate.cs" />
|
||||||
<Compile Include="CSharp\SignatureExtracter.cs" />
|
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Utils\DirectoryHT.cs" />
|
<Compile Include="Utils\DirectoryHT.cs" />
|
||||||
<Compile Include="Utils\Constants.cs" />
|
<Compile Include="Utils\Constants.cs" />
|
||||||
<Compile Include="Utils\TypeHelper.cs" />
|
<Compile Include="Utils\TypeHelper.cs" />
|
||||||
|
<Compile Include="CSharp\TemplateExtracter.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="CSharp\SignatureExtracter.g" />
|
|
||||||
<None Include="CSharp\csCrawl.g" />
|
<None Include="CSharp\csCrawl.g" />
|
||||||
<None Include="CSharp\cs.g" />
|
<None Include="CSharp\cs.g" />
|
||||||
|
<None Include="CSharp\TemplateExtracter.g" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="README.txt" />
|
<Content Include="README.txt" />
|
||||||
@ -102,6 +102,10 @@
|
|||||||
<Project>{CF15D0D5-BE72-4F98-B70F-229ABA1DF0E8}</Project>
|
<Project>{CF15D0D5-BE72-4F98-B70F-229ABA1DF0E8}</Project>
|
||||||
<Name>Antlr3.Runtime</Name>
|
<Name>Antlr3.Runtime</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\NDesk.Options\NDesk.Options.csproj">
|
||||||
|
<Project>{E6ACBB37-AF38-45E1-B399-0CEE63809A15}</Project>
|
||||||
|
<Name>NDesk.Options</Name>
|
||||||
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\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.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user