@@ -254,7 +254,7 @@ Parser.prototype._parseControl = function() {
254254
255255Parser . prototype . _parseFunction = function ( ) {
256256 var lexer = this . _lexer ;
257- if ( ! lexer . accept ( 'func' , [ 'FUNCTION ' , 'PROCEDURE ' ] ) ) return null ;
257+ if ( ! lexer . accept ( 'func' , [ 'function ' , 'procedure ' ] ) ) return null ;
258258
259259 // \FUNCTION{funcName}{funcArgs}
260260 var funcType = this . _lexer . get ( ) . text ; // FUNCTION or PROCEDURE
@@ -267,7 +267,7 @@ Parser.prototype._parseFunction = function() {
267267 // <block>
268268 var blockNode = this . _parseBlock ( ) ;
269269 // \ENDFUNCTION
270- lexer . expect ( 'func' , 'END ' + funcType ) ;
270+ lexer . expect ( 'func' , 'end ' + funcType ) ;
271271
272272 var functionNode = new ParseNode ( 'function' ,
273273 { type : funcType , name : funcName } ) ;
@@ -277,7 +277,7 @@ Parser.prototype._parseFunction = function() {
277277} ;
278278
279279Parser . prototype . _parseIf = function ( ) {
280- if ( ! this . _lexer . accept ( 'func' , 'IF ' ) ) return null ;
280+ if ( ! this . _lexer . accept ( 'func' , 'if ' ) ) return null ;
281281
282282 var ifNode = new ParseNode ( 'if' ) ;
283283
@@ -289,7 +289,7 @@ Parser.prototype._parseIf = function() {
289289
290290 // ( \ELIF { <cond> } <block> )[0...n]
291291 var numElif = 0 ;
292- while ( this . _lexer . accept ( 'func' , 'ELIF' ) ) {
292+ while ( this . _lexer . accept ( 'func' , [ 'elif' , 'elsif' , 'elseif' ] ) ) {
293293 this . _lexer . expect ( 'open' ) ;
294294 ifNode . addChild ( this . _parseCond ( ) ) ;
295295 this . _lexer . expect ( 'close' ) ;
@@ -299,13 +299,13 @@ Parser.prototype._parseIf = function() {
299299
300300 // ( \ELSE <block> )[0..1]
301301 var hasElse = false ;
302- if ( this . _lexer . accept ( 'func' , 'ELSE ' ) ) {
302+ if ( this . _lexer . accept ( 'func' , 'else ' ) ) {
303303 hasElse = true ;
304304 ifNode . addChild ( this . _parseBlock ( ) ) ;
305305 }
306306
307307 // \ENDIF
308- this . _lexer . expect ( 'func' , 'ENDIF ' ) ;
308+ this . _lexer . expect ( 'func' , 'endif ' ) ;
309309
310310 ifNode . value = { numElif : numElif , hasElse : hasElse } ;
311311 return ifNode ;
@@ -314,7 +314,7 @@ Parser.prototype._parseIf = function() {
314314Parser . prototype . _parseLoop = function ( ) {
315315 if ( ! this . _lexer . accept ( 'func' , [ 'FOR' , 'FORALL' , 'WHILE' ] ) ) return null ;
316316
317- var loopName = this . _lexer . get ( ) . text ;
317+ var loopName = this . _lexer . get ( ) . text . toLowerCase ( ) ;
318318 var loopNode = new ParseNode ( 'loop' , loopName ) ;
319319
320320 // { <cond> } <block>
@@ -324,25 +324,25 @@ Parser.prototype._parseLoop = function() {
324324 loopNode . addChild ( this . _parseBlock ( ) ) ;
325325
326326 // \ENDFOR
327- var endLoop = loopName !== 'FORALL ' ? 'END ' + loopName : 'ENDFOR ' ;
327+ var endLoop = loopName !== 'forall ' ? 'end ' + loopName : 'endfor ' ;
328328 this . _lexer . expect ( 'func' , endLoop ) ;
329329
330330 return loopNode ;
331331} ;
332332
333- var INPUTS_OUTPUTS_COMMANDS = [ 'ENSURE ' , 'REQUIRE ' ] ;
334- var STATEMENT_COMMANDS = [ 'STATE ' , 'PRINT ' , 'RETURN ' ] ;
333+ var INPUTS_OUTPUTS_COMMANDS = [ 'ensure ' , 'require ' ] ;
334+ var STATEMENT_COMMANDS = [ 'state ' , 'print ' , 'return ' ] ;
335335Parser . prototype . _parseCommand = function ( acceptCommands ) {
336336 if ( ! this . _lexer . accept ( 'func' , acceptCommands ) ) return null ;
337337
338- var cmdName = this . _lexer . get ( ) . text ;
338+ var cmdName = this . _lexer . get ( ) . text . toLowerCase ( ) ;
339339 var cmdNode = new ParseNode ( 'command' , cmdName ) ;
340340 cmdNode . addChild ( this . _parseOpenText ( ) ) ;
341341 return cmdNode ;
342342} ;
343343
344344Parser . prototype . _parseComment = function ( ) {
345- if ( ! this . _lexer . accept ( 'func' , 'COMMENT ' ) ) return null ;
345+ if ( ! this . _lexer . accept ( 'func' , 'comment ' ) ) return null ;
346346
347347 var commentNode = new ParseNode ( 'comment' ) ;
348348
@@ -356,7 +356,7 @@ Parser.prototype._parseComment = function() {
356356
357357Parser . prototype . _parseCall = function ( ) {
358358 var lexer = this . _lexer ;
359- if ( ! lexer . accept ( 'func' , 'CALL ' ) ) return null ;
359+ if ( ! lexer . accept ( 'func' , 'call ' ) ) return null ;
360360
361361 var anyWhitespace = lexer . get ( ) . whitespace ;
362362
@@ -424,7 +424,7 @@ var ACCEPTED_TOKEN_BY_ATOM = {
424424 'special' : { tokenType : 'special' } ,
425425 'cond-symbol' : {
426426 tokenType : 'func' ,
427- tokenValues : [ 'AND ' , 'OR ' , 'NOT ' , 'TRUE ' , 'FALSE ' , 'TO ' ]
427+ tokenValues : [ 'and ' , 'or ' , 'not ' , 'true ' , 'false ' , 'to ' ]
428428 } ,
429429 'quote-symbol' : {
430430 tokenType : 'quote'
@@ -461,7 +461,7 @@ Parser.prototype._parseAtom = function() {
461461 if ( tokenText === null ) continue ;
462462
463463 var anyWhitespace = this . _lexer . get ( ) . whitespace ;
464- return new AtomNode ( atomType , tokenText , anyWhitespace ) ;
464+ return new AtomNode ( atomType , tokenText . toLowerCase ( ) , anyWhitespace ) ;
465465 }
466466 return null ;
467467} ;
0 commit comments