From 0a999d9818460fc3919cddeffaebce3d8f3a7a2d Mon Sep 17 00:00:00 2001 From: nisstyre56 Date: Sun, 18 May 2014 18:33:49 -0400 Subject: [PATCH] support for oneline comments using ; as the prefix --- example.jl | 3 +++ tokenize.js | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/example.jl b/example.jl index 32fe00a..f211604 100644 --- a/example.jl +++ b/example.jl @@ -3,6 +3,9 @@ defop 2 Left (a ++ b) deftype Foo (A -> B) +;; here is a comment +; here is another comment + deftype (Foo a b) (a -> b) diff --git a/tokenize.js b/tokenize.js index 56de382..907622e 100755 --- a/tokenize.js +++ b/tokenize.js @@ -178,15 +178,21 @@ function peek(tokstream, toktype, word, charnum, linenum) { return false; } + function tokenize(tokstream, matchop) { var tokens = []; var charnum = 1; var linenum = 1; - var i, result, lambda, num; + var i, result, lambda, num, comment; while (tokstream) { switch (tokstream[0].charCodeAt()) { /* falls through */ + case 59: // ; + while (tokstream[0].charCodeAt() !== 10) { + tokstream = tokstream.substr(1); + } + break; case 9: // '\t' charnum++; tokens.push(["whitespace", '\t', charnum, linenum]); @@ -216,6 +222,7 @@ function tokenize(tokstream, matchop) { charnum++; tokens.push(["left_paren", '(', charnum, linenum]); tokstream = tokstream.substr(1); + break; /* falls through */ case 41: // ')'