homunculus
Advanced tools
Comparing version 0.2.3 to 0.2.4
@@ -35,3 +35,3 @@ (function(factory) { | ||
var regMatch = new RegMatch(Token.ID, /^[$a-zA-Z_][$\w]*/, Lexer.SPECIAL, function() { | ||
var id = new RegMatch(Token.ID, /^[$a-zA-Z_][$\w]*/, Lexer.SPECIAL, function() { | ||
return !!(self.keyWords().hasOwnProperty(this.content())); | ||
@@ -41,3 +41,3 @@ }, function() { | ||
}); | ||
regMatch.callback = function(token) { | ||
id.callback = function(token) { | ||
var s = token.content(); | ||
@@ -49,3 +49,3 @@ if(isProperty) { | ||
}; | ||
self.addMatch(regMatch); | ||
self.addMatch(id); | ||
@@ -52,0 +52,0 @@ self.addMatch(new RegMatch(Token.NUMBER, /^\.\d+(?:E[+-]?\d*)?/i, { |
@@ -367,2 +367,3 @@ (function(factory) { | ||
} | ||
node.add(this.match(';')); | ||
return node; | ||
@@ -369,0 +370,0 @@ }, |
{ | ||
"name": "homunculus", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"description": "A lexer&parser by Javascript", | ||
@@ -5,0 +5,0 @@ "maintainers": [ |
@@ -13,2 +13,6 @@ # A lexer&parser by Javascript | ||
## 使用说明 | ||
* 解析语法并返回语法树和此法单元序列。、 | ||
* CommonJS/AMD/CMD自适应。 | ||
## API | ||
@@ -117,2 +121,5 @@ * getClass(type:String, lan:String):class | ||
当调用语法分析器解析后,会返回生成ast,这是一个树状数据结构,每个节点都是对应语法解析器目录下的Node.js的实例。<br/> | ||
demo目录下是一个用js的parser分析输入js代码并画出ast形状的页面。 | ||
demo目录下是一个用js的parser分析输入js代码并画出ast形状的页面。 | ||
## License | ||
[MIT License] |
@@ -27,3 +27,3 @@ var Rule = require('./Rule'); | ||
var regMatch = new RegMatch(Token.ID, /^[$a-zA-Z_][$\w]*/, Lexer.SPECIAL, function() { | ||
var id = new RegMatch(Token.ID, /^[$a-zA-Z_][$\w]*/, Lexer.SPECIAL, function() { | ||
return !!(self.keyWords().hasOwnProperty(this.content())); | ||
@@ -33,3 +33,3 @@ }, function() { | ||
}); | ||
regMatch.callback = function(token) { | ||
id.callback = function(token) { | ||
var s = token.content(); | ||
@@ -41,3 +41,3 @@ if(isProperty) { | ||
}; | ||
self.addMatch(regMatch); | ||
self.addMatch(id); | ||
@@ -44,0 +44,0 @@ self.addMatch(new RegMatch(Token.NUMBER, /^\.\d+(?:E[+-]?\d*)?/i, { |
@@ -359,2 +359,3 @@ var IParser = require('../Parser'); | ||
} | ||
node.add(this.match(';')); | ||
return node; | ||
@@ -361,0 +362,0 @@ }, |
@@ -316,2 +316,8 @@ var homunculus = require('../'); | ||
}); | ||
it('keyword can not be label', function() { | ||
var parser = homunculus.getParser('js'); | ||
expect(function() { | ||
parser.parse('var:'); | ||
}).to.throwError(); | ||
}); | ||
it('keyword after get/set', function() { | ||
@@ -318,0 +324,0 @@ var parser = homunculus.getParser('js'); |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1286318
32951
123