Skip to content
Browse files

Initial commit.

  • Loading branch information...
0 parents commit ea7a007985362dd41ab2da027dec0422374eb422 @tomlokhorst committed Apr 15, 2011
9 .gitignore
@@ -0,0 +1,9 @@
+# Vim swap file
+*.swp
+
+# Visual studio files
+[Oo]bj
+[Bb]in
+*.user
+*.suo
+
63 Coffee/Coffee.fsproj
@@ -0,0 +1,63 @@
+<?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>{d294906b-de5d-43cb-b88f-8799f2096730}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <RootNamespace>Coffee</RootNamespace>
+ <AssemblyName>Coffee</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <TargetFrameworkProfile>Client</TargetFrameworkProfile>
+ <Name>Coffee</Name>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <Tailcalls>false</Tailcalls>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <WarningLevel>3</WarningLevel>
+ <PlatformTarget>x86</PlatformTarget>
+ <DocumentationFile>bin\Debug\Coffee.XML</DocumentationFile>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <Tailcalls>true</Tailcalls>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <WarningLevel>3</WarningLevel>
+ <PlatformTarget>x86</PlatformTarget>
+ <DocumentationFile>bin\Release\Coffee.XML</DocumentationFile>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="mscorlib" />
+ <Reference Include="FSharp.Core" />
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Numerics" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Program.fs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\CoffeeSharp\CoffeeSharp.csproj">
+ <Name>CoffeeSharp</Name>
+ <Project>{b269febd-f9ce-4c90-b26c-c2c42f3be375}</Project>
+ <Private>True</Private>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildExtensionsPath32)\FSharp\1.0\Microsoft.FSharp.Targets" Condition="!Exists('$(MSBuildBinPath)\Microsoft.Build.Tasks.v4.0.dll')" />
+ <Import Project="$(MSBuildExtensionsPath32)\..\Microsoft F#\v4.0\Microsoft.FSharp.Targets" Condition=" Exists('$(MSBuildBinPath)\Microsoft.Build.Tasks.v4.0.dll')" />
+ <!-- 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>
6 Coffee/Program.fs
@@ -0,0 +1,6 @@
+open CoffeeSharp
+
+let cse = new CoffeeScriptEngine()
+
+let main =
+ cse.Eval "console.log 'Hello, World!'"
42 CoffeeSharp.sln
@@ -0,0 +1,42 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CoffeeSharp", "CoffeeSharp\CoffeeSharp.csproj", "{B269FEBD-F9CE-4C90-B26C-C2C42F3BE375}"
+EndProject
+Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Coffee", "Coffee\Coffee.fsproj", "{D294906B-DE5D-43CB-B88F-8799F2096730}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Debug|Mixed Platforms = Debug|Mixed Platforms
+ Debug|x86 = Debug|x86
+ Release|Any CPU = Release|Any CPU
+ Release|Mixed Platforms = Release|Mixed Platforms
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {B269FEBD-F9CE-4C90-B26C-C2C42F3BE375}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B269FEBD-F9CE-4C90-B26C-C2C42F3BE375}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B269FEBD-F9CE-4C90-B26C-C2C42F3BE375}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {B269FEBD-F9CE-4C90-B26C-C2C42F3BE375}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {B269FEBD-F9CE-4C90-B26C-C2C42F3BE375}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {B269FEBD-F9CE-4C90-B26C-C2C42F3BE375}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B269FEBD-F9CE-4C90-B26C-C2C42F3BE375}.Release|Any CPU.Build.0 = Release|Any CPU
+ {B269FEBD-F9CE-4C90-B26C-C2C42F3BE375}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {B269FEBD-F9CE-4C90-B26C-C2C42F3BE375}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {B269FEBD-F9CE-4C90-B26C-C2C42F3BE375}.Release|x86.ActiveCfg = Release|Any CPU
+ {D294906B-DE5D-43CB-B88F-8799F2096730}.Debug|Any CPU.ActiveCfg = Debug|x86
+ {D294906B-DE5D-43CB-B88F-8799F2096730}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
+ {D294906B-DE5D-43CB-B88F-8799F2096730}.Debug|Mixed Platforms.Build.0 = Debug|x86
+ {D294906B-DE5D-43CB-B88F-8799F2096730}.Debug|x86.ActiveCfg = Debug|x86
+ {D294906B-DE5D-43CB-B88F-8799F2096730}.Debug|x86.Build.0 = Debug|x86
+ {D294906B-DE5D-43CB-B88F-8799F2096730}.Release|Any CPU.ActiveCfg = Release|x86
+ {D294906B-DE5D-43CB-B88F-8799F2096730}.Release|Mixed Platforms.ActiveCfg = Release|x86
+ {D294906B-DE5D-43CB-B88F-8799F2096730}.Release|Mixed Platforms.Build.0 = Release|x86
+ {D294906B-DE5D-43CB-B88F-8799F2096730}.Release|x86.ActiveCfg = Release|x86
+ {D294906B-DE5D-43CB-B88F-8799F2096730}.Release|x86.Build.0 = Release|x86
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
64 CoffeeSharp/CoffeeScriptEngine.cs
@@ -0,0 +1,64 @@
+using Jurassic;
+using Jurassic.Library;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.IO;
+
+namespace CoffeeSharp
+{
+ public class CoffeeScriptEngine
+ {
+ private ScriptEngine scriptEngine;
+
+ public CoffeeScriptEngine()
+ {
+ this.scriptEngine = new ScriptEngine();
+ scriptEngine.Execute(Resources.CoffeeScriptSource);
+ scriptEngine.Execute("coffeeScriptEval = CoffeeScript.eval;");
+ scriptEngine.Execute("coffeeScriptNodes = CoffeeScript.nodes;");
+ scriptEngine.Execute("coffeeScriptTokens = CoffeeScript.tokens;");
+ scriptEngine.Execute("coffeeScriptCompile = CoffeeScript.compile;");
+ }
+
+ public void Eval(string code, bool globals = false)
+ {
+ var options = new JsObject(scriptEngine);
+ options["globals"] = globals;
+
+ scriptEngine.SetGlobalValue("console", new Jurassic.Library.FirebugConsole(scriptEngine));
+ scriptEngine.CallGlobalFunction("coffeeScriptEval", code, options);
+ scriptEngine.Evaluate("delete console");
+ }
+
+ public string Nodes(string source)
+ {
+ return scriptEngine.CallGlobalFunction("coffeeScriptNodes", source).ToString();
+ }
+
+ public IEnumerable<Tuple<String, object>> Tokens(string code, bool rewrite = true)
+ {
+ var options = new JsObject(scriptEngine);
+ options["rewrite"] = rewrite;
+
+ var ts = (ArrayInstance)scriptEngine.CallGlobalFunction("coffeeScriptTokens", code, options);
+
+ foreach (var v in ts.ElementValues.Cast<ArrayInstance>())
+ yield return Tuple.Create((string)v[0], v[1]);
+ }
+
+ public string Compile(string code, bool bare = false)
+ {
+ var options = new JsObject(scriptEngine);
+ options["bare"] = bare;
+
+ return scriptEngine.CallGlobalFunction<string>("coffeeScriptCompile", code, options);
+ }
+
+ private class JsObject : ObjectInstance
+ {
+ public JsObject(ScriptEngine se) : base(se) { }
+ }
+ }
+}
68 CoffeeSharp/CoffeeSharp.csproj
@@ -0,0 +1,68 @@
+<?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>{B269FEBD-F9CE-4C90-B26C-C2C42F3BE375}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>CoffeeSharp</RootNamespace>
+ <AssemblyName>CoffeeSharp</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <TargetFrameworkProfile>Client</TargetFrameworkProfile>
+ </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="Jurassic">
+ <HintPath>..\Lib\Jurassic.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="CoffeeScriptEngine.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Resources.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DesignTime>True</DesignTime>
+ <DependentUpon>Resources.resx</DependentUpon>
+ </Compile>
+ </ItemGroup>
+ <ItemGroup>
+ <EmbeddedResource Include="Resources.resx">
+ <Generator>ResXFileCodeGenerator</Generator>
+ <LastGenOutput>Resources.Designer.cs</LastGenOutput>
+ </EmbeddedResource>
+ </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 CoffeeSharp/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+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("CoffeeSharp")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("CoffeeSharp")]
+[assembly: AssemblyCopyright("Copyright © 2011")]
+[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("99d5bb9d-2d42-4c8b-b1ff-d8e2727226e1")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.1.0")]
+[assembly: AssemblyFileVersion("1.0.1.0")]
79 CoffeeSharp/Resources.Designer.cs
@@ -0,0 +1,79 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.1
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace CoffeeSharp {
+ using System;
+
+
+ /// <summary>
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ /// </summary>
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources() {
+ }
+
+ /// <summary>
+ /// Returns the cached ResourceManager instance used by this class.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CoffeeSharp.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ /// <summary>
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to /**
+ /// * CoffeeScript Compiler v1.0.1
+ /// * http://coffeescript.org
+ /// *
+ /// * Copyright 2011, Jeremy Ashkenas
+ /// * Released under the MIT License
+ /// */
+ ///this.CoffeeScript=function(){function require(a){return require[a]}require[&quot;./helpers&quot;]=new function(){var a=this;(function(){var b,c;a.starts=function(a,b,c){return b===a.substr(c,b.length)},a.ends=function(a,b,c){var d;d=b.length;return b===a.substr(a.length-d-(c||0),d)},a.compact=function(a){var b,c,d,e;e=[];for(c=0,d=a.length;c&lt;d;c++)b=a[c],b&amp;&amp;e.push(b);return [rest of string was truncated]&quot;;.
+ /// </summary>
+ internal static string CoffeeScriptSource {
+ get {
+ return ResourceManager.GetString("CoffeeScriptSource", resourceCulture);
+ }
+ }
+ }
+}
130 CoffeeSharp/Resources.resx
130 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
27 LICENSE
@@ -0,0 +1,27 @@
+Copyright (c) 2011, Tom Lokhorst
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+3. Neither the name of the author nor the names of his contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
31 Lib/Jurassic.License.txt
@@ -0,0 +1,31 @@
+Microsoft Public License (Ms-PL)
+
+This license governs use of the accompanying software. If you use the software, you accept this license. If you do not accept the license, do not use the software.
+
+1. Definitions
+
+The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under U.S. copyright law.
+
+A "contribution" is the original software, or any additions or changes to the software.
+
+A "contributor" is any person that distributes its contribution under this license.
+
+"Licensed patents" are a contributor's patent claims that read directly on its contribution.
+
+2. Grant of Rights
+
+(A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
+
+(B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
+
+3. Conditions and Limitations
+
+(A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
+
+(B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically.
+
+(C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software.
+
+(D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license.
+
+(E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement.
BIN Lib/Jurassic.dll
Binary file not shown.
8 README.md
@@ -0,0 +1,8 @@
+CoffeeSharp
+===========
+
+A [CoffeeScript][1] compiler in .NET, build using the [Jurassic Javascript Compiler][2].
+
+
+[1]: http://coffeescript.org/
+[2]: http://jurassic.codeplex.com/

0 comments on commit ea7a007

Please sign in to comment.
Something went wrong with that request. Please try again.