Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

really initial commit

  • Loading branch information...
commit cf00192b86ea805ddc42dec2de9bb08e091569b1 1 parent 28b1b92
yas4891 authored
Showing with 10,448 additions and 0 deletions.
  1. +30 −0 .gitignore
  2. +8 −0 App.xaml
  3. +16 −0 App.xaml.cs
  4. +6,516 −0 CTokenizer/CLexer.cs
  5. +74 −0 CTokenizer/CTokenizer.csproj
  6. +33 −0 CTokenizer/LexerHelper.cs
  7. +1,574 −0 CTokenizer/MutexCLexer.cs
  8. +31 −0 CTokenizer/MutexCLexer.g
  9. +9 −0 CTokenizer/MutexCLexer.tokens
  10. +36 −0 CTokenizer/Properties/AssemblyInfo.cs
  11. +59 −0 CTokenizer/TokenWrapper.cs
  12. +70 −0 GSTConsole/GSTConsole.csproj
  13. +70 −0 GSTConsole/Program.cs
  14. +36 −0 GSTConsole/Properties/AssemblyInfo.cs
  15. +71 −0 GSTLibrary/GSTLibrary.csproj
  16. +36 −0 GSTLibrary/Properties/AssemblyInfo.cs
  17. +18 −0 GSTLibrary/exception/GSTException.cs
  18. +214 −0 GSTLibrary/test/tile/GSTAlgorithmTest.cs
  19. +40 −0 GSTLibrary/test/tile/TileTest.cs
  20. +33 −0 GSTLibrary/test/token/GSTTokenTest.cs
  21. +321 −0 GSTLibrary/tile/GSTAlgorithm.cs
  22. +116 −0 GSTLibrary/tile/Tile.cs
  23. +35 −0 GSTLibrary/token/GSTHelper.cs
  24. +70 −0 GSTLibrary/token/GSTToken.cs
  25. +19 −0 GSTLibrary/token/GSTTokenList.cs
  26. +17 −0 GSTTests.VisualState.xml
  27. +7 −0 GSTTests.nunit
  28. +113 −0 GreedyStringTiling.csproj
  29. +66 −0 GreedyStringTiling.sln
  30. +22 −0 MainWindow.xaml
  31. +270 −0 MainWindow.xaml.cs
  32. +55 −0 Properties/AssemblyInfo.cs
  33. +71 −0 Properties/Resources.Designer.cs
  34. +117 −0 Properties/Resources.resx
  35. +30 −0 Properties/Settings.Designer.cs
  36. +7 −0 Properties/Settings.settings
  37. BIN  ThirdPartyLibs/Antlr3.Runtime.dll
  38. BIN  ThirdPartyLibs/Antlr3.Runtime.pdb
  39. +25 −0 UIHelper.cs
  40. BIN  nunit.framework.dll
  41. BIN  nunit.mocks.dll
  42. +1 −0  openConsole.bat
  43. +58 −0 test/main-01.c
  44. +54 −0 test/main-13.c
30 .gitignore
View
@@ -0,0 +1,30 @@
+# See http://help.github.com/ignore-files/ for more about ignoring files.
+#
+# If you find yourself ignoring temporary files generated by your text editor
+# or operating system, you probably want to add a global ignore instead:
+# git config --global core.excludesfile ~/.gitignore_global
+
+# ignore ResharperFiles
+/_ReSharper*
+*ReSharper*
+
+# ignore compiler generated files
+*/bin/*/*.exe
+*/bin/*/*.dll
+*/bin/*/*.manifest
+*/bin/*/*.pdb
+*/obj
+/obj
+/bin/*/*.exe
+/bin/*/*.dll
+/bin/*/*.manifest
+/bin/*/*.pdb
+
+
+# ignore user-specific Visual Studio files
+GreedyStringTiling.suo
+GreedyStringTiling.sln.DotSettings.user
+
+# ignore nUnit result file
+TestResult.xml
+
8 App.xaml
View
@@ -0,0 +1,8 @@
+<Application x:Class="GreedyStringTiling.App"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ StartupUri="MainWindow.xaml">
+ <Application.Resources>
+
+ </Application.Resources>
+</Application>
16 App.xaml.cs
View
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Data;
+using System.Linq;
+using System.Windows;
+
+namespace GreedyStringTiling
+{
+ /// <summary>
+ /// Interaktionslogik für "App.xaml"
+ /// </summary>
+ public partial class App : Application
+ {
+ }
+}
6,516 CTokenizer/CLexer.cs
View
6,516 additions, 0 deletions not shown
74 CTokenizer/CTokenizer.csproj
View
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{BEF91472-4566-4604-9DEB-3FDFA17E6048}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>CTokenizer</RootNamespace>
+ <AssemblyName>CTokenizer</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Antlr3.Runtime">
+ <HintPath>..\ThirdPartyLibs\Antlr3.Runtime.dll</HintPath>
+ </Reference>
+ <Reference Include="nunit.framework, Version=2.6.0.12051, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\nunit.framework.dll</HintPath>
+ </Reference>
+ <Reference Include="nunit.mocks, Version=2.6.0.12051, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\nunit.mocks.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="CLexer.cs" />
+ <Compile Include="TokenWrapper.cs" />
+ <Compile Include="LexerHelper.cs" />
+ <Compile Include="MutexCLexer.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="MutexCLexer.g" />
+ </ItemGroup>
+ <ItemGroup>
+ <Folder Include="test\" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- 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.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
33 CTokenizer/LexerHelper.cs
View
@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+
+namespace CTokenizer
+{
+ /// <summary>
+ ///
+ /// </summary>
+ public static class LexerHelper
+ {
+ public static string GetTokenNameFromMUTEXLexer(this int tokenType)
+ {
+ return tokenType.GetTokenName(typeof(MutexCLexer));
+ }
+ public static string GetTokenNameFromCLexer(this int tokenType)
+ {
+ return tokenType.GetTokenName(typeof(CLexer));
+ }
+
+ public static string GetTokenName(this int tokenType, Type lexerType)
+ {
+ var fields =
+ lexerType.GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly).Where(
+ field => field.FieldType == typeof(int)).Where(field => ((int)field.GetValue(null)) == tokenType).Select(field => field.Name);
+
+
+ return fields.First();
+ }
+ }
+}
1,574 CTokenizer/MutexCLexer.cs
View
@@ -0,0 +1,1574 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+// ANTLR Version: 3.4
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+// $ANTLR 3.4 D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g 2012-04-17 15:52:25
+
+// The variable 'variable' is assigned but its value is never used.
+#pragma warning disable 168, 219
+// Unreachable code detected.
+#pragma warning disable 162
+// Missing XML comment for publicly visible type or member 'Type_or_Member'
+#pragma warning disable 1591
+
+
+using System.Collections.Generic;
+using Antlr.Runtime;
+using Antlr.Runtime.Misc;
+using ConditionalAttribute = System.Diagnostics.ConditionalAttribute;
+
+[System.CodeDom.Compiler.GeneratedCode("ANTLR", "3.4")]
+[System.CLSCompliant(false)]
+public partial class MutexCLexer : Antlr.Runtime.Lexer
+{
+ public const int EOF=-1;
+ public const int DIGIT=4;
+ public const int FLOAT_DATATYPE=5;
+ public const int HEX_DIGIT=6;
+ public const int IDENTIFIER=7;
+ public const int INTEGER_DATATYPE=8;
+ public const int LETTER=9;
+ public const int POINTER_DATATYPE=10;
+ public const int SIGNED_UNSIGNED=11;
+ public const int VOID_DATATYPE=12;
+
+ // delegates
+ // delegators
+
+ public MutexCLexer()
+ {
+ OnCreated();
+ }
+
+ public MutexCLexer(ICharStream input )
+ : this(input, new RecognizerSharedState())
+ {
+ }
+
+ public MutexCLexer(ICharStream input, RecognizerSharedState state)
+ : base(input, state)
+ {
+
+ OnCreated();
+ }
+ public override string GrammarFileName { get { return "D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g"; } }
+
+ private static readonly bool[] decisionCanBacktrack = new bool[0];
+
+ public override IToken NextToken()
+ {
+ while (true)
+ {
+ if (input.LA(1) == CharStreamConstants.EndOfFile)
+ {
+ IToken eof = new CommonToken((ICharStream)input, CharStreamConstants.EndOfFile, TokenChannels.Default, input.Index, input.Index);
+ eof.Line = Line;
+ eof.CharPositionInLine = CharPositionInLine;
+ return eof;
+ }
+ state.token = null;
+ state.channel = TokenChannels.Default;
+ state.tokenStartCharIndex = input.Index;
+ state.tokenStartCharPositionInLine = input.CharPositionInLine;
+ state.tokenStartLine = input.Line;
+ state.text = null;
+ try
+ {
+ int m = input.Mark();
+ state.backtracking=1;
+ state.failed=false;
+ mTokens();
+ state.backtracking=0;
+ if (state.failed)
+ {
+ input.Rewind(m);
+ input.Consume();
+ }
+ else
+ {
+ Emit();
+ return state.token;
+ }
+ }
+ catch (RecognitionException re)
+ {
+ // shouldn't happen in backtracking mode, but...
+ ReportError(re);
+ Recover(re);
+ }
+ }
+ }
+
+ public override void Memoize(IIntStream input, int ruleIndex, int ruleStartIndex)
+ {
+ if (state.backtracking > 1)
+ base.Memoize(input, ruleIndex, ruleStartIndex);
+ }
+
+ public override bool AlreadyParsedRule(IIntStream input, int ruleIndex)
+ {
+ if (state.backtracking > 1)
+ return base.AlreadyParsedRule(input, ruleIndex);
+
+ return false;
+ }
+
+ [Conditional("ANTLR_TRACE")]
+ protected virtual void OnCreated() {}
+ [Conditional("ANTLR_TRACE")]
+ protected virtual void EnterRule(string ruleName, int ruleIndex) {}
+ [Conditional("ANTLR_TRACE")]
+ protected virtual void LeaveRule(string ruleName, int ruleIndex) {}
+
+ [Conditional("ANTLR_TRACE")]
+ protected virtual void EnterRule_POINTER_DATATYPE() {}
+ [Conditional("ANTLR_TRACE")]
+ protected virtual void LeaveRule_POINTER_DATATYPE() {}
+
+ // $ANTLR start "POINTER_DATATYPE"
+ [GrammarRule("POINTER_DATATYPE")]
+ private void mPOINTER_DATATYPE()
+ {
+ EnterRule_POINTER_DATATYPE();
+ EnterRule("POINTER_DATATYPE", 1);
+ TraceIn("POINTER_DATATYPE", 1);
+ try
+ {
+ int _type = POINTER_DATATYPE;
+ int _channel = DefaultTokenChannel;
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:10:2: ( ( FLOAT_DATATYPE | INTEGER_DATATYPE | VOID_DATATYPE ) ( ' ' )* ( '*' )+ )
+ DebugEnterAlt(1);
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:10:4: ( FLOAT_DATATYPE | INTEGER_DATATYPE | VOID_DATATYPE ) ( ' ' )* ( '*' )+
+ {
+ DebugLocation(10, 4);
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:10:4: ( FLOAT_DATATYPE | INTEGER_DATATYPE | VOID_DATATYPE )
+ int alt1=3;
+ try { DebugEnterSubRule(1);
+ try { DebugEnterDecision(1, decisionCanBacktrack[1]);
+ switch (input.LA(1))
+ {
+ case 'd':
+ case 'f':
+ {
+ alt1 = 1;
+ }
+ break;
+ case 'c':
+ case 'i':
+ case 'l':
+ case 's':
+ case 'u':
+ {
+ alt1 = 2;
+ }
+ break;
+ case 'v':
+ {
+ alt1 = 3;
+ }
+ break;
+ default:
+ {
+ if (state.backtracking>0) {state.failed=true; return;}
+ NoViableAltException nvae = new NoViableAltException("", 1, 0, input);
+ DebugRecognitionException(nvae);
+ throw nvae;
+ }
+ }
+
+ } finally { DebugExitDecision(1); }
+ switch (alt1)
+ {
+ case 1:
+ DebugEnterAlt(1);
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:10:5: FLOAT_DATATYPE
+ {
+ DebugLocation(10, 5);
+ mFLOAT_DATATYPE(); if (state.failed) return;
+
+ }
+ break;
+ case 2:
+ DebugEnterAlt(2);
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:10:22: INTEGER_DATATYPE
+ {
+ DebugLocation(10, 22);
+ mINTEGER_DATATYPE(); if (state.failed) return;
+
+ }
+ break;
+ case 3:
+ DebugEnterAlt(3);
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:10:41: VOID_DATATYPE
+ {
+ DebugLocation(10, 41);
+ mVOID_DATATYPE(); if (state.failed) return;
+
+ }
+ break;
+
+ }
+ } finally { DebugExitSubRule(1); }
+
+ DebugLocation(10, 56);
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:10:56: ( ' ' )*
+ try { DebugEnterSubRule(2);
+ while (true)
+ {
+ int alt2=2;
+ try { DebugEnterDecision(2, decisionCanBacktrack[2]);
+ int LA2_0 = input.LA(1);
+
+ if ((LA2_0==' '))
+ {
+ alt2 = 1;
+ }
+
+
+ } finally { DebugExitDecision(2); }
+ switch ( alt2 )
+ {
+ case 1:
+ DebugEnterAlt(1);
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:10:56: ' '
+ {
+ DebugLocation(10, 56);
+ Match(' '); if (state.failed) return;
+
+ }
+ break;
+
+ default:
+ goto loop2;
+ }
+ }
+
+ loop2:
+ ;
+
+ } finally { DebugExitSubRule(2); }
+
+ DebugLocation(10, 61);
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:10:61: ( '*' )+
+ int cnt3=0;
+ try { DebugEnterSubRule(3);
+ while (true)
+ {
+ int alt3=2;
+ try { DebugEnterDecision(3, decisionCanBacktrack[3]);
+ int LA3_0 = input.LA(1);
+
+ if ((LA3_0=='*'))
+ {
+ alt3 = 1;
+ }
+
+
+ } finally { DebugExitDecision(3); }
+ switch (alt3)
+ {
+ case 1:
+ DebugEnterAlt(1);
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:10:61: '*'
+ {
+ DebugLocation(10, 61);
+ Match('*'); if (state.failed) return;
+
+ }
+ break;
+
+ default:
+ if (cnt3 >= 1)
+ goto loop3;
+
+ if (state.backtracking>0) {state.failed=true; return;}
+ EarlyExitException eee3 = new EarlyExitException( 3, input );
+ DebugRecognitionException(eee3);
+ throw eee3;
+ }
+ cnt3++;
+ }
+ loop3:
+ ;
+
+ } finally { DebugExitSubRule(3); }
+
+
+ }
+
+ state.type = _type;
+ state.channel = _channel;
+ }
+ finally
+ {
+ TraceOut("POINTER_DATATYPE", 1);
+ LeaveRule("POINTER_DATATYPE", 1);
+ LeaveRule_POINTER_DATATYPE();
+ }
+ }
+ // $ANTLR end "POINTER_DATATYPE"
+
+ [Conditional("ANTLR_TRACE")]
+ protected virtual void EnterRule_VOID_DATATYPE() {}
+ [Conditional("ANTLR_TRACE")]
+ protected virtual void LeaveRule_VOID_DATATYPE() {}
+
+ // $ANTLR start "VOID_DATATYPE"
+ [GrammarRule("VOID_DATATYPE")]
+ private void mVOID_DATATYPE()
+ {
+ EnterRule_VOID_DATATYPE();
+ EnterRule("VOID_DATATYPE", 2);
+ TraceIn("VOID_DATATYPE", 2);
+ try
+ {
+ int _type = VOID_DATATYPE;
+ int _channel = DefaultTokenChannel;
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:13:2: ( 'void' )
+ DebugEnterAlt(1);
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:13:5: 'void'
+ {
+ DebugLocation(13, 5);
+ Match("void"); if (state.failed) return;
+
+
+ }
+
+ state.type = _type;
+ state.channel = _channel;
+ }
+ finally
+ {
+ TraceOut("VOID_DATATYPE", 2);
+ LeaveRule("VOID_DATATYPE", 2);
+ LeaveRule_VOID_DATATYPE();
+ }
+ }
+ // $ANTLR end "VOID_DATATYPE"
+
+ [Conditional("ANTLR_TRACE")]
+ protected virtual void EnterRule_FLOAT_DATATYPE() {}
+ [Conditional("ANTLR_TRACE")]
+ protected virtual void LeaveRule_FLOAT_DATATYPE() {}
+
+ // $ANTLR start "FLOAT_DATATYPE"
+ [GrammarRule("FLOAT_DATATYPE")]
+ private void mFLOAT_DATATYPE()
+ {
+ EnterRule_FLOAT_DATATYPE();
+ EnterRule("FLOAT_DATATYPE", 3);
+ TraceIn("FLOAT_DATATYPE", 3);
+ try
+ {
+ int _type = FLOAT_DATATYPE;
+ int _channel = DefaultTokenChannel;
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:14:16: ( 'float' | 'double' )
+ int alt4=2;
+ try { DebugEnterDecision(4, decisionCanBacktrack[4]);
+ int LA4_0 = input.LA(1);
+
+ if ((LA4_0=='f'))
+ {
+ alt4 = 1;
+ }
+ else if ((LA4_0=='d'))
+ {
+ alt4 = 2;
+ }
+ else
+ {
+ if (state.backtracking>0) {state.failed=true; return;}
+ NoViableAltException nvae = new NoViableAltException("", 4, 0, input);
+ DebugRecognitionException(nvae);
+ throw nvae;
+ }
+ } finally { DebugExitDecision(4); }
+ switch (alt4)
+ {
+ case 1:
+ DebugEnterAlt(1);
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:14:18: 'float'
+ {
+ DebugLocation(14, 18);
+ Match("float"); if (state.failed) return;
+
+
+ }
+ break;
+ case 2:
+ DebugEnterAlt(2);
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:14:28: 'double'
+ {
+ DebugLocation(14, 28);
+ Match("double"); if (state.failed) return;
+
+
+ }
+ break;
+
+ }
+ state.type = _type;
+ state.channel = _channel;
+ }
+ finally
+ {
+ TraceOut("FLOAT_DATATYPE", 3);
+ LeaveRule("FLOAT_DATATYPE", 3);
+ LeaveRule_FLOAT_DATATYPE();
+ }
+ }
+ // $ANTLR end "FLOAT_DATATYPE"
+
+ [Conditional("ANTLR_TRACE")]
+ protected virtual void EnterRule_INTEGER_DATATYPE() {}
+ [Conditional("ANTLR_TRACE")]
+ protected virtual void LeaveRule_INTEGER_DATATYPE() {}
+
+ // $ANTLR start "INTEGER_DATATYPE"
+ [GrammarRule("INTEGER_DATATYPE")]
+ private void mINTEGER_DATATYPE()
+ {
+ EnterRule_INTEGER_DATATYPE();
+ EnterRule("INTEGER_DATATYPE", 4);
+ TraceIn("INTEGER_DATATYPE", 4);
+ try
+ {
+ int _type = INTEGER_DATATYPE;
+ int _channel = DefaultTokenChannel;
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:16:18: ( ( SIGNED_UNSIGNED )? ( 'short' | 'int' | 'long' | 'char' ) )
+ DebugEnterAlt(1);
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:16:20: ( SIGNED_UNSIGNED )? ( 'short' | 'int' | 'long' | 'char' )
+ {
+ DebugLocation(16, 20);
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:16:20: ( SIGNED_UNSIGNED )?
+ int alt5=2;
+ try { DebugEnterSubRule(5);
+ try { DebugEnterDecision(5, decisionCanBacktrack[5]);
+ int LA5_0 = input.LA(1);
+
+ if ((LA5_0=='s'))
+ {
+ int LA5_1 = input.LA(2);
+
+ if ((LA5_1=='i'))
+ {
+ alt5 = 1;
+ }
+ }
+ else if ((LA5_0=='u'))
+ {
+ alt5 = 1;
+ }
+ } finally { DebugExitDecision(5); }
+ switch (alt5)
+ {
+ case 1:
+ DebugEnterAlt(1);
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:16:21: SIGNED_UNSIGNED
+ {
+ DebugLocation(16, 21);
+ mSIGNED_UNSIGNED(); if (state.failed) return;
+
+ }
+ break;
+
+ }
+ } finally { DebugExitSubRule(5); }
+
+ DebugLocation(16, 39);
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:16:39: ( 'short' | 'int' | 'long' | 'char' )
+ int alt6=4;
+ try { DebugEnterSubRule(6);
+ try { DebugEnterDecision(6, decisionCanBacktrack[6]);
+ switch (input.LA(1))
+ {
+ case 's':
+ {
+ alt6 = 1;
+ }
+ break;
+ case 'i':
+ {
+ alt6 = 2;
+ }
+ break;
+ case 'l':
+ {
+ alt6 = 3;
+ }
+ break;
+ case 'c':
+ {
+ alt6 = 4;
+ }
+ break;
+ default:
+ {
+ if (state.backtracking>0) {state.failed=true; return;}
+ NoViableAltException nvae = new NoViableAltException("", 6, 0, input);
+ DebugRecognitionException(nvae);
+ throw nvae;
+ }
+ }
+
+ } finally { DebugExitDecision(6); }
+ switch (alt6)
+ {
+ case 1:
+ DebugEnterAlt(1);
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:16:40: 'short'
+ {
+ DebugLocation(16, 40);
+ Match("short"); if (state.failed) return;
+
+
+ }
+ break;
+ case 2:
+ DebugEnterAlt(2);
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:16:50: 'int'
+ {
+ DebugLocation(16, 50);
+ Match("int"); if (state.failed) return;
+
+
+ }
+ break;
+ case 3:
+ DebugEnterAlt(3);
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:16:58: 'long'
+ {
+ DebugLocation(16, 58);
+ Match("long"); if (state.failed) return;
+
+
+ }
+ break;
+ case 4:
+ DebugEnterAlt(4);
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:16:67: 'char'
+ {
+ DebugLocation(16, 67);
+ Match("char"); if (state.failed) return;
+
+
+ }
+ break;
+
+ }
+ } finally { DebugExitSubRule(6); }
+
+
+ }
+
+ state.type = _type;
+ state.channel = _channel;
+ }
+ finally
+ {
+ TraceOut("INTEGER_DATATYPE", 4);
+ LeaveRule("INTEGER_DATATYPE", 4);
+ LeaveRule_INTEGER_DATATYPE();
+ }
+ }
+ // $ANTLR end "INTEGER_DATATYPE"
+
+ [Conditional("ANTLR_TRACE")]
+ protected virtual void EnterRule_SIGNED_UNSIGNED() {}
+ [Conditional("ANTLR_TRACE")]
+ protected virtual void LeaveRule_SIGNED_UNSIGNED() {}
+
+ // $ANTLR start "SIGNED_UNSIGNED"
+ [GrammarRule("SIGNED_UNSIGNED")]
+ private void mSIGNED_UNSIGNED()
+ {
+ EnterRule_SIGNED_UNSIGNED();
+ EnterRule("SIGNED_UNSIGNED", 5);
+ TraceIn("SIGNED_UNSIGNED", 5);
+ try
+ {
+ int _type = SIGNED_UNSIGNED;
+ int _channel = DefaultTokenChannel;
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:18:17: ( 'signed' | 'unsigned' )
+ int alt7=2;
+ try { DebugEnterDecision(7, decisionCanBacktrack[7]);
+ int LA7_0 = input.LA(1);
+
+ if ((LA7_0=='s'))
+ {
+ alt7 = 1;
+ }
+ else if ((LA7_0=='u'))
+ {
+ alt7 = 2;
+ }
+ else
+ {
+ if (state.backtracking>0) {state.failed=true; return;}
+ NoViableAltException nvae = new NoViableAltException("", 7, 0, input);
+ DebugRecognitionException(nvae);
+ throw nvae;
+ }
+ } finally { DebugExitDecision(7); }
+ switch (alt7)
+ {
+ case 1:
+ DebugEnterAlt(1);
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:18:19: 'signed'
+ {
+ DebugLocation(18, 19);
+ Match("signed"); if (state.failed) return;
+
+
+ }
+ break;
+ case 2:
+ DebugEnterAlt(2);
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:18:30: 'unsigned'
+ {
+ DebugLocation(18, 30);
+ Match("unsigned"); if (state.failed) return;
+
+
+ }
+ break;
+
+ }
+ state.type = _type;
+ state.channel = _channel;
+ }
+ finally
+ {
+ TraceOut("SIGNED_UNSIGNED", 5);
+ LeaveRule("SIGNED_UNSIGNED", 5);
+ LeaveRule_SIGNED_UNSIGNED();
+ }
+ }
+ // $ANTLR end "SIGNED_UNSIGNED"
+
+ [Conditional("ANTLR_TRACE")]
+ protected virtual void EnterRule_IDENTIFIER() {}
+ [Conditional("ANTLR_TRACE")]
+ protected virtual void LeaveRule_IDENTIFIER() {}
+
+ // $ANTLR start "IDENTIFIER"
+ [GrammarRule("IDENTIFIER")]
+ private void mIDENTIFIER()
+ {
+ EnterRule_IDENTIFIER();
+ EnterRule("IDENTIFIER", 6);
+ TraceIn("IDENTIFIER", 6);
+ try
+ {
+ int _type = IDENTIFIER;
+ int _channel = DefaultTokenChannel;
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:21:2: ( LETTER ( LETTER | DIGIT )* )
+ DebugEnterAlt(1);
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:21:4: LETTER ( LETTER | DIGIT )*
+ {
+ DebugLocation(21, 4);
+ mLETTER(); if (state.failed) return;
+ DebugLocation(21, 11);
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:21:11: ( LETTER | DIGIT )*
+ try { DebugEnterSubRule(8);
+ while (true)
+ {
+ int alt8=2;
+ try { DebugEnterDecision(8, decisionCanBacktrack[8]);
+ int LA8_0 = input.LA(1);
+
+ if (((LA8_0>='0' && LA8_0<='9')||(LA8_0>='A' && LA8_0<='Z')||LA8_0=='_'||(LA8_0>='a' && LA8_0<='z')))
+ {
+ alt8 = 1;
+ }
+
+
+ } finally { DebugExitDecision(8); }
+ switch ( alt8 )
+ {
+ case 1:
+ DebugEnterAlt(1);
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:
+ {
+ DebugLocation(21, 11);
+ input.Consume();
+ state.failed=false;
+
+ }
+ break;
+
+ default:
+ goto loop8;
+ }
+ }
+
+ loop8:
+ ;
+
+ } finally { DebugExitSubRule(8); }
+
+
+ }
+
+ state.type = _type;
+ state.channel = _channel;
+ }
+ finally
+ {
+ TraceOut("IDENTIFIER", 6);
+ LeaveRule("IDENTIFIER", 6);
+ LeaveRule_IDENTIFIER();
+ }
+ }
+ // $ANTLR end "IDENTIFIER"
+
+ [Conditional("ANTLR_TRACE")]
+ protected virtual void EnterRule_LETTER() {}
+ [Conditional("ANTLR_TRACE")]
+ protected virtual void LeaveRule_LETTER() {}
+
+ // $ANTLR start "LETTER"
+ [GrammarRule("LETTER")]
+ private void mLETTER()
+ {
+ EnterRule_LETTER();
+ EnterRule("LETTER", 7);
+ TraceIn("LETTER", 7);
+ try
+ {
+ int _type = LETTER;
+ int _channel = DefaultTokenChannel;
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:23:8: ( 'A' .. 'Z' | 'a' .. 'z' | '_' )
+ DebugEnterAlt(1);
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:
+ {
+ DebugLocation(23, 8);
+ if ((input.LA(1)>='A' && input.LA(1)<='Z')||input.LA(1)=='_'||(input.LA(1)>='a' && input.LA(1)<='z'))
+ {
+ input.Consume();
+ state.failed=false;
+ }
+ else
+ {
+ if (state.backtracking>0) {state.failed=true; return;}
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ DebugRecognitionException(mse);
+ Recover(mse);
+ throw mse;
+ }
+
+
+ }
+
+ state.type = _type;
+ state.channel = _channel;
+ }
+ finally
+ {
+ TraceOut("LETTER", 7);
+ LeaveRule("LETTER", 7);
+ LeaveRule_LETTER();
+ }
+ }
+ // $ANTLR end "LETTER"
+
+ [Conditional("ANTLR_TRACE")]
+ protected virtual void EnterRule_HEX_DIGIT() {}
+ [Conditional("ANTLR_TRACE")]
+ protected virtual void LeaveRule_HEX_DIGIT() {}
+
+ // $ANTLR start "HEX_DIGIT"
+ [GrammarRule("HEX_DIGIT")]
+ private void mHEX_DIGIT()
+ {
+ EnterRule_HEX_DIGIT();
+ EnterRule("HEX_DIGIT", 8);
+ TraceIn("HEX_DIGIT", 8);
+ try
+ {
+ int _type = HEX_DIGIT;
+ int _channel = DefaultTokenChannel;
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:25:11: ( DIGIT | 'a' .. 'f' | 'A' .. 'F' )
+ DebugEnterAlt(1);
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:
+ {
+ DebugLocation(25, 11);
+ if ((input.LA(1)>='0' && input.LA(1)<='9')||(input.LA(1)>='A' && input.LA(1)<='F')||(input.LA(1)>='a' && input.LA(1)<='f'))
+ {
+ input.Consume();
+ state.failed=false;
+ }
+ else
+ {
+ if (state.backtracking>0) {state.failed=true; return;}
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ DebugRecognitionException(mse);
+ Recover(mse);
+ throw mse;
+ }
+
+
+ }
+
+ state.type = _type;
+ state.channel = _channel;
+ }
+ finally
+ {
+ TraceOut("HEX_DIGIT", 8);
+ LeaveRule("HEX_DIGIT", 8);
+ LeaveRule_HEX_DIGIT();
+ }
+ }
+ // $ANTLR end "HEX_DIGIT"
+
+ [Conditional("ANTLR_TRACE")]
+ protected virtual void EnterRule_DIGIT() {}
+ [Conditional("ANTLR_TRACE")]
+ protected virtual void LeaveRule_DIGIT() {}
+
+ // $ANTLR start "DIGIT"
+ [GrammarRule("DIGIT")]
+ private void mDIGIT()
+ {
+ EnterRule_DIGIT();
+ EnterRule("DIGIT", 9);
+ TraceIn("DIGIT", 9);
+ try
+ {
+ int _type = DIGIT;
+ int _channel = DefaultTokenChannel;
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:27:7: ( '0' .. '9' )
+ DebugEnterAlt(1);
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:
+ {
+ DebugLocation(27, 7);
+ if ((input.LA(1)>='0' && input.LA(1)<='9'))
+ {
+ input.Consume();
+ state.failed=false;
+ }
+ else
+ {
+ if (state.backtracking>0) {state.failed=true; return;}
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ DebugRecognitionException(mse);
+ Recover(mse);
+ throw mse;
+ }
+
+
+ }
+
+ state.type = _type;
+ state.channel = _channel;
+ }
+ finally
+ {
+ TraceOut("DIGIT", 9);
+ LeaveRule("DIGIT", 9);
+ LeaveRule_DIGIT();
+ }
+ }
+ // $ANTLR end "DIGIT"
+
+ public override void mTokens()
+ {
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:1:39: ( POINTER_DATATYPE | VOID_DATATYPE | FLOAT_DATATYPE | INTEGER_DATATYPE | SIGNED_UNSIGNED | IDENTIFIER | LETTER | HEX_DIGIT | DIGIT )
+ int alt9=9;
+ try { DebugEnterDecision(9, decisionCanBacktrack[9]);
+ switch (input.LA(1))
+ {
+ case 'v':
+ {
+ int LA9_1 = input.LA(2);
+
+ if ((EvaluatePredicate(synpred1_MutexCLexer_fragment)))
+ {
+ alt9 = 1;
+ }
+ else if ((EvaluatePredicate(synpred2_MutexCLexer_fragment)))
+ {
+ alt9 = 2;
+ }
+ else if ((EvaluatePredicate(synpred6_MutexCLexer_fragment)))
+ {
+ alt9 = 6;
+ }
+ else if ((EvaluatePredicate(synpred7_MutexCLexer_fragment)))
+ {
+ alt9 = 7;
+ }
+ else
+ {
+ if (state.backtracking>0) {state.failed=true; return;}
+ NoViableAltException nvae = new NoViableAltException("", 9, 1, input);
+ DebugRecognitionException(nvae);
+ throw nvae;
+ }
+ }
+ break;
+ case 'd':
+ case 'f':
+ {
+ int LA9_6 = input.LA(2);
+
+ if ((EvaluatePredicate(synpred1_MutexCLexer_fragment)))
+ {
+ alt9 = 1;
+ }
+ else if ((EvaluatePredicate(synpred3_MutexCLexer_fragment)))
+ {
+ alt9 = 3;
+ }
+ else if ((EvaluatePredicate(synpred6_MutexCLexer_fragment)))
+ {
+ alt9 = 6;
+ }
+ else if ((EvaluatePredicate(synpred7_MutexCLexer_fragment)))
+ {
+ alt9 = 7;
+ }
+ else if ((EvaluatePredicate(synpred8_MutexCLexer_fragment)))
+ {
+ alt9 = 8;
+ }
+ else
+ {
+ if (state.backtracking>0) {state.failed=true; return;}
+ NoViableAltException nvae = new NoViableAltException("", 9, 6, input);
+ DebugRecognitionException(nvae);
+ throw nvae;
+ }
+ }
+ break;
+ case 's':
+ case 'u':
+ {
+ int LA9_9 = input.LA(2);
+
+ if ((EvaluatePredicate(synpred1_MutexCLexer_fragment)))
+ {
+ alt9 = 1;
+ }
+ else if ((EvaluatePredicate(synpred4_MutexCLexer_fragment)))
+ {
+ alt9 = 4;
+ }
+ else if ((EvaluatePredicate(synpred5_MutexCLexer_fragment)))
+ {
+ alt9 = 5;
+ }
+ else if ((EvaluatePredicate(synpred6_MutexCLexer_fragment)))
+ {
+ alt9 = 6;
+ }
+ else if ((EvaluatePredicate(synpred7_MutexCLexer_fragment)))
+ {
+ alt9 = 7;
+ }
+ else
+ {
+ if (state.backtracking>0) {state.failed=true; return;}
+ NoViableAltException nvae = new NoViableAltException("", 9, 9, input);
+ DebugRecognitionException(nvae);
+ throw nvae;
+ }
+ }
+ break;
+ case 'c':
+ {
+ int LA9_12 = input.LA(2);
+
+ if ((EvaluatePredicate(synpred1_MutexCLexer_fragment)))
+ {
+ alt9 = 1;
+ }
+ else if ((EvaluatePredicate(synpred4_MutexCLexer_fragment)))
+ {
+ alt9 = 4;
+ }
+ else if ((EvaluatePredicate(synpred6_MutexCLexer_fragment)))
+ {
+ alt9 = 6;
+ }
+ else if ((EvaluatePredicate(synpred7_MutexCLexer_fragment)))
+ {
+ alt9 = 7;
+ }
+ else if ((EvaluatePredicate(synpred8_MutexCLexer_fragment)))
+ {
+ alt9 = 8;
+ }
+ else
+ {
+ if (state.backtracking>0) {state.failed=true; return;}
+ NoViableAltException nvae = new NoViableAltException("", 9, 12, input);
+ DebugRecognitionException(nvae);
+ throw nvae;
+ }
+ }
+ break;
+ case 'A':
+ case 'B':
+ case 'C':
+ case 'D':
+ case 'E':
+ case 'F':
+ case 'a':
+ case 'b':
+ case 'e':
+ {
+ int LA9_13 = input.LA(2);
+
+ if ((EvaluatePredicate(synpred6_MutexCLexer_fragment)))
+ {
+ alt9 = 6;
+ }
+ else if ((EvaluatePredicate(synpred7_MutexCLexer_fragment)))
+ {
+ alt9 = 7;
+ }
+ else if ((EvaluatePredicate(synpred8_MutexCLexer_fragment)))
+ {
+ alt9 = 8;
+ }
+ else
+ {
+ if (state.backtracking>0) {state.failed=true; return;}
+ NoViableAltException nvae = new NoViableAltException("", 9, 13, input);
+ DebugRecognitionException(nvae);
+ throw nvae;
+ }
+ }
+ break;
+ case 'i':
+ case 'l':
+ {
+ int LA9_14 = input.LA(2);
+
+ if ((EvaluatePredicate(synpred1_MutexCLexer_fragment)))
+ {
+ alt9 = 1;
+ }
+ else if ((EvaluatePredicate(synpred4_MutexCLexer_fragment)))
+ {
+ alt9 = 4;
+ }
+ else if ((EvaluatePredicate(synpred6_MutexCLexer_fragment)))
+ {
+ alt9 = 6;
+ }
+ else if ((EvaluatePredicate(synpred7_MutexCLexer_fragment)))
+ {
+ alt9 = 7;
+ }
+ else
+ {
+ if (state.backtracking>0) {state.failed=true; return;}
+ NoViableAltException nvae = new NoViableAltException("", 9, 14, input);
+ DebugRecognitionException(nvae);
+ throw nvae;
+ }
+ }
+ break;
+ case 'G':
+ case 'H':
+ case 'I':
+ case 'J':
+ case 'K':
+ case 'L':
+ case 'M':
+ case 'N':
+ case 'O':
+ case 'P':
+ case 'Q':
+ case 'R':
+ case 'S':
+ case 'T':
+ case 'U':
+ case 'V':
+ case 'W':
+ case 'X':
+ case 'Y':
+ case 'Z':
+ case '_':
+ case 'g':
+ case 'h':
+ case 'j':
+ case 'k':
+ case 'm':
+ case 'n':
+ case 'o':
+ case 'p':
+ case 'q':
+ case 'r':
+ case 't':
+ case 'w':
+ case 'x':
+ case 'y':
+ case 'z':
+ {
+ int LA9_15 = input.LA(2);
+
+ if ((EvaluatePredicate(synpred6_MutexCLexer_fragment)))
+ {
+ alt9 = 6;
+ }
+ else if ((EvaluatePredicate(synpred7_MutexCLexer_fragment)))
+ {
+ alt9 = 7;
+ }
+ else
+ {
+ if (state.backtracking>0) {state.failed=true; return;}
+ NoViableAltException nvae = new NoViableAltException("", 9, 15, input);
+ DebugRecognitionException(nvae);
+ throw nvae;
+ }
+ }
+ break;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ {
+ int LA9_16 = input.LA(2);
+
+ if ((EvaluatePredicate(synpred8_MutexCLexer_fragment)))
+ {
+ alt9 = 8;
+ }
+ else if ((true))
+ {
+ alt9 = 9;
+ }
+ else
+ {
+ if (state.backtracking>0) {state.failed=true; return;}
+ NoViableAltException nvae = new NoViableAltException("", 9, 16, input);
+ DebugRecognitionException(nvae);
+ throw nvae;
+ }
+ }
+ break;
+ default:
+ {
+ if (state.backtracking>0) {state.failed=true; return;}
+ NoViableAltException nvae = new NoViableAltException("", 9, 0, input);
+ DebugRecognitionException(nvae);
+ throw nvae;
+ }
+ }
+
+ } finally { DebugExitDecision(9); }
+ switch (alt9)
+ {
+ case 1:
+ DebugEnterAlt(1);
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:1:41: POINTER_DATATYPE
+ {
+ DebugLocation(1, 41);
+ mPOINTER_DATATYPE(); if (state.failed) return;
+
+ }
+ break;
+ case 2:
+ DebugEnterAlt(2);
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:1:58: VOID_DATATYPE
+ {
+ DebugLocation(1, 58);
+ mVOID_DATATYPE(); if (state.failed) return;
+
+ }
+ break;
+ case 3:
+ DebugEnterAlt(3);
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:1:72: FLOAT_DATATYPE
+ {
+ DebugLocation(1, 72);
+ mFLOAT_DATATYPE(); if (state.failed) return;
+
+ }
+ break;
+ case 4:
+ DebugEnterAlt(4);
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:1:87: INTEGER_DATATYPE
+ {
+ DebugLocation(1, 87);
+ mINTEGER_DATATYPE(); if (state.failed) return;
+
+ }
+ break;
+ case 5:
+ DebugEnterAlt(5);
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:1:104: SIGNED_UNSIGNED
+ {
+ DebugLocation(1, 104);
+ mSIGNED_UNSIGNED(); if (state.failed) return;
+
+ }
+ break;
+ case 6:
+ DebugEnterAlt(6);
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:1:120: IDENTIFIER
+ {
+ DebugLocation(1, 120);
+ mIDENTIFIER(); if (state.failed) return;
+
+ }
+ break;
+ case 7:
+ DebugEnterAlt(7);
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:1:131: LETTER
+ {
+ DebugLocation(1, 131);
+ mLETTER(); if (state.failed) return;
+
+ }
+ break;
+ case 8:
+ DebugEnterAlt(8);
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:1:138: HEX_DIGIT
+ {
+ DebugLocation(1, 138);
+ mHEX_DIGIT(); if (state.failed) return;
+
+ }
+ break;
+ case 9:
+ DebugEnterAlt(9);
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:1:148: DIGIT
+ {
+ DebugLocation(1, 148);
+ mDIGIT(); if (state.failed) return;
+
+ }
+ break;
+
+ }
+
+ }
+ [Conditional("ANTLR_TRACE")]
+ protected virtual void EnterRule_synpred1_MutexCLexer_fragment() {}
+ [Conditional("ANTLR_TRACE")]
+ protected virtual void LeaveRule_synpred1_MutexCLexer_fragment() {}
+
+ // $ANTLR start synpred1_MutexCLexer
+ public void synpred1_MutexCLexer_fragment()
+ {
+ EnterRule_synpred1_MutexCLexer_fragment();
+ EnterRule("synpred1_MutexCLexer_fragment", 11);
+ TraceIn("synpred1_MutexCLexer_fragment", 11);
+ try
+ {
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:1:41: ( POINTER_DATATYPE )
+ DebugEnterAlt(1);
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:1:41: POINTER_DATATYPE
+ {
+ DebugLocation(1, 41);
+ mPOINTER_DATATYPE(); if (state.failed) return;
+
+ }
+
+ }
+ finally
+ {
+ TraceOut("synpred1_MutexCLexer_fragment", 11);
+ LeaveRule("synpred1_MutexCLexer_fragment", 11);
+ LeaveRule_synpred1_MutexCLexer_fragment();
+ }
+ }
+ // $ANTLR end synpred1_MutexCLexer
+ [Conditional("ANTLR_TRACE")]
+ protected virtual void EnterRule_synpred2_MutexCLexer_fragment() {}
+ [Conditional("ANTLR_TRACE")]
+ protected virtual void LeaveRule_synpred2_MutexCLexer_fragment() {}
+
+ // $ANTLR start synpred2_MutexCLexer
+ public void synpred2_MutexCLexer_fragment()
+ {
+ EnterRule_synpred2_MutexCLexer_fragment();
+ EnterRule("synpred2_MutexCLexer_fragment", 12);
+ TraceIn("synpred2_MutexCLexer_fragment", 12);
+ try
+ {
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:1:58: ( VOID_DATATYPE )
+ DebugEnterAlt(1);
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:1:58: VOID_DATATYPE
+ {
+ DebugLocation(1, 58);
+ mVOID_DATATYPE(); if (state.failed) return;
+
+ }
+
+ }
+ finally
+ {
+ TraceOut("synpred2_MutexCLexer_fragment", 12);
+ LeaveRule("synpred2_MutexCLexer_fragment", 12);
+ LeaveRule_synpred2_MutexCLexer_fragment();
+ }
+ }
+ // $ANTLR end synpred2_MutexCLexer
+ [Conditional("ANTLR_TRACE")]
+ protected virtual void EnterRule_synpred3_MutexCLexer_fragment() {}
+ [Conditional("ANTLR_TRACE")]
+ protected virtual void LeaveRule_synpred3_MutexCLexer_fragment() {}
+
+ // $ANTLR start synpred3_MutexCLexer
+ public void synpred3_MutexCLexer_fragment()
+ {
+ EnterRule_synpred3_MutexCLexer_fragment();
+ EnterRule("synpred3_MutexCLexer_fragment", 13);
+ TraceIn("synpred3_MutexCLexer_fragment", 13);
+ try
+ {
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:1:72: ( FLOAT_DATATYPE )
+ DebugEnterAlt(1);
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:1:72: FLOAT_DATATYPE
+ {
+ DebugLocation(1, 72);
+ mFLOAT_DATATYPE(); if (state.failed) return;
+
+ }
+
+ }
+ finally
+ {
+ TraceOut("synpred3_MutexCLexer_fragment", 13);
+ LeaveRule("synpred3_MutexCLexer_fragment", 13);
+ LeaveRule_synpred3_MutexCLexer_fragment();
+ }
+ }
+ // $ANTLR end synpred3_MutexCLexer
+ [Conditional("ANTLR_TRACE")]
+ protected virtual void EnterRule_synpred4_MutexCLexer_fragment() {}
+ [Conditional("ANTLR_TRACE")]
+ protected virtual void LeaveRule_synpred4_MutexCLexer_fragment() {}
+
+ // $ANTLR start synpred4_MutexCLexer
+ public void synpred4_MutexCLexer_fragment()
+ {
+ EnterRule_synpred4_MutexCLexer_fragment();
+ EnterRule("synpred4_MutexCLexer_fragment", 14);
+ TraceIn("synpred4_MutexCLexer_fragment", 14);
+ try
+ {
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:1:87: ( INTEGER_DATATYPE )
+ DebugEnterAlt(1);
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:1:87: INTEGER_DATATYPE
+ {
+ DebugLocation(1, 87);
+ mINTEGER_DATATYPE(); if (state.failed) return;
+
+ }
+
+ }
+ finally
+ {
+ TraceOut("synpred4_MutexCLexer_fragment", 14);
+ LeaveRule("synpred4_MutexCLexer_fragment", 14);
+ LeaveRule_synpred4_MutexCLexer_fragment();
+ }
+ }
+ // $ANTLR end synpred4_MutexCLexer
+ [Conditional("ANTLR_TRACE")]
+ protected virtual void EnterRule_synpred5_MutexCLexer_fragment() {}
+ [Conditional("ANTLR_TRACE")]
+ protected virtual void LeaveRule_synpred5_MutexCLexer_fragment() {}
+
+ // $ANTLR start synpred5_MutexCLexer
+ public void synpred5_MutexCLexer_fragment()
+ {
+ EnterRule_synpred5_MutexCLexer_fragment();
+ EnterRule("synpred5_MutexCLexer_fragment", 15);
+ TraceIn("synpred5_MutexCLexer_fragment", 15);
+ try
+ {
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:1:104: ( SIGNED_UNSIGNED )
+ DebugEnterAlt(1);
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:1:104: SIGNED_UNSIGNED
+ {
+ DebugLocation(1, 104);
+ mSIGNED_UNSIGNED(); if (state.failed) return;
+
+ }
+
+ }
+ finally
+ {
+ TraceOut("synpred5_MutexCLexer_fragment", 15);
+ LeaveRule("synpred5_MutexCLexer_fragment", 15);
+ LeaveRule_synpred5_MutexCLexer_fragment();
+ }
+ }
+ // $ANTLR end synpred5_MutexCLexer
+ [Conditional("ANTLR_TRACE")]
+ protected virtual void EnterRule_synpred6_MutexCLexer_fragment() {}
+ [Conditional("ANTLR_TRACE")]
+ protected virtual void LeaveRule_synpred6_MutexCLexer_fragment() {}
+
+ // $ANTLR start synpred6_MutexCLexer
+ public void synpred6_MutexCLexer_fragment()
+ {
+ EnterRule_synpred6_MutexCLexer_fragment();
+ EnterRule("synpred6_MutexCLexer_fragment", 16);
+ TraceIn("synpred6_MutexCLexer_fragment", 16);
+ try
+ {
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:1:120: ( IDENTIFIER )
+ DebugEnterAlt(1);
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:1:120: IDENTIFIER
+ {
+ DebugLocation(1, 120);
+ mIDENTIFIER(); if (state.failed) return;
+
+ }
+
+ }
+ finally
+ {
+ TraceOut("synpred6_MutexCLexer_fragment", 16);
+ LeaveRule("synpred6_MutexCLexer_fragment", 16);
+ LeaveRule_synpred6_MutexCLexer_fragment();
+ }
+ }
+ // $ANTLR end synpred6_MutexCLexer
+ [Conditional("ANTLR_TRACE")]
+ protected virtual void EnterRule_synpred7_MutexCLexer_fragment() {}
+ [Conditional("ANTLR_TRACE")]
+ protected virtual void LeaveRule_synpred7_MutexCLexer_fragment() {}
+
+ // $ANTLR start synpred7_MutexCLexer
+ public void synpred7_MutexCLexer_fragment()
+ {
+ EnterRule_synpred7_MutexCLexer_fragment();
+ EnterRule("synpred7_MutexCLexer_fragment", 17);
+ TraceIn("synpred7_MutexCLexer_fragment", 17);
+ try
+ {
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:1:131: ( LETTER )
+ DebugEnterAlt(1);
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:
+ {
+ DebugLocation(1, 131);
+ if ((input.LA(1)>='A' && input.LA(1)<='Z')||input.LA(1)=='_'||(input.LA(1)>='a' && input.LA(1)<='z'))
+ {
+ input.Consume();
+ state.failed=false;
+ }
+ else
+ {
+ if (state.backtracking>0) {state.failed=true; return;}
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ DebugRecognitionException(mse);
+ Recover(mse);
+ throw mse;
+ }
+
+
+ }
+
+ }
+ finally
+ {
+ TraceOut("synpred7_MutexCLexer_fragment", 17);
+ LeaveRule("synpred7_MutexCLexer_fragment", 17);
+ LeaveRule_synpred7_MutexCLexer_fragment();
+ }
+ }
+ // $ANTLR end synpred7_MutexCLexer
+ [Conditional("ANTLR_TRACE")]
+ protected virtual void EnterRule_synpred8_MutexCLexer_fragment() {}
+ [Conditional("ANTLR_TRACE")]
+ protected virtual void LeaveRule_synpred8_MutexCLexer_fragment() {}
+
+ // $ANTLR start synpred8_MutexCLexer
+ public void synpred8_MutexCLexer_fragment()
+ {
+ EnterRule_synpred8_MutexCLexer_fragment();
+ EnterRule("synpred8_MutexCLexer_fragment", 18);
+ TraceIn("synpred8_MutexCLexer_fragment", 18);
+ try
+ {
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:1:138: ( HEX_DIGIT )
+ DebugEnterAlt(1);
+ // D:\\wissen\\csharp\\GreedyStringTiling\\CTokenizer\\MutexCLexer.g:
+ {
+ DebugLocation(1, 138);
+ if ((input.LA(1)>='0' && input.LA(1)<='9')||(input.LA(1)>='A' && input.LA(1)<='F')||(input.LA(1)>='a' && input.LA(1)<='f'))
+ {
+ input.Consume();
+ state.failed=false;
+ }
+ else
+ {
+ if (state.backtracking>0) {state.failed=true; return;}
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ DebugRecognitionException(mse);
+ Recover(mse);
+ throw mse;
+ }
+
+
+ }
+
+ }
+ finally
+ {
+ TraceOut("synpred8_MutexCLexer_fragment", 18);
+ LeaveRule("synpred8_MutexCLexer_fragment", 18);
+ LeaveRule_synpred8_MutexCLexer_fragment();
+ }
+ }
+ // $ANTLR end synpred8_MutexCLexer
+
+ #region Synpreds
+ private bool EvaluatePredicate(System.Action fragment)
+ {
+ bool success = false;
+ state.backtracking++;
+ try { DebugBeginBacktrack(state.backtracking);
+ int start = input.Mark();
+ try
+ {
+ fragment();
+ }
+ catch ( RecognitionException re )
+ {
+ System.Console.Error.WriteLine("impossible: "+re);
+ }
+ success = !state.failed;
+ input.Rewind(start);
+ } finally { DebugEndBacktrack(state.backtracking, success); }
+ state.backtracking--;
+ state.failed=false;
+ return success;
+ }
+ #endregion Synpreds
+
+
+ #region DFA
+
+ protected override void InitDFAs()
+ {
+ base.InitDFAs();
+ }
+
+
+ #endregion
+
+}
31 CTokenizer/MutexCLexer.g
View
@@ -0,0 +1,31 @@
+lexer grammar MutexCLexer;
+
+options {
+ language = CSharp2;
+ filter = true;
+ k = 2;
+}
+
+
+CONST_MODIFIER
+ : 'const';
+
+POINTER_DATATYPE
+ : (FLOAT_DATATYPE | INTEGER_DATATYPE | VOID_DATATYPE) ' '* '*'+;
+
+VOID_DATATYPE : 'void';
+FLOAT_DATATYPE : 'float' | 'double';
+
+INTEGER_DATATYPE : (SIGNED_UNSIGNED)? ('short' | 'int' | 'long' | 'char') ;
+
+SIGNED_UNSIGNED : 'signed' | 'unsigned';
+
+IDENTIFIER
+ : LETTER (LETTER | DIGIT)*;
+
+LETTER : 'A'..'Z' | 'a'..'z' | '_';
+
+HEX_DIGIT : DIGIT | 'a'..'f' | 'A'..'F';
+
+DIGIT : '0'..'9';
+
9 CTokenizer/MutexCLexer.tokens
View
@@ -0,0 +1,9 @@
+DIGIT=4
+FLOAT_DATATYPE=5
+HEX_DIGIT=6
+IDENTIFIER=7
+INTEGER_DATATYPE=8
+LETTER=9
+POINTER_DATATYPE=10
+SIGNED_UNSIGNED=11
+VOID_DATATYPE=12
36 CTokenizer/Properties/AssemblyInfo.cs
View
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// Allgemeine Informationen über eine Assembly werden über die folgenden
+// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
+// die mit einer Assembly verknüpft sind.
+[assembly: AssemblyTitle("CTokenizer")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("CTokenizer")]
+[assembly: AssemblyCopyright("Copyright © 2012")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
+// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
+// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest.
+[assembly: ComVisible(false)]
+
+// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
+[assembly: Guid("85baf819-13d4-4c6d-8c21-cef0927be102")]
+
+// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
+//
+// Hauptversion
+// Nebenversion
+// Buildnummer
+// Revision
+//
+// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
+// übernehmen, indem Sie "*" eingeben:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
59 CTokenizer/TokenWrapper.cs
View
@@ -0,0 +1,59 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Antlr.Runtime;
+
+namespace CTokenizer
+{
+ /// <summary>
+ /// wrapper around IToken to override Equals.
+ /// Needed to make it work with GSTToken / GSTAlgorithm
+ /// </summary>
+ public class TokenWrapper
+ {
+ /// <summary>
+ /// the saved token object from ANTLR lexers
+ /// </summary>
+ public IToken Token { get; private set; }
+
+ public TokenWrapper(IToken token)
+ {
+ Token = token;
+ }
+
+ /// <summary>
+ /// compares for value equality using the token's Type
+ /// </summary>
+ /// <param name="obj"></param>
+ /// <returns></returns>
+ public override bool Equals(object obj)
+ {
+ if (obj == null || GetType() != obj.GetType())
+ {
+ return false;
+ }
+
+ var other = (TokenWrapper) obj;
+
+ if (null == Token && null == other.Token)
+ return true;
+
+ if (null == Token ||
+ null == other.Token)
+ return false;
+
+ return other.Token.Type == Token.Type;
+ }
+
+ public override int GetHashCode()
+ {
+ return null == Token ? GetType().GetHashCode() : Token.GetHashCode();
+ }
+
+ public override string ToString()
+ {
+ return Token.Text;
+ }
+ }
+}
70 GSTConsole/GSTConsole.csproj
View
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{D78F3B51-FF8B-4F9D-857C-EDD078C2FBBC}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>GSTConsole</RootNamespace>
+ <AssemblyName>GSTConsole</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <TargetFrameworkProfile>Client</TargetFrameworkProfile>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+ <PlatformTarget>x86</PlatformTarget>
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+ <PlatformTarget>x86</PlatformTarget>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Antlr3.Runtime">
+ <HintPath>..\ThirdPartyLibs\Antlr3.Runtime.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\CTokenizer\CTokenizer.csproj">
+ <Project>{BEF91472-4566-4604-9DEB-3FDFA17E6048}</Project>
+ <Name>CTokenizer</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\GSTLibrary\GSTLibrary.csproj">
+ <Project>{B80B2459-2992-4F3A-A6C4-EE692EDA01FF}</Project>
+ <Name>GSTLibrary</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- 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.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
70 GSTConsole/Program.cs
View
@@ -0,0 +1,70 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using Antlr.Runtime;
+using CTokenizer;
+using GSTLibrary.tile;
+using GSTLibrary.token;
+
+namespace GSTConsole
+{
+ static class Program
+ {
+ private const string RelativePathToTestFiles = @"..\..\..\test";
+ private static GSTAlgorithm<GSTToken<TokenWrapper>> Algorithm;
+
+ static void Main(string[] args)
+ {
+ /*
+ var listA = GetTokenList(new MutexCLexer(new ANTLRStringStream("void main(void) { }")));
+ var listB = GetTokenList(new MutexCLexer(new ANTLRStringStream("void main(void) { }")));
+ /* */
+
+
+ var listA = GetTokenList(new MutexCLexer(new ANTLRFileStream(Path.Combine(RelativePathToTestFiles, "main-01.c"))));
+ var listB = GetTokenList(new MutexCLexer(new ANTLRFileStream(Path.Combine(RelativePathToTestFiles, "main-13.c"))));
+ /* */
+ Algorithm = new GSTAlgorithm<GSTToken<TokenWrapper>>(listA, listB)
+ {
+ MinimumMatchLength = 5
+ };
+
+
+ Algorithm.RunToCompletion();
+
+ Console.WriteLine("Similarity: {0}", Algorithm.Similarity);
+ /*
+ var fileStream = new ANTLRFileStream(@"test\main-01.c");
+
+ Lexer lexer = new MutexCLexer(fileStream);
+
+ var lexerType = lexer.GetType();
+ IToken myToken;
+
+ while(-1 != (myToken = lexer.NextToken()).Type)
+ {
+ Console.WriteLine("Lexer-Token: {0} => {1}",
+ myToken.Type.GetTokenName(lexerType),
+ myToken.Text);
+ }
+ /* */
+ Console.WriteLine("Finished Lexer run");
+ Console.ReadLine();
+ }
+
+ internal static GSTTokenList<GSTToken<TokenWrapper>> GetTokenList(Lexer lexer)
+ {
+ var list = new GSTTokenList<GSTToken<TokenWrapper>>();
+ IToken myToken;
+
+ while(-1 != (myToken = lexer.NextToken()).Type)
+ {
+ list.Add(new GSTToken<TokenWrapper>(new TokenWrapper(myToken)));
+ }
+
+ return list;
+ }
+ }
+}
36 GSTConsole/Properties/AssemblyInfo.cs
View
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// Allgemeine Informationen über eine Assembly werden über die folgenden
+// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
+// die mit einer Assembly verknüpft sind.
+[assembly: AssemblyTitle("GSTConsole")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("GSTConsole")]
+[assembly: AssemblyCopyright("Copyright © 2012")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
+// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
+// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest.
+[assembly: ComVisible(false)]
+
+// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
+[assembly: Guid("0db1624f-8c5f-44ab-8e6b-80c886e6ffc0")]
+
+// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
+//
+// Hauptversion
+// Nebenversion
+// Buildnummer
+// Revision
+//
+// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
+// übernehmen, indem Sie "*" eingeben:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
71 GSTLibrary/GSTLibrary.csproj
View
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{B80B2459-2992-4F3A-A6C4-EE692EDA01FF}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>GSTLibrary</RootNamespace>
+ <AssemblyName>GSTLibrary</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="nunit.framework, Version=2.5.8.10295, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\nunit.framework.dll</HintPath>
+ </Reference>
+ <Reference Include="nunit.mocks, Version=2.5.8.10295, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\nunit.mocks.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="exception\GSTException.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="test\tile\GSTAlgorithmTest.cs" />
+ <Compile Include="test\tile\TileTest.cs" />
+ <Compile Include="test\token\GSTTokenTest.cs" />
+ <Compile Include="tile\GSTAlgorithm.cs" />
+ <Compile Include="tile\Tile.cs" />
+ <Compile Include="token\GSTHelper.cs" />
+ <Compile Include="token\GSTToken.cs" />
+ <Compile Include="token\GSTTokenList.cs" />
+ </ItemGroup>
+ <ItemGroup />
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- 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.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
36 GSTLibrary/Properties/AssemblyInfo.cs
View
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// Allgemeine Informationen über eine Assembly werden über die folgenden
+// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
+// die mit einer Assembly verknüpft sind.
+[assembly: AssemblyTitle("GSTLibrary")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("GSTLibrary")]
+[assembly: AssemblyCopyright("Copyright © 2012")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
+// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
+// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest.
+[assembly: ComVisible(false)]
+
+// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
+[assembly: Guid("517f16ab-9d0e-4ac4-ab89-882e9b935d17")]
+
+// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
+//
+// Hauptversion
+// Nebenversion
+// Buildnummer
+// Revision
+//
+// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
+// übernehmen, indem Sie "*" eingeben:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
18 GSTLibrary/exception/GSTException.cs
View
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace GSTLibrary.exception
+{
+ /// <summary>
+ /// used to keep the thrown exception consistent with the interface
+ /// </summary>
+ public class GSTException : Exception
+ {
+ public GSTException(string msg) : base (msg)
+ {
+
+ }
+ }
+}
214 GSTLibrary/test/tile/GSTAlgorithmTest.cs
View
@@ -0,0 +1,214 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using GSTLibrary.tile;
+using GSTLibrary.token;
+using NUnit.Framework;
+
+namespace GSTLibrary.test.tile
+{
+ [TestFixture]
+ public class GSTAlgorithmTest
+ {
+ private GSTAlgorithm<GSTToken<char>> Algorithm;
+
+ [SetUp]
+ public void SetUp()
+ {
+ var listA = GSTHelper.FromString("Hallo");
+ var listB = GSTHelper.FromString("Hallo");
+
+ Algorithm = new GSTAlgorithm<GSTToken<char>>(listA, listB)
+ {
+ MinimumMatchLength = 3
+ };
+ }
+
+
+ [Test]
+ public void InitialState()
+ {
+ Assert.False(Algorithm.Finished);
+ Assert.AreEqual(0, Algorithm.Tiles.Count(), "tiles not empty");
+ }
+
+ [Test]
+ public void DoOneRun()
+ {
+ Algorithm.DoOneRun();
+ Assert.True(Algorithm.Tiles.Count() == 1, "no matching tiles found");
+
+ var foundTile = Algorithm.Tiles.FirstOrDefault();
+
+ Assert.NotNull(foundTile, "no tile found");
+ Assert.True("Hallo".ToCharTile(0,0).EqualsValue(foundTile));
+ }
+
+ [Test]
+ public void TwoRunsNeededToFinishDefaultSet()
+ {
+ Algorithm.DoOneRun();
+ Algorithm.DoOneRun();
+ Assert.True(Algorithm.Finished, "algorithm not finished");
+ }
+
+ [Test]
+ public void TestIsInRange()
+ {
+ Assert.True(GSTAlgorithm<GSTToken>.IsInRange(5, 1, 10), "most basic");
+ Assert.False(GSTAlgorithm<GSTToken>.IsInRange(5, 3, 4), "above range");
+ Assert.False(GSTAlgorithm<GSTToken>.IsInRange(5, 6, 7), "below range");
+ Assert.True(GSTAlgorithm<GSTToken>.IsInRange(5, 3, 5), "upper edge");
+ Assert.True(GSTAlgorithm<GSTToken>.IsInRange(5, 5, 7), "lower edge");
+
+ }
+
+ [Test]
+ public void TwoTilesInString()
+ {
+ Algorithm = new GSTAlgorithm<GSTToken<char>>(
+ GSTHelper.FromString("Hallo Welt! Wie du mir gefällst!"),
+ GSTHelper.FromString("Hallo Welt?ASDF Wie du mir gefällst_"))
+ {
+ MinimumMatchLength = 5
+ };
+
+ Algorithm.DoOneRun();
+
+ Assert.AreEqual(1, Algorithm.Tiles.Count(), "no matching tiles found");
+
+ var tile = Algorithm.Tiles.First();
+
+ Assert.True(" Wie du mir gefällst".ToCharTile(11, 15).EqualsValue(tile));
+
+ Algorithm.DoOneRun();
+ Assert.AreEqual(2, Algorithm.Tiles.Count(), "too few tiles found");
+ }
+
+ public void DontBeCaseInsensitive()
+ {
+ Algorithm = new GSTAlgorithm<GSTToken<char>>(
+ GSTHelper.FromString("hallo welt! wie du mir gefällst!"),
+ GSTHelper.FromString("Hallo Welt?ASDF Wie du mir gefällst_"))
+ {
+ MinimumMatchLength = 5
+ };
+
+ Algorithm.RunToCompletion();
+
+ Assert.AreEqual(0, Algorithm.Tiles.Count(), "found UNEXPECTED match");
+
+
+ }
+
+ [Test]
+ public void DontMatchTileTwice()
+ {
+ Algorithm = new GSTAlgorithm<GSTToken<char>>(
+ GSTHelper.FromString("Hallo Welt!"),
+ GSTHelper.FromString("Hallo Welt!ASDF Hallo Welt!"))
+ {
+ MinimumMatchLength = 5
+ };
+
+ Algorithm.RunToCompletion();
+
+
+ Assert.AreEqual(1, Algorithm.Tiles.Count(), "matched a tile more than once");
+ }
+
+ [Test]
+ public void RunToCompletion()
+ {
+ Assert.False(Algorithm.Finished);
+ Algorithm.RunToCompletion();
+
+ Assert.True(Algorithm.Finished);
+ }
+
+ [Test]
+ public void MatchesTwoDifferentTiles()
+ {
+ Algorithm = new GSTAlgorithm<GSTToken<char>>(
+ GSTHelper.FromString("Hallo Welt! Du bist Deutschland"),
+ GSTHelper.FromString("*BlaBlub*Hallo Welt!ASDF Du bist Deutschland!"))
+ {
+ MinimumMatchLength = 5
+ };
+ Algorithm.RunToCompletion();
+
+ Assert.AreEqual(2, Algorithm.Tiles.Count(), "unexpected number of matches");
+ var listTiles = Algorithm.Tiles.ToList();
+
+ Assert.True(" Du bist Deutschland".ToCharTile(11 ,24).EqualsValue(listTiles[0]), "first tile does not match");
+ Assert.True("Hallo Welt!".ToCharTile(0, 9).EqualsValue(listTiles[1]), "second tile does not match");
+ }
+
+ [Test]
+ public void HandlesEscapeSequences()
+ {
+ Algorithm = new GSTAlgorithm<GSTToken<char>>(
+ GSTHelper.FromString("Hallo Welt!\r\n\t Du bist Deutschland"),
+ GSTHelper.FromString("*Bla\nBlub*Hallo Welt!\tAS\rDF Du bist Deutschland!"))
+ {
+ MinimumMatchLength = 5
+ };
+
+ Algorithm.RunToCompletion();
+
+ Assert.AreEqual(2, Algorithm.Tiles.Count(), "unexpected number of matches");
+ var listTiles = Algorithm.Tiles.ToList();
+
+ Assert.True(" Du bist Deutschland".ToCharTile(14, 27).EqualsValue(listTiles[0]), "first tile does not match");
+ Assert.True("Hallo Welt!".ToCharTile(0, 10).EqualsValue(listTiles[1]), "second tile does not match");
+ }
+
+ [Test]
+ public void SimilarityCalculation()
+ {
+ Algorithm = new GSTAlgorithm<GSTToken<char>>(
+ GSTHelper.FromString("Hallo Welt!\r\n\t Du bist Deutschland"),
+ GSTHelper.FromString("*Bla\nBlub*Hallo Welt!\tAS\rDF Du bist Deutschland!"))
+ {
+ MinimumMatchLength = 5
+ };
+
+ Algorithm.RunToCompletion();
+
+ Assert.AreEqual(91, Algorithm.Similarity, "similarity has unexpected value");
+ }
+
+ [Test]
+ public void OverlappingMatchesOfSameSize()
+ {
+ Algorithm = new GSTAlgorithm<GSTToken<char>>(
+ GSTHelper.FromString("Hallo Welt!"),
+ GSTHelper.FromString("allo Welt!|SEP|Hallo Welt"))
+ {
+ MinimumMatchLength = 5
+ };
+
+ Algorithm.RunToCompletion();
+
+ Assert.AreEqual(1, Algorithm.Tiles.Count(), "too many tiles found");
+ /* */
+ }
+
+ [Test]
+ public void DoNotMatchTwoIdenticalTilesOnA()
+ {
+ Algorithm = new GSTAlgorithm<GSTToken<char>>(
+ GSTHelper.FromString("Hallo Welt! Hallo Welt!"),
+ GSTHelper.FromString("Hallo Welt!"))
+ {
+ MinimumMatchLength = 5
+ };
+
+ Algorithm.RunToCompletion();
+
+ Assert.AreEqual(1, Algorithm.Tiles.Count());
+ }
+ }
+}
40 GSTLibrary/test/tile/TileTest.cs
View
@@ -0,0 +1,40 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using GSTLibrary.tile;
+using GSTLibrary.token;
+using NUnit.Framework;
+
+namespace GSTLibrary.test.tile
+{
+ [TestFixture]
+ public class TileTest
+ {
+ [Test]
+ public void EqualsTokensAndIndexOnA()
+ {
+ var tile1 = new Tile<GSTToken<char>> (GSTHelper.FromString("Hallo"), 1, 5);
+ var tile2 = new Tile<GSTToken<char>>(GSTHelper.FromString("Hallo"), 1, 5);
+
+ Assert.True(tile1.EqualsTokensAndIndexOnA(tile2), "identical tiles do not match");
+
+ tile2 = new Tile<GSTToken<char>>(GSTHelper.FromString("Hallo"), 1, 10);
+
+ Assert.True(tile1.EqualsTokensAndIndexOnA(tile2), "IndexOnB influences behaviour");
+ }
+
+ [Test]
+ public void EqualsValue()
+ {
+ var tile1 = new Tile<GSTToken<char>>(GSTHelper.FromString("Hallo"), 1, 5);
+ var tile2 = new Tile<GSTToken<char>>(GSTHelper.FromString("Hallo"), 1, 5);
+
+ Assert.True(tile1.EqualsValue(tile2), "identical tiles do not match");
+
+ tile2 = new Tile<GSTToken<char>>(GSTHelper.FromString("Hallo"), 1, 10);
+
+ Assert.False(tile1.EqualsValue(tile2), "IndexOnB does not influence behaviour");
+ }
+ }
+}
33 GSTLibrary/test/token/GSTTokenTest.cs
View
@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using GSTLibrary.token;
+using NUnit.Framework;
+
+namespace GSTLibrary.test.token
+{
+ [TestFixture]
+ public class GSTTokenTest
+ {
+ private GSTTokenList<GSTToken<char>> ListA;
+ private GSTTokenList<GSTToken<char>> ListB;
+
+ [SetUp]
+ public void SetUp()
+ {
+ ListA = GSTHelper.FromString("Hallo");
+ ListB = GSTHelper.FromString("Hallo");
+ }
+
+ [Test]
+ public void Equals()
+ {
+ for(int i = 0; i < ListA.Count; i++)
+ {
+ Assert.True(ListA[i].EqualsTokenValue(ListB[i]), "values did not match. A {0}, B{1}", ListA[i], ListB[i]);
+ Assert.True(ListA[i] != ListB[i]);
+ }
+ }
+ }
+}
321 GSTLibrary/tile/GSTAlgorithm.cs
View
@@ -0,0 +1,321 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using GSTLibrary.exception;
+using GSTLibrary.token;
+
+namespace GSTLibrary.tile
+{
+ /// <summary>
+ /// implements the greedy string tiling algorithm
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ public class GSTAlgorithm<T> where T : GSTToken
+ {
+ /// <summary>
+ /// the default minimum match length used
+ /// </summary>
+ public const int DEFAULT_MINIMUM_MATCH_LENGTH = 12;
+
+ /// <summary>
+ /// internal storage for found Tiles
+ /// </summary>
+ private readonly List<Tile<T>> ListTiles = new List<Tile<T>>();
+
+ /// <summary>
+ /// field to hold the MinimumMatchLength
+ /// </summary>
+ private int MML;
+
+ /// <summary>
+ /// the length of the last found match
+ /// </summary>
+ private int LastMaximumMatch;
+
+ /// <summary>
+ /// the token list of stream A
+ /// </summary>
+ public GSTTokenList<T> ListA { get; private set; }
+
+ /// <summary>
+ /// the token list of stream B
+ /// </summary>
+ public GSTTokenList<T> ListB { get; private set; }
+
+ /// <summary>
+ /// returns the Tiles found so far
+ /// </summary>
+ public IEnumerable<Tile<T>> Tiles
+ {
+ get { return ListTiles.AsEnumerable(); }
+ }
+
+ /// <summary>
+ /// returns the Tiles that were matched during the last run
+ /// </summary>
+ public IEnumerable<Tile<T>> TilesMatchedInLastRun { get; private set; }
+
+ /// <summary>
+ /// returns true if no more runs are needed
+ /// </summary>
+ public bool Finished
+ {
+ get { return LastMaximumMatch <= MinimumMatchLength; }
+ }
+
+ /// <summary>
+ /// the minimum length of a tile to be considered a match
+ /// </summary>
+ public int MinimumMatchLength
+ {
+ get
+ {
+ return MML;
+ }
+ set
+ {
+ MML = value;
+ // this needs to be set to be greater than MML
+ // because else the initial state of the algorithmB
+ // would be FINISHED
+ LastMaximumMatch = value + 1;
+ }
+ }
+
+ /// <summary>
+ /// returns the similarity between the token streams.
+ ///
+ /// Similarity is calculated by adding up the length of all the found tiles and dividing it
+ /// by the length of the shorter list
+ /// </summary>
+ public int Similarity
+ {
+ get
+ {
+ double lenList = ListA.Count < ListB.Count ? ListA.Count : ListB.Count;
+ double lenTiles = Tiles.Select(tile => tile.Tokens.Count()).Sum();
+
+ Console.WriteLine("list length: {0}, {1}", ListA.Count, ListB.Count);
+ Console.WriteLine("simil: {0} / {1}", lenTiles, lenList);
+ return (int) (100 * lenTiles / lenList);
+ }
+ }
+
+ public GSTAlgorithm(GSTTokenList<T> a, GSTTokenList<T> b)
+ {
+ if (null == a)
+ throw new ArgumentNullException("a");
+
+ if (null == b)
+ throw new ArgumentNullException("b");
+
+
+ LastMaximumMatch = DEFAULT_MINIMUM_MATCH_LENGTH + 1;
+
+ MinimumMatchLength = DEFAULT_MINIMUM_MATCH_LENGTH;
+
+ ListA = a;
+ ListB = b;
+ }
+
+ /// <summary>