~ivle-dev/ivle/codemirror

« back to all changes in this revision

Viewing changes to ivle/webapp/filesystem/browser/media/codemirror/js/parsedummy.js

  • Committer: David Coles
  • Date: 2010-05-31 10:38:53 UTC
  • Revision ID: coles.david@gmail.com-20100531103853-8xypjpracvwy0qt4
Editor: Added CodeMirror-0.67 Javascript code editor source from 
http://marijn.haverbeke.nl/codemirror/ (zlib-style licence)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
var DummyParser = Editor.Parser = (function() {
 
2
  function tokenizeDummy(source) {
 
3
    while (!source.endOfLine()) source.next();
 
4
    return "text";
 
5
  }
 
6
  function parseDummy(source) {
 
7
    function indentTo(n) {return function() {return n;}}
 
8
    source = tokenizer(source, tokenizeDummy);
 
9
    var space = 0;
 
10
 
 
11
    var iter = {
 
12
      next: function() {
 
13
        var tok = source.next();
 
14
        if (tok.type == "whitespace") {
 
15
          if (tok.value == "\n") tok.indentation = indentTo(space);
 
16
          else space = tok.value.length;
 
17
        }
 
18
        return tok;
 
19
      },
 
20
      copy: function() {
 
21
        var _space = space;
 
22
        return function(_source) {
 
23
          space = _space;
 
24
          source = tokenizer(_source, tokenizeDummy);
 
25
          return iter;
 
26
        };
 
27
      }
 
28
    };
 
29
    return iter;
 
30
  }
 
31
  return {make: parseDummy};
 
32
})();