@@ -212,8 +212,6 @@ algorithm
212212 end match;
213213end printAndFailIfError;
214214
215-
216-
217215public function parseError
218216 input list< String > inChars;
219217 input LineInfo inLineInfo;
@@ -393,13 +391,13 @@ algorithm
393391
394392 case (c :: chars, linfo, ec)
395393 equation
396- equality(c = ec);
394+ true = stringEq(c, ec);
397395 then (chars, linfo);
398396
399397 case (chars, linfo, ec)
400398 equation
401- // failure(equality(c = ec));
402- // or chars = {}
399+ // false = stringEq(c, ec));
400+ // or chars = {}
403401 (linfo) = parseError(chars, linfo, "Expected character '" + ec + "' at the position." , false );
404402 // fprint(Flags.FAILTRACE, "???Expected character '" + ec + "'\n");
405403 then (chars, linfo);
@@ -432,13 +430,13 @@ algorithm
432430 equation
433431 (chars, linfo) = interleave(chars, linfo);
434432 (c :: chars) = chars;
435- equality(c = ec);
433+ true = stringEq(c, ec);
436434 then (chars, linfo);
437435
438436 case (chars, linfo, ec)
439437 equation
440- // failure(equality(c = ec) );
441- // or chars = {}
438+ // false = stringEq( c, ec );
439+ // or chars = {}
442440 (linfo) = parseError(chars, linfo, "Expected character '" + ec + "' after the position." ,false );
443441 then (chars, linfo);
444442
@@ -464,7 +462,7 @@ algorithm
464462
465463 case (c :: chars, kwc :: kwchars)
466464 equation
467- equality(c = kwc);
465+ true = stringEq(c, kwc);
468466 then takeKeywordChars(chars, kwchars);
469467
470468 case (chars, {})
@@ -752,32 +750,32 @@ public function newLine
752750 output list< String > outChars;
753751 output LineInfo outLineInfo;
754752algorithm
755- (outChars, outLineInfo) := matchcontinue (inChars, inLineInfo)
753+ (outChars, outLineInfo) := match (inChars, inLineInfo)
756754 local
757755 list< String > chars;
758756 ParseInfo pinfo;
759757 String c;
760758 Integer lnum, llen, i;
761- // CR + LF .. Windows
762- case (c :: chars, LINE_INFO (parseInfo = pinfo, lineNumber = lnum))
763- equation
764- 13 = stringCharInt(c); // \r
765- (" \n " :: chars) = chars; // \n
766- llen = charsTillEndOfLine(chars, 1 ); // 1 is colum number of the first character, so count it
767- lnum = lnum + 1 ;
768- then (chars, LINE_INFO (pinfo, lnum, llen, chars));
769759
770- // LF only ... Linux
771- // or CR only - Mac OS up to 9
760+ // CR + LF .. Windows
761+ // LF only ... Linux
762+ // or CR only - Mac OS up to 9
772763 case (c :: chars, LINE_INFO (parseInfo = pinfo, lineNumber = lnum))
773764 equation
774765 i = stringCharInt(c);
766+ if i == 13
767+ then
768+ chars = match(chars)
769+ case (" \n " :: chars) then chars; // \n
770+ else chars;
771+ end match;
772+ end if ;
775773 true = (i == 10 ) or (i == 13 ); // \n or \r
776- llen = charsTillEndOfLine(chars, 1 ); // 1 is colum number of the first character, so count it
774+ llen = charsTillEndOfLine(chars, 1 ); // 1 is colum number of the first character, so count it
777775 lnum = lnum + 1 ;
778776 then (chars, LINE_INFO (pinfo, lnum, llen, chars));
779777
780- end matchcontinue ;
778+ end match ;
781779end newLine;
782780
783781/*
@@ -992,7 +990,7 @@ public function identifier_rest
992990 output list< String > outChars;
993991 output list< String > outRestIdentChars;
994992algorithm
995- (outChars, outRestIdentChars) := matchcontinue inChars
993+ (outChars, outRestIdentChars) := match inChars
996994 local
997995 list< String > chars, restIdChars;
998996 String c;
@@ -1002,21 +1000,22 @@ algorithm
10021000 equation
10031001 i = stringCharInt(c);
10041002 // [_0-9A-Za-z]
1005- true = (i == 95 /* _*/ )
1003+ if (i == 95 /* _*/ )
10061004 or ( 48 /* 0*/ <= i and i <= 57 /* 9*/ )
10071005 or ( 65 /* A*/ <= i and i <= 90 /* Z*/ )
1008- or ( 97 /* a*/ <= i and i <= 122 /* z*/ );
1009- (chars, restIdChars) = identifier_rest(chars);
1010- then (chars, c :: restIdChars);
1011-
1012- else (inChars, {});
1006+ or ( 97 /* a*/ <= i and i <= 122 /* z*/ )
1007+ then
1008+ (chars, restIdChars) = identifier_rest(chars);
1009+ restIdChars = c :: restIdChars;
1010+ else
1011+ chars = inChars;
1012+ restIdChars = {};
1013+ end if ;
1014+ then (chars, restIdChars);
10131015
1014- end matchcontinue ;
1016+ end match ;
10151017end identifier_rest;
10161018
1017-
1018-
1019-
10201019/*
10211020pathIdent:
10221021 identifier:head pathIdentPath(head):pid => pid
@@ -4027,13 +4026,13 @@ algorithm
40274026 equation
40284027 (chars, linfo) = newLine(chars, linfo);
40294028 (c :: "%" :: chars) = chars;
4030- equality(c = rquot);
4029+ true = stringEq(c, rquot);
40314030 str = stringCharListString(listReverse(accChars));
40324031 then (chars, linfo, str :: accStrList,NONE ());
40334032
40344033 case (c :: "%" :: chars, linfo, rquot, accChars, accStrList)
40354034 equation
4036- equality(c = rquot);
4035+ true = stringEq(c, rquot);
40374036 str = stringCharListString(listReverse(accChars));
40384037 then (chars, linfo, str :: accStrList,NONE ());
40394038
@@ -4436,7 +4435,7 @@ public function lineIndent
44364435 output list< String > outChars;
44374436 output Integer outLineIndent;
44384437algorithm
4439- (outChars, outLineIndent) := matchcontinue (inChars, inLineIndent)
4438+ (outChars, outLineIndent) := match (inChars, inLineIndent)
44404439 local
44414440 list< String > chars;
44424441 Integer lineInd;
@@ -4453,7 +4452,7 @@ algorithm
44534452
44544453 else (inChars, inLineIndent);
44554454
4456- end matchcontinue ;
4455+ end match ;
44574456end lineIndent;
44584457/*
44594458// & ... no interleave
@@ -4533,13 +4532,13 @@ algorithm
45334532 /*
45344533 case (startChars as (c :: "#" :: chars), startLinfo, lesc, resc, isSQ, expLst, indStack, actInd, lineInd, accChars)
45354534 equation
4536- equality( c = lesc );
4535+ true = stringEq( c, lesc );
45374536 (chars, linfo) = interleave(chars, startLinfo);
45384537 (chars, linfo, eexp) = nonTemplateExprWithOpts(chars, linfo, lesc, resc);
45394538 (chars, linfo) = interleaveExpectChar(chars, linfo, "#");
45404539 (chars, linfo) = expectChar(chars, linfo, resc);
45414540 //("#" :: c :: chars) = chars;
4542- //equality( c = resc );
4541+ // true = stringEq( c, resc );
45434542 (chars, linfo, lineInd) = dropNewLineAfterEmptyExp(chars, linfo, lineInd, accChars);
45444543 (expLst, indStack, actInd, errOpt) = onEscapedExp(eexp, expLst, indStack, actInd, lineInd, accChars);
45454544 LINE_INFO(startOfLineChars = solChars) = startLinfo;
@@ -4548,65 +4547,70 @@ algorithm
45484547 then (chars, linfo, exp);
45494548 */
45504549
4551- // <% %> empty expression ... i.e. comment or a break in line that is not parsed
4550+ // ??? should we allow escaping at all ??
4551+ /* experimentally we will disallow it ... use "" constants in like 'hey son<%"'"%>s brother'
4552+ // \ will be taken literally, '\\' and <<\\>> are both double-backslash !
4553+ case ("\\":: c :: chars, linfo, lesc, resc, isSQ, expLst, indStack, actInd, lineInd, accChars)
4554+ equation
4555+ true = (c == "\\" or c == "'" or c == lesc or c == resc);
4556+ (chars, linfo, exp) = restOfTemplLine(chars, linfo, lesc, resc, isSQ, expLst, indStack, actInd, lineInd, c :: accChars);
4557+ then (chars, linfo, exp);
4558+ */
4559+
4560+ // isSingleQuote = true
4561+ case ("'" :: chars, linfo, _, _, true , expLst, indStack, actInd, lineInd, accChars)
4562+ equation
4563+ expLst = onTemplEnd(false , expLst, indStack, actInd, lineInd, accChars);
4564+ expB = makeTemplateFromExpList(expLst, "'" ,"'" );
4565+ then (chars, linfo, expB);
4566+
4567+ // isDoubleQuote = false => << >>
4568+ case (">" ::">" :: chars, linfo, _, _, false , expLst, indStack, actInd, lineInd, accChars)
4569+ equation
4570+ expLst = onTemplEnd(true , expLst, indStack, actInd, lineInd, accChars);
4571+ expB = makeTemplateFromExpList(expLst, "<<" ,">>" );
4572+ then (chars, linfo, expB);
4573+
4574+ // <% %> empty expression ... i.e. comment or a break in line that is not parsed
45524575 case (c :: "%" :: chars, linfo, lesc, resc, isSQ, expLst, indStack, actInd, lineInd, accChars)
45534576 equation
4554- equality( c = lesc );
4577+ true = stringEq(c, lesc);
45554578 (chars, linfo) = interleave(chars, linfo);
45564579 ("%" :: c :: chars) = chars;
4557- equality( c = resc );
4580+ true = stringEq(c, resc );
45584581 (chars, linfo, lineInd) = dropNewLineAfterEmptyExp(chars, linfo, lineInd, accChars);
45594582 (chars, linfo, expB) = restOfTemplLine(chars, linfo, lesc, resc, isSQ, expLst, indStack, actInd, lineInd, accChars);
45604583 then (chars, linfo, expB);
45614584
4562- // <% expression %>
4585+ // <% expression %>
45634586 case ((c :: "%" :: chars), startLinfo, lesc, resc, isSQ, expLst, indStack, actInd, lineInd, accChars)
45644587 equation
4565- equality( c = lesc );
4588+ true = stringEq(c, lesc );
45664589 (chars, linfo) = interleave(chars, startLinfo);
45674590 (chars, linfo, eexp) = expression(chars, linfo, lesc, resc, false );
45684591 (chars, linfo) = interleaveExpectChar(chars, linfo, "%" );
45694592 (chars, linfo) = expectChar(chars, linfo, resc);
45704593 // (c :: chars) = chars;
4571- // equality ( c = resc );
4594+ // true = stringEq ( c , resc );
45724595 (expLst, indStack, actInd, errOpt) = onEscapedExp(eexp, expLst, indStack, actInd, lineInd, accChars);
45734596 LINE_INFO (startOfLineChars = solChars) = startLinfo;
45744597 linfo = parseErrorPrevPositionOpt(solChars, startLinfo, linfo, errOpt, false );
45754598 (chars, linfo, expB) = restOfTemplLine(chars, linfo, lesc, resc, isSQ, expLst, indStack, actInd, actInd, {});
45764599 then (chars, linfo, expB);
45774600
4578- case (startChars, startLinfo , lesc, resc, isSQ, expLst, indStack, actInd, lineInd, accChars)
4601+ case (c :: chars, linfo , lesc, resc, isSQ, expLst, indStack, actInd, lineInd, accChars)
45794602 equation
4580- (chars, linfo) = newLine(startChars, startLinfo );
4603+ (chars, linfo) = newLine(c :: chars, linfo );
45814604 (expLst, indStack, actInd, errOpt) = onNewLine(expLst, indStack, actInd, lineInd, accChars);
4582- LINE_INFO (startOfLineChars = solChars) = startLinfo;
4583- linfo = parseErrorPrevPositionOpt(solChars, startLinfo, linfo, errOpt, false );
4584- (chars, linfo, expB) = templateBody(chars, linfo, lesc, resc, isSQ, expLst, indStack, actInd);
4585- then (chars, linfo, expB);
4605+ LINE_INFO (startOfLineChars = solChars) = linfo;
4606+ linfo = parseErrorPrevPositionOpt(solChars, linfo, linfo, errOpt, false );
45864607
4587- // isSingleQuote = true
4588- case ("'" :: chars, linfo, _, _, true , expLst, indStack, actInd, lineInd, accChars)
4589- equation
4590- expLst = onTemplEnd(false , expLst, indStack, actInd, lineInd, accChars);
4591- expB = makeTemplateFromExpList(expLst, "'" ,"'" );
4592- then (chars, linfo, expB);
4593-
4594- // isDoubleQuote = false => << >>
4595- case (">" ::">" :: chars, linfo, _, _, false , expLst, indStack, actInd, lineInd, accChars)
4596- equation
4597- expLst = onTemplEnd(true , expLst, indStack, actInd, lineInd, accChars);
4598- expB = makeTemplateFromExpList(expLst, "<<" ,">>" );
4608+ // adrpo: replace this call with the actual body of templateBody
4609+ // (chars, linfo, expB) = templateBody(chars, linfo, lesc, resc, isSQ, expLst, indStack, actInd);
4610+ (chars, lineInd) = lineIndent(chars, 0 );
4611+ (chars, linfo, expB) = restOfTemplLine(chars, linfo, lesc, resc, isSQ, expLst, indStack, actInd, lineInd, {});
45994612 then (chars, linfo, expB);
46004613
4601- // ??? should we allow escaping at all ??
4602- /* experimentally we will disallow it ... use "" constants in like 'hey son<%"'"%>s brother'
4603- // \ will be taken literally, '\\' and <<\\>> are both double-backslash !
4604- case ("\\":: c :: chars, linfo, lesc, resc, isSQ, expLst, indStack, actInd, lineInd, accChars)
4605- equation
4606- true = (c == "\\" or c == "'" or c == lesc or c == resc);
4607- (chars, linfo, exp) = restOfTemplLine(chars, linfo, lesc, resc, isSQ, expLst, indStack, actInd, lineInd, c :: accChars);
4608- then (chars, linfo, exp);
4609- */
46104614 case (c :: chars, linfo, lesc, resc, isSQ, expLst, indStack, actInd, lineInd, accChars)
46114615 equation
46124616 (chars, linfo, expB) = restOfTemplLine(chars, linfo, lesc, resc, isSQ, expLst, indStack, actInd, lineInd, c :: accChars);
@@ -4763,14 +4767,14 @@ algorithm
47634767 // we need a flag for having something non-space on the line
47644768 // case (TplAbsyn.STR_TOKEN(value = Tpl.ST_NEW_LINE()), expLst, indStack, actInd, lineInd, accChars)
47654769 // equation
4766- // //equality( lineInd = actInd);
4770+ // // true = intEq( lineInd, actInd);
47674771 // expLst = addAccStringChars(expLst, "\n" :: accChars);
47684772 // then (expLst, indStack, actInd);
47694773
47704774 // the same indent level
47714775 case (exp, expLst, indStack, actInd, lineInd, accChars)
47724776 equation
4773- equality ( lineInd = actInd);
4777+ true = intEq ( lineInd, actInd );
47744778 expLst = addAccStringChars(expLst, accChars);
47754779 expLst = finalizeLastStringToken(expLst);
47764780 expLst = exp :: expLst;
0 commit comments