Permalink
Browse files

Added tabspace option, defaults to 8. This allows us to use spaces in…

…stead of tabs for indentation without crashing the lexer
  • Loading branch information...
1 parent 63291f8 commit b9dbf6172d142ff2c0fdcbc365d577ba5a13043c @rajkissu rajkissu committed with pacovell May 5, 2011
Showing with 8 additions and 1 deletion.
  1. +8 −1 lib/kyuri/core.js
View
9 lib/kyuri/core.js
@@ -25,6 +25,13 @@ exports.compile = function (code, options) {
// Default options are to generate steps only
options = options || {};
options.target = options.target || 'steps'
+ options.tabspace = options.tabspace || 8;
+
+ // Convert groups of spaces to tabs
+ code = code.replace(new RegExp(' {' + options.tabspace + '}', 'g'), '\t');
@marco4net
marco4net Dec 7, 2012

should be conditional on isText, i.e.
if (isText)
code = code.replace(new RegExp(' {' + options.tabspace + '}', 'g'), '\t');

+
+ // we don't need this anymore
+ delete options.tabspace;
try {
ast = isText ? parser.parse(lexer.tokenize(code)) : code;
@@ -64,4 +71,4 @@ exports.setLanguage = function (language) {
lexer = new Lexer(language, i18n);
};
-exports.i18n = i18n;
+exports.i18n = i18n;

0 comments on commit b9dbf61

Please sign in to comment.