From 095dc531352b8055aa4ec355d8cf1157901377fa Mon Sep 17 00:00:00 2001 From: dos-reis Date: Fri, 10 May 2013 01:09:22 +0000 Subject: The compiler now accepts do-statements --- src/interp/spad-parser.boot | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'src/interp/spad-parser.boot') diff --git a/src/interp/spad-parser.boot b/src/interp/spad-parser.boot index d4f27573..4db1d4bc 100644 --- a/src/interp/spad-parser.boot +++ b/src/interp/spad-parser.boot @@ -1,4 +1,4 @@ --- Copyright (C) 2007-2012, Gabriel Dos Reis. +-- Copyright (C) 2007-2013, Gabriel Dos Reis. -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without @@ -751,7 +751,7 @@ parseReturn rd == parseThrow rd == matchAdvanceKeyword(rd,"throw") => compulsorySyntax(rd,parseExpression rd) - pushReduction('parseReturn,["%Throw",popStack1()]) + pushReduction('parseThrow,["%Throw",popStack1()]) nil parseExit rd == @@ -776,6 +776,10 @@ parseJump rd == pushReduction('parseJump,s) nil +++ Parse a block statement, e.g. a pile of expressions. +parseBlock rd == + parseExpr(rd,110) + parseForm rd == matchAdvanceKeyword(rd,"iterate") => pushReduction('parseForm,["iterate"]) @@ -822,13 +826,19 @@ parseIteratorTails rd == parseLoop rd == repeatedSyntax(rd,'iterators,function parseIterator) => compulsorySyntax(rd,matchAdvanceKeyword(rd,"repeat")) - compulsorySyntax(rd,parseExpr(rd,110)) + compulsorySyntax(rd,parseBlock rd) pushReduction('parseLoop,["REPEAT",:popStack2(),popStack1()]) matchAdvanceKeyword(rd,"repeat") => - compulsorySyntax(rd,parseExpr(rd,110)) + compulsorySyntax(rd,parseBlock rd) pushReduction('parseLoop,["REPEAT",popStack1()]) nil +parseDo rd == + matchAdvanceKeyword(rd,"do") => + compulsorySyntax(rd, parseBlock rd) + pushReduction('parseDo,["%Do",popStack1()]) + nil + parseOpenBracket rd == s := currentSymbol rd s is "[" or s is ["elt",.,"["] => @@ -931,7 +941,7 @@ parseMatch rd == matchAdvanceKeyword(rd,"case") => compulsorySyntax(rd,parseExpr(rd,400)) compulsorySyntax(rd,matchAdvanceKeyword(rd,"is")) - compulsorySyntax(rd,parseExpr(rd,110)) + compulsorySyntax(rd,parseBlock rd) pushReduction('parseMatch,["%Match",popStack2(),popStack1()]) nil @@ -1249,5 +1259,6 @@ for j in [ ["|",0,190], ["suchthat"], ["then",0,114], - ["else",0,114] + ["else",0,114], + ["do",122,121,function parseDo] ] repeat MAKENEWOP(j,'Nud) -- cgit v1.2.3