-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
firebie
committed
Nov 27, 2010
0 parents
commit d9b15f4
Showing
13 changed files
with
779 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Parser/bin/ | ||
Parser/obj/ | ||
Parser/time.txt | ||
|
||
TinyAcc/bin/ | ||
TinyAcc/obj/ | ||
TinyAcc.suo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using System; | ||
using Nemerle.Collections; | ||
using Nemerle.Text; | ||
using Nemerle.Utility; | ||
|
||
using Nemerle.Peg; | ||
|
||
namespace tinyacc | ||
{ | ||
/// <summary> | ||
/// Description of Ast. | ||
/// </summary> | ||
public enum OperationType | ||
{ | ||
| Debit | ||
| Credit | ||
} | ||
public variant Ast : Located | ||
{ | ||
| Rate | ||
{ | ||
From : string; | ||
To : string; | ||
Course : double; | ||
} | ||
|
||
| Account | ||
{ | ||
Name : string; | ||
Currency : string; | ||
Balance : double; | ||
} | ||
|
||
| Operation | ||
{ | ||
OperationType : OperationType; | ||
Amount : double; | ||
Currency : string; | ||
AccountName : string; | ||
Name : string; | ||
} | ||
|
||
| Bad | ||
|
||
public GetMessage(msg : string) : string | ||
{ | ||
def pos = Location.StartPos; | ||
def len = Location.EndPos - Location.StartPos; | ||
$"$(Location.Source.FileName)$(Location.StartLineColumn.ToString()):[$pos:$len]: $msg" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
using Nemerle.Collections; | ||
using Nemerle.Text; | ||
using Nemerle.Utility; | ||
|
||
using Nemerle.Peg; | ||
|
||
namespace tinyacc | ||
{ | ||
[PegGrammar(start, | ||
grammar | ||
{ | ||
any = ['\u0000'..'\uFFFF']; | ||
|
||
#region White space | ||
|
||
whitespace = [Zs] | ||
/ '\t' | ||
/ '\v' /* vertial tab */ | ||
/ '\f'; /* form feed */ | ||
|
||
#endregion | ||
|
||
#region Line terminators | ||
|
||
newLineCharacter = '\n' | ||
/ '\r' | ||
/ '\u2028' /* line separator */ | ||
/ '\u2029'; /* paragraph separator */ | ||
newLine = ("\r\n" / newLineCharacter); | ||
|
||
#endregion | ||
|
||
#region Comments | ||
|
||
singleLineComment = "//" (!newLineCharacter any)*; | ||
delimitedComment = "/*" (!"*/" any)* "*/"; | ||
comment = singleLineComment / delimitedComment; | ||
|
||
#endregion | ||
|
||
#region Spacer | ||
|
||
space : Void = whitespace / newLine / comment; | ||
|
||
semicolon : Void = ";" space*; | ||
|
||
#endregion | ||
|
||
#region Identifiers | ||
|
||
decimalDigit = ['0'..'9']; | ||
combiningCharacter = [Mn, Mc]; | ||
decimalDigitCharacter = [Nd]; | ||
connectingCharacter = [Pc]; | ||
formattingCharacter = [Cf]; | ||
letterCharacter = [Lu, Ll, Lt, Lm, Lo, Nl] / '$' / '+' / '-'; | ||
|
||
#endregion | ||
|
||
identifierStartCharacter = letterCharacter / "_"; | ||
identifierPartCharacters = letterCharacter / decimalDigitCharacter / connectingCharacter / combiningCharacter / formattingCharacter; | ||
identifierBody = identifierStartCharacter identifierPartCharacters*; | ||
identifier = identifierBody; | ||
|
||
name = identifier; | ||
|
||
number = decimalDigit* "." decimalDigit+ / decimalDigit*; | ||
|
||
accountName = name; | ||
currencyName = name; | ||
operationName = name; | ||
|
||
rate : Ast = "rate" space+ currencyName space+ currencyName space+ number semicolon; | ||
account : Ast = "account" space+ currencyName space+ number space+ accountName space* semicolon; | ||
creditOrDebit : Ast = ('+'/ '-') space* number space+ currencyName space+ accountName space+ operationName space* semicolon; | ||
badRecord : Ast = (!semicolon any)* semicolon; | ||
|
||
definition : Ast = (rate / account / creditOrDebit / badRecord) space*; | ||
|
||
start : List[Ast] = space* definition* !any; | ||
})] | ||
|
||
public class AccParser | ||
{ | ||
badRecord(_ : NToken) : Ast | ||
{ | ||
Ast.Bad() | ||
} | ||
|
||
rate(_ : NToken, currencyNameFrom : NToken, currencyNameTo : NToken, course : NToken) : Ast | ||
{ | ||
Ast.Rate(GetText(currencyNameFrom), GetText(currencyNameTo), Convert.ToDouble(GetText(course))); | ||
} | ||
|
||
account(_ : NToken, currencyName : NToken, balance : NToken, accountName : NToken) : Ast | ||
{ | ||
Ast.Account(GetText(accountName), GetText(currencyName), Convert.ToDouble(GetText(balance))); | ||
} | ||
|
||
creditOrDebit(operation : NToken, amount : NToken, currencyName : NToken, accountName : NToken, operationName : NToken) : Ast | ||
{ | ||
def op = match(GetText(operation)) | ||
{ | ||
| "-" => OperationType.Debit | ||
| "+" => OperationType.Credit | ||
| _ => OperationType.Credit | ||
} | ||
|
||
Ast.Operation(op, Convert.ToDouble(GetText(amount)), GetText(currencyName), GetText(accountName), GetText(operationName)); | ||
} | ||
|
||
definition(rec : Ast) : Ast | ||
{ | ||
rec | ||
} | ||
|
||
start(recs : List[Ast] ) : List[Ast] | ||
{ | ||
recs | ||
} | ||
|
||
//semicolon(semicol : NToken) : NToken | ||
//{ | ||
// semicol | ||
//} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<NoStdLib>true</NoStdLib> | ||
<Nemerle Condition=" '$(Nemerle)' == '' ">$(ProgramFiles)\Nemerle</Nemerle> | ||
<Name>Parser</Name> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProductVersion>8.0.30703</ProductVersion> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
<ProjectGuid>{4e951655-3dff-4737-a348-0779570f48c0}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>Parser</RootNamespace> | ||
<AssemblyName>Parser</AssemblyName> | ||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<DocumentationFile>bin\Release\Parser.xml</DocumentationFile> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="mscorlib" /> | ||
<Reference Include="Nemerle.Peg, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> | ||
<Name>Nemerle.Peg</Name> | ||
<AssemblyName>Nemerle.Peg.dll</AssemblyName> | ||
<HintPath>..\..\..\..\..\MyUsers\programs\manysrc\dev\nemerle\src\snippets\peg-parser\Nemerle.Peg\bin\Debug\Nemerle.Peg.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core"> | ||
<RequiredTargetFramework>3.5</RequiredTargetFramework> | ||
</Reference> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="Nemerle"> | ||
<SpecificVersion>False</SpecificVersion> | ||
<HintPath>$(Nemerle)\Nemerle.dll</HintPath> | ||
</Reference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Ast.n"> | ||
<SubType>Code</SubType> | ||
</Compile> | ||
<Compile Include="Parser.n"> | ||
<SubType>Code</SubType> | ||
</Compile> | ||
<Compile Include="Properties\AssemblyInfo.n" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Folder Include="Properties\" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<MacroReference Include="Nemerle.Peg.Macros, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> | ||
<Name>Nemerle.Peg.Macros</Name> | ||
<AssemblyName>Nemerle.Peg.Macros.dll</AssemblyName> | ||
<HintPath>..\..\..\..\..\MyUsers\programs\manysrc\dev\nemerle\src\snippets\peg-parser\Nemerle.Peg.Macros\bin\Debug\Nemerle.Peg.Macros.dll</HintPath> | ||
<Private>False</Private> | ||
</MacroReference> | ||
</ItemGroup> | ||
<Import Project="$(Nemerle)\Nemerle.MSBuild.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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("Parser")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("Parser")] | ||
[assembly: AssemblyCopyright("Copyright © 2010")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("e0d7e9dc-2c58-4f9c-a0a7-d76208490a15")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 10.00 | ||
# Visual Studio 2008 | ||
Project("{EDCC3B85-0BAD-11DB-BC1A-00112FDE8B61}") = "Parser", "Parser\Parser.nproj", "{4E951655-3DFF-4737-A348-0779570F48C0}" | ||
EndProject | ||
Project("{EDCC3B85-0BAD-11DB-BC1A-00112FDE8B61}") = "TinyAcc", "TinyAcc\TinyAcc.nproj", "{FBDDD4EE-0D10-4DD6-A8AF-213FAC1834EE}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{4E951655-3DFF-4737-A348-0779570F48C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{4E951655-3DFF-4737-A348-0779570F48C0}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{4E951655-3DFF-4737-A348-0779570F48C0}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{4E951655-3DFF-4737-A348-0779570F48C0}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{FBDDD4EE-0D10-4DD6-A8AF-213FAC1834EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{FBDDD4EE-0D10-4DD6-A8AF-213FAC1834EE}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{FBDDD4EE-0D10-4DD6-A8AF-213FAC1834EE}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{FBDDD4EE-0D10-4DD6-A8AF-213FAC1834EE}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
Oops, something went wrong.