merge OFTN version #17

Merged
weskerfoot merged 2 commits from master into master 11 years ago
  1. 3
      example.jl
  2. 9
      prelude.jl
  3. 3
      representation.js
  4. 9
      tokenize.js

3
example.jl

@ -3,6 +3,9 @@ defop 2 Left (a ++ b)
deftype Foo (A -> B) deftype Foo (A -> B)
;; here is a comment
; here is another comment
deftype (Foo a b) deftype (Foo a b)
(a -> b) (a -> b)

9
prelude.jl

@ -0,0 +1,9 @@
;; This file declares the various types used by intrinsic/prelude definitions
;; It is sort of special in that it doesn't care whether there are any associated definitions
;; just that there are type definitions for that particular binding's name
deftype String (List Char)
deftype (List a)
(Empty |
(Cons a (List a)))

3
representation.js

@ -391,7 +391,8 @@ OPInfo = {"+" : [3, "Left"],
"<$>" : [1, "Left"], "<$>" : [1, "Left"],
"." : [1, "Left"], "." : [1, "Left"],
"," : [1, "Left"], "," : [1, "Left"],
"->" : [1, "Right"]}; "->" : [1, "Right"],
"|" : [1, "Left"]};
module.exports = module.exports =
{ {

9
tokenize.js

@ -178,15 +178,21 @@ function peek(tokstream, toktype, word, charnum, linenum) {
return false; return false;
} }
function tokenize(tokstream, matchop) { function tokenize(tokstream, matchop) {
var tokens = []; var tokens = [];
var charnum = 1; var charnum = 1;
var linenum = 1; var linenum = 1;
var i, result, lambda, num; var i, result, lambda, num, comment;
while (tokstream) { while (tokstream) {
switch (tokstream[0].charCodeAt()) { switch (tokstream[0].charCodeAt()) {
/* falls through */ /* falls through */
case 59: // ;
while (tokstream[0].charCodeAt() !== 10) {
tokstream = tokstream.substr(1);
}
break;
case 9: // '\t' case 9: // '\t'
charnum++; charnum++;
tokens.push(["whitespace", '\t', charnum, linenum]); tokens.push(["whitespace", '\t', charnum, linenum]);
@ -216,6 +222,7 @@ function tokenize(tokstream, matchop) {
charnum++; charnum++;
tokens.push(["left_paren", '(', charnum, linenum]); tokens.push(["left_paren", '(', charnum, linenum]);
tokstream = tokstream.substr(1); tokstream = tokstream.substr(1);
break; break;
/* falls through */ /* falls through */
case 41: // ')' case 41: // ')'

Loading…
Cancel
Save