Commit 8e1d132b authored by Ole Voldsæter's avatar Ole Voldsæter

allow * and // stata comments. Hack: prepending a § character to input to...

allow * and // stata comments. Hack: prepending a § character to input to signify start of line. This is because of a Jison limitation ( https://github.com/zaach/jison/issues/67 ).
parent 81bde7d9
This diff is collapsed.
......@@ -8,7 +8,9 @@ ID {ID_PART}('@'{ID_PART})?
%%
"§"\s*"*" return 'EOF';
"//" return 'EOF';
"§" /* skip */
\s+ /* skip whitespace */
......@@ -147,6 +149,7 @@ command
| defineCatLabels EOF {return $1;}
| assignCatLabels EOF {return $1;}
| assignMissingValues EOF {return $1;}
| EOF {return {"type":"no-op"};}
;
useOrDeleteDataset
......
......@@ -8,6 +8,7 @@ function RairdParser() {
if (parser) {
result.parse = function(input, macroResolver) {
input = "§"+input;
return parser.parse(macroResolver ? _expandMarcos(input, macroResolver) : input);
};
} else {
......
......@@ -483,6 +483,20 @@ describe('Tests', function () {
})
});
describe("#comment_1", function(){
it("should return a no-op json object", function(){
var result = parser.parse(" * a, b(1 4)");
assert.equal(result.type, "no-op")
})
});
describe("#comment_2", function(){
it("should return a statop json object with no subset", function(){
var result = parser.parse("a // if b==1");
assert.equal(result.type, "statOp");
assert(! result.subset)
})
});
});
mocha.run();
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment