bemhtml-syntax
Advanced tools
Comparing version 0.0.2 to 0.0.3
{ | ||
"name": "bemhtml-syntax", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "BEMHTML syntax converter", | ||
@@ -5,0 +5,0 @@ "main": "lib/syntax.js", |
@@ -9,22 +9,30 @@ var syntax = require(".."), | ||
bemxjst = require("bem-xjst"), | ||
compat = require("bemhtml-compat"); | ||
compat = require("bemhtml-compat"), | ||
options = {}; | ||
// var source = fs.readFileSync('./tt.bemhtml', {encoding: 'utf8'}); | ||
var source = "function test() { for(var i = 0;i < 2;i++) { }; return [];}"; | ||
// var source = "function test(){for(;;){};return []}"; | ||
var esprima = require("esprima"), | ||
esgen = require("escodegen").generate; | ||
var code = fs.readFileSync('./basic/info7.bemhtml.js', {encoding: 'utf8'}); | ||
// Парсим | ||
var ast = syntax.parse(source); | ||
pp(ast, {prompt: "ast"}); | ||
// Делаем всякую магию с деревом | ||
var newAst = syntax.translate(ast); | ||
pp(newAst, {prompt: "newAst"}); | ||
// Сериализуем в JavaScript | ||
var jsCode1 = syntax.generate(newAst, options); | ||
pp(jsCode1, {prompt: "jsCode1"}); | ||
var esprima = require("esprima"), | ||
esgen = require("escodegen").generate, | ||
uglify = require("uglify-js"); | ||
// Все сразу одним махом, наверное, только это вам и нужно | ||
var jsCode2 = syntax.compile(source, options); | ||
var exhibit1 = '"\0 \x00 \u0000 0 \x30 \u0030"', | ||
ast1 = esprima.parse(exhibit1), | ||
exhibit2 = "'привет'", | ||
ast2 = esprima.parse(exhibit2); | ||
var east = esprima.parse(source); | ||
pp(east, {prompt: "east"}); | ||
esgen(ast1); | ||
uglify.AST_Node.from_mozilla_ast(ast1).print_to_string(); | ||
pp(esgen(east), {prompt: "esgen(east)"}); | ||
esgen(ast2); | ||
uglify.AST_Node.from_mozilla_ast(ast2).print_to_string(); |
Sorry, the diff of this file is not supported yet
1148
736022