Permalink
Browse files

Fixed arithmetic sequense parser/ast

  • Loading branch information...
phyrex1an committed May 18, 2010
1 parent 84e27a5 commit 866cbfb80a59415fec4026338630ff65e087e042
Showing with 6 additions and 3 deletions.
  1. +1 −1 haskell.ast.js
  2. +5 −2 haskell.parser.js
View
@@ -202,7 +202,7 @@
var funname = 'enumFrom';
if (this.e2) funname = funname + 'Then';
if (this.e3) funname = funname + 'To';
- var application = new ast.Application(ast.VariableLookup(funname), this.e1);
+ var application = new ast.Application(new ast.VariableLookup(funname), this.e1);
if (this.e2) application = new ast.Application(application, this.e2);
if (this.e3) application = new ast.Application(application, this.e3);
return application;
View
@@ -406,7 +406,10 @@
var aexp_arithmetic_action = function(p) {
return action(p, function(ast) {
- return ast;
+ if (ast[1]) {
+ ast[1] = ast[1][0];
+ }
+ return new haskell.ast.ArithmeticSequence(ast[0], ast[1], ast[2]);
});
}
@@ -431,7 +434,7 @@
list_action(sequence(expect(ws('[')), optional(wlist(exp, ',')), expect(ws(']')))), // list constructor
left_section_action(sequence(expect(ws('(')), ws(infixexp), ws(qop), expect(ws(')')))), // left section
right_section_action(sequence(expect(ws('(')), ws(qop), ws(infixexp), expect(ws(')')))), // right section, todo: look into resolution of infixexp in this case, see Haskell Report Chapter 3
- aexp_arithmetic_action(sequence(expectws('['), exp, repeat0(exp), expectws('..'), optional(ws(exp)), expectws(']'))), // arithmetic sequence
+ aexp_arithmetic_action(sequence(expectws('['), ws(exp), optional(sequence(expectws(','), ws(exp))), expectws('..'), optional(ws(exp)), expectws(']'))), // arithmetic sequence
aexp_list_comp_action(sequence(expectws('['), ws(exp), expectws('|'), list(qual, ws(',')), expectws(']'))) // list comprehension
// Todo:
// Labeled construction

0 comments on commit 866cbfb

Please sign in to comment.