Permalink
Browse files

Rename to ParseJS

  • Loading branch information...
1 parent cb35a59 commit 74c27c71c46e13c2736bf312737641acb21f45d7 @wycats committed Jan 9, 2012
View
@@ -1,6 +1,3 @@
source 'http://rubygems.org'
-# Specify your gem's dependencies in lattescript.gemspec
gemspec
-
-gem "kpeg", :git => "git://github.com/wycats/kpeg"
View
@@ -2,10 +2,10 @@
require "bundler/gem_tasks"
require "bundler/setup"
-file "lib/lattescript/grammar.kpeg.rb" => "lib/lattescript/grammar.kpeg" do
- sh "kpeg -f lib/lattescript/grammar.kpeg --stand-alone --debug"
+file "lib/parsejs/grammar.kpeg.rb" => "lib/parsejs/grammar.kpeg" do
+ sh "kpeg -f lib/parsejs/grammar.kpeg --stand-alone --debug"
end
-task :compile => "lib/lattescript/grammar.kpeg.rb"
+task :compile => "lib/parsejs/grammar.kpeg.rb"
task :default => :compile
View
@@ -1,11 +1,11 @@
-require "lattescript/version"
-require "lattescript/grammar.kpeg"
-require "lattescript/stringifier"
-require "lattescript/ast"
+require "parsejs/version"
+require "parsejs/grammar.kpeg"
+require "parsejs/stringifier"
+require "parsejs/ast"
-module LatteScript
+module ParseJS
def self.parse(string)
- parser = LatteScript::Parser.new(string)
+ parser = ParseJS::Parser.new(string)
parser.parse
parser.result
end
View
@@ -0,0 +1,13 @@
+require "parsejs/version"
+require "parsejs/grammar.kpeg"
+require "parsejs/stringifier"
+require "parsejs/ast"
+
+module ParseJS
+ def self.parse(string)
+ parser = ParseJS::Parser.new(string)
+ parser.parse
+ parser.result
+ end
+ # Your code goes here...
+end
@@ -1,4 +1,4 @@
-module LatteScript
+module ParseJS
module AST
class Node
def cuddly?
@@ -1,8 +1,8 @@
require "lattescript/visitor"
-module LatteScript
+module ParseJS
class CommentScanner < Visitor
- include LatteScript::AST
+ include ParseJS::AST
def initialize(*)
@current_comment = nil
@@ -1,6 +1,6 @@
-%% name = LatteScript::Parser
+%% name = ParseJS::Parser
-%% ast-location = ::LatteScript::AST
+%% ast-location = ::ParseJS::AST
%% program = ast Program(elements)
%% expression_statement = ast ExpressionStatement(expression)
%% block_statement = ast BlockStatement(statements)
@@ -1,7 +1,7 @@
require "lattescript/visitor"
require "json"
-module LatteScript
+module ParseJS
require "pp"
class Stringifier < Visitor
@@ -126,7 +126,7 @@ def visit_Literal(literal)
case val = literal.val
when nil
"null"
- when LatteScript::AST::Node
+ when ParseJS::AST::Node
accept val
else
val.inspect
@@ -1,3 +1,3 @@
-module LatteScript
+module ParseJS
VERSION = "0.0.1"
end
@@ -1,4 +1,4 @@
-module LatteScript
+module ParseJS
class Visitor
def accept(node)
visit(node)
@@ -29,7 +29,7 @@ def visit_Literal(literal)
case val = literal.val
when nil
"null"
- when LatteScript::AST::Node
+ when ParseJS::AST::Node
accept val
else
val
@@ -1,19 +1,20 @@
# -*- encoding: utf-8 -*-
-require File.expand_path('../lib/lattescript/version', __FILE__)
+$:.unshift File.expand_path("../lib", __FILE__)
+require "parsejs/version"
Gem::Specification.new do |gem|
- gem.authors = ["TODO: Write your name"]
+ gem.authors = ["Yehuda Katz"]
gem.email = ["wycats@gmail.com"]
- gem.description = %q{TODO: Write a gem description}
- gem.summary = %q{TODO: Write a gem summary}
+ gem.description = %q{ParseJS is a JavaScript parser written using KPeg}
+ gem.summary = %q{ParseJS parses JavaScript into a Ruby AST, suitable for preprocessing and other purposes. It also has work-in-progress support for extracting documentation from JavaScript}
gem.homepage = ""
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
gem.files = `git ls-files`.split("\n")
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
- gem.name = "lattescript"
+ gem.name = "parsejs"
gem.require_paths = ["lib"]
- gem.version = LatteScript::VERSION
+ gem.version = ParseJS::VERSION
gem.add_dependency "kpeg"
gem.add_dependency "yard"
@@ -1,4 +1,4 @@
-require "lattescript"
+require "parsejs"
require "digest"
require "uglifier"
@@ -7,8 +7,8 @@ def should_equal_itself(string, should)
string = "#{string}\n"
should = "#{should}\n"
- ast = LatteScript.parse(string)
- new_string = LatteScript::Stringifier.to_string(ast) do |stringifier|
+ ast = ParseJS.parse(string)
+ new_string = ParseJS::Stringifier.to_string(ast) do |stringifier|
stringifier.include_comments = true
end
@@ -20,8 +20,8 @@ def should_match_compressed(string)
string.force_encoding("BINARY")
- ast = LatteScript.parse(string)
- new_string = LatteScript::Stringifier.to_string(ast) do |stringifier|
+ ast = ParseJS.parse(string)
+ new_string = ParseJS::Stringifier.to_string(ast) do |stringifier|
stringifier.include_comments = true
end

0 comments on commit 74c27c7

Please sign in to comment.