continue (report 2026-10.31) A reserved word, the last, so that the others keep the seed's numbers. Loop gains cont, a chain fixed where the round ends: a while's test, a repeat's until, a for's step; deferred statements run on the way, and a lone continue is one conditional jump (loneJump). The seed's dumpers intern continue first (src/test/seedcontinue.pas), so names number alike on both sides. tools/Scan.raz and the vim and emacs modes know the word. Tests in conform/, messages in test/msg.
| @@ -0,0 +1,11 @@ | ||
| 1 | +module ContinueDefer; | |
| 2 | +import Out; | |
| 3 | +proc main*; | |
| 4 | +var i: INT; | |
| 5 | +begin | |
| 6 | + for i := 1 to 3 do | |
| 7 | + defer continue; | |
| 8 | + Out.int(i); | |
| 9 | + end; | |
| 10 | +end; | |
| 11 | +end ContinueDefer. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module ContinueName; | |
| 2 | +proc main*; | |
| 3 | +var continue: INT; | |
| 4 | +begin | |
| 5 | + continue := 1; | |
| 6 | +end; | |
| 7 | +end ContinueName. |
| @@ -0,0 +1,6 @@ | ||
| 1 | +module ContinueOutside; | |
| 2 | +proc main*; | |
| 3 | +begin | |
| 4 | + continue; | |
| 5 | +end; | |
| 6 | +end ContinueOutside. |
| @@ -0,0 +1,5 @@ | ||
| 1 | +1 2 4 5 7 8 10 | |
| 2 | +10 8 six 4 2 | |
| 3 | +abc | |
| 4 | +1||3|4| | |
| 5 | +11 13 ; 21 23 31 33 ; |
| @@ -0,0 +1,49 @@ | ||
| 1 | +(* continue ends the round of the innermost loop: a while tests its | |
| 2 | + condition again, a repeat its until, a for steps or ends; and the | |
| 3 | + statements deferred in the round run on the way (report 2026-10.31, | |
| 4 | + sections 7.2 and 7.7). *) | |
| 5 | +module Continue; | |
| 6 | +import Out; | |
| 7 | + | |
| 8 | +proc main*; | |
| 9 | +var i, j, n: INT; t: []U8; | |
| 10 | +begin | |
| 11 | + for i := 1 to 10 do | |
| 12 | + if i mod 3 = 0 then continue; end; (* a lone continue *) | |
| 13 | + Out.int(i); Out.str(" "); | |
| 14 | + end; | |
| 15 | + Out.ln; | |
| 16 | + for i := 10 to 1 by -2 do | |
| 17 | + if i = 6 then Out.str("six "); continue; end; | |
| 18 | + Out.int(i); Out.str(" "); | |
| 19 | + end; | |
| 20 | + Out.ln; | |
| 21 | + t := "a-b--c"; | |
| 22 | + i := 0; | |
| 23 | + while i < LEN(t) do | |
| 24 | + n := i; | |
| 25 | + i := i + 1; (* the step first *) | |
| 26 | + if t[n] = '-' then continue; end; | |
| 27 | + Out.str(t[n..i]); | |
| 28 | + end; | |
| 29 | + Out.ln; | |
| 30 | + i := 0; | |
| 31 | + repeat | |
| 32 | + INC(i); | |
| 33 | + defer Out.str("|"); | |
| 34 | + if i = 2 then continue; end; | |
| 35 | + Out.int(i); | |
| 36 | + until i >= 4; | |
| 37 | + Out.ln; | |
| 38 | + for i := 1 to 3 do (* the innermost loop's round *) | |
| 39 | + for j := 1 to 3 do | |
| 40 | + if j = 2 then continue; end; | |
| 41 | + Out.int(10 * i + j); Out.str(" "); | |
| 42 | + end; | |
| 43 | + if i = 2 then continue; end; | |
| 44 | + Out.str("; "); | |
| 45 | + end; | |
| 46 | + Out.ln; | |
| 47 | +end; | |
| 48 | + | |
| 49 | +end Continue. |
| @@ -14,13 +14,13 @@ | ||
| 14 | 14 | | File | Lines | Code | What | |
| 15 | 15 | |---|---|---|---| |
| 16 | 16 | | `src/Diag.raz` | 410 | 315 | Messages: positions, source excerpts, colour, counts | |
| 17 | -| `src/Scan.raz` | 1,125 | 934 | Symbols, literals, comments, positions | | |
| 17 | +| `src/Scan.raz` | 1,127 | 934 | Symbols, literals, comments, positions | | |
| 18 | 18 | | `src/Sym.raz` | 687 | 556 | Types, objects, scopes, layout | |
| 19 | 19 | | `src/Chunk.raz` | 363 | 279 | The compiled program: chunks, fixups, line notes | |
| 20 | 20 | | `src/X64.raz` | 1,517 | 1,253 | The instruction encoder, jumps within a procedure, the assembler | |
| 21 | 21 | | `src/Gen.raz` | 2,552 | 1,821 | The stack machine, for x86-64: values, operations, checks, calls, frames | |
| 22 | 22 | | `src/Item.raz` | 2,037 | 1,651 | Items: types, constants, variables, operators, conversions, calls | |
| 23 | -| `src/Parse.raz` | 4,049 | 3,518 | Declarations, statements, expressions, built-ins, recovery, warnings | | |
| 23 | +| `src/Parse.raz` | 4,065 | 3,532 | Declarations, statements, expressions, built-ins, recovery, warnings | | |
| 24 | 24 | | `src/Link.raz` | 381 | 298 | Tree shaking, layout, patching, the places | |
| 25 | 25 | | `src/Elf.raz` | 431 | 344 | Static and dynamic ELF, symbol table, line numbers | |
| 26 | 26 | | `src/Raz.raz` | 305 | 238 | The command line | |
| @@ -1384,7 +1384,11 @@ | ||
| 1384 | 1384 | with gen's labels. A branch of an `if` that ends, in `return` or |
| 1385 | 1385 | `break` (`ends`), gets no jump past the others; and `if c then break; |
| 1386 | 1386 | end` is one jump out of the loop where `c` holds (`thenPart`, |
| 1387 | -`loneBreak`, and `Item.condJumpTrue`), not a jump past a jump. A `for` loop | |
| 1387 | +`loneJump`, and `Item.condJumpTrue`), not a jump past a jump; so is | |
| 1388 | +`if c then continue; end`, to the end of the round. A loop keeps two | |
| 1389 | +chains of jumps in its `Loop`: `brk`, fixed after the loop, and | |
| 1390 | +`cont`, for `continue` (report 2026-10.31), fixed where the round ends: | |
| 1391 | +a `while`'s test, a `repeat`'s `until`, a `for`'s step (`forNext`). A `for` loop | |
| 1388 | 1392 | steps its variable at the top and tests at the bottom, so that a round |
| 1389 | 1393 | by 1 is one compare and one jump; its rare case, a body that moves the |
| 1390 | 1394 | variable past the limit, has code of its own after (`Item.forNext`, whose |
| @@ -1410,7 +1414,7 @@ | ||
| 1410 | 1414 | is compiled where it stands, as a little subroutine of the procedure |
| 1411 | 1415 | that the code jumps over (gen's `deferBegin` and `deferEnd`), and |
| 1412 | 1416 | `runDefers` emits a call to it at every way out of its statement list: |
| 1413 | -the end, `return` and `break`. A `return`'s result waits in the frame | |
| 1417 | +the end, `return`, `break` and `continue`. A `return`'s result waits in the frame | |
| 1414 | 1418 | meanwhile, so that gen's stack is empty when they run. |
| 1415 | 1419 | |
| 1416 | 1420 | `try` (report 7.8) is `tryCall`, for the statement, an operand |
| @@ -1769,5 +1773,12 @@ | ||
| 1769 | 1773 | to suit `src/`); a raz that already exists could do it as well. |
| 1770 | 1774 | `make fixpoint` has the seed's build compile `src/`, that compile it |
| 1771 | 1775 | again, and that again, and checks that the last two are the same file. |
| 1772 | -`make seed-check` tests each unit of `src/` against the seed's. After any change: `make check`, `make bench`, | |
| 1776 | +`make seed-check` tests each unit of `src/` against the seed's. The | |
| 1777 | +seed has no `continue`, the last reserved word of `src/Scan.raz`, so | |
| 1778 | +the Pascal dumpers in `src/test` use `seedcontinue`, which interns the | |
| 1779 | +name right after the seed's reserved words: every name then has the | |
| 1780 | +same number on both sides, and only the end of a file's symbols, one | |
| 1781 | +higher in `src/`, is renumbered (`ScanDump.raz`'s `seedSym`). A file | |
| 1782 | +that uses something the seed doesn't know is left out (`src/check.sh`'s | |
| 1783 | +`newer`). After any change: `make check`, `make bench`, | |
| 1773 | 1784 | `make loc`. |
| @@ -22,7 +22,7 @@ | ||
| 22 | 22 | :type 'integer :group 'raz) |
| 23 | 23 | |
| 24 | 24 | (defconst raz-keywords |
| 25 | - '("and" "begin" "break" "by" "code" "const" "defer" "div" "do" "else" | |
| 25 | + '("and" "begin" "break" "by" "code" "const" "continue" "defer" "div" "do" "else" | |
| 26 | 26 | "elsif" "end" "extern" "for" "forward" "if" "import" "in" "link" |
| 27 | 27 | "match" "mod" "module" "not" "of" "or" "packed" "proc" "record" |
| 28 | 28 | "repeat" "return" "set" "shl" "shr" "then" "to" "try" "type" "until" |
| @@ -8,7 +8,7 @@ | ||
| 8 | 8 | |
| 9 | 9 | syntax case match |
| 10 | 10 | |
| 11 | -syntax keyword razKeyword and begin break by code const defer div do else | |
| 11 | +syntax keyword razKeyword and begin break by code const continue defer div do else | |
| 12 | 12 | syntax keyword razKeyword elsif end extern for forward if import in link |
| 13 | 13 | syntax keyword razKeyword match mod module not of or packed proc record |
| 14 | 14 | syntax keyword razKeyword repeat return set shl shr then to try type until |
| @@ -34,10 +34,11 @@ | ||
| 34 | 34 | PModule = ^Sym.Module; |
| 35 | 35 | TItem = Item.Item; |
| 36 | 36 | |
| 37 | - (* The innermost loop: the chain of its breaks and the deferred | |
| 38 | - statements in force outside it *) | |
| 37 | + (* The innermost loop: the chain of its breaks, the chain of its | |
| 38 | + continues, and the deferred statements in force outside it *) | |
| 39 | 39 | Loop = record |
| 40 | 40 | brk: INT; |
| 41 | + cont: INT; | |
| 41 | 42 | base: INT; |
| 42 | 43 | end; |
| 43 | 44 | PLoop = ^Loop; |
| @@ -1598,6 +1599,7 @@ | ||
| 1598 | 1599 | proc enterLoop(var lp: Loop; var old: PLoop); |
| 1599 | 1600 | begin |
| 1600 | 1601 | lp.brk := Gen.NoLabel; |
| 1602 | + lp.cont := Gen.NoLabel; | |
| 1601 | 1603 | lp.base := numDefers; |
| 1602 | 1604 | old := curLoop; |
| 1603 | 1605 | curLoop := ADR(lp); |
| @@ -1610,13 +1612,17 @@ | ||
| 1610 | 1612 | for i := numDefers - 1 to base by -1 do Gen.runDefer(defers[i]); end; |
| 1611 | 1613 | end; |
| 1612 | 1614 | |
| 1613 | -(* Whether what follows "then" is a lone "break;", with no deferred | |
| 1614 | - statement to run on the way out of the loop: the break must be the | |
| 1615 | - branch's last statement, so ";" and then end, elsif or else follow. *) | |
| 1616 | -proc loneBreak: BOOL; | |
| 1615 | +(* Whether what follows "then" is a lone "break;" or "continue;", with | |
| 1616 | + no deferred statement to run on the way out of the round: it must be | |
| 1617 | + the branch's last statement, so ";" and then end, elsif or else | |
| 1618 | + follow. *) | |
| 1619 | +proc loneJump: BOOL; | |
| 1617 | 1620 | var st: Scan.State; lone: BOOL; |
| 1618 | 1621 | begin |
| 1619 | - if (Scan.tok # Scan.sBreak) or (curLoop = nil) or (numDefers # curLoop^.base) then return false; end; | |
| 1622 | + if ((Scan.tok # Scan.sBreak) and (Scan.tok # Scan.sContinue)) or (curLoop = nil) | |
| 1623 | + or (numDefers # curLoop^.base) then | |
| 1624 | + return false; | |
| 1625 | + end; | |
| 1620 | 1626 | Scan.saveScan(st); |
| 1621 | 1627 | lone := false; |
| 1622 | 1628 | Scan.next; |
| @@ -1630,15 +1636,17 @@ | ||
| 1630 | 1636 | |
| 1631 | 1637 | (* The condition x of if or elsif, and the statements it guards, which |
| 1632 | 1638 | L skips when it is false. "if c then break; end" is one jump out of |
| 1633 | - the loop when c holds, not one past a jump out. *) | |
| 1639 | + the loop when c holds, not one past a jump out; "if c then continue; | |
| 1640 | + end" one jump to the end of the round. *) | |
| 1634 | 1641 | proc thenPart(var x: TItem; var L: INT): ERROR; |
| 1635 | 1642 | begin |
| 1636 | 1643 | try expect(Scan.sThen); |
| 1637 | - L := Gen.NoLabel; (* stays so with a lone break: there is nothing to skip *) | |
| 1638 | - if loneBreak() then | |
| 1639 | - Chunk.noteLine(Scan.curLine(), Scan.curCol()); (* the jump gets the break's line *) | |
| 1640 | - try Item.condJumpTrue(x, curLoop^.brk); | |
| 1641 | - Scan.next; Scan.next; (* skip "break" and ";" *) | |
| 1644 | + L := Gen.NoLabel; (* stays so with a lone break or continue: there is nothing to skip *) | |
| 1645 | + if loneJump() then | |
| 1646 | + Chunk.noteLine(Scan.curLine(), Scan.curCol()); (* the jump gets the break's or continue's line *) | |
| 1647 | + if Scan.tok = Scan.sBreak then try Item.condJumpTrue(x, curLoop^.brk); | |
| 1648 | + else try Item.condJumpTrue(x, curLoop^.cont); end; | |
| 1649 | + Scan.next; Scan.next; (* skip "break" or "continue", and ";" *) | |
| 1642 | 1650 | ends := true; |
| 1643 | 1651 | else |
| 1644 | 1652 | try Item.condJump(x, L); |
| @@ -1716,6 +1724,7 @@ | ||
| 1716 | 1724 | Scan.saveScan(after); |
| 1717 | 1725 | Scan.restoreScan(cond); |
| 1718 | 1726 | Gen.fix(test); |
| 1727 | + Gen.fix(lp.cont); (* a continue goes to the test *) | |
| 1719 | 1728 | Chunk.noteLine(Scan.curLine(), Scan.curCol()); |
| 1720 | 1729 | try expression(x, nil); |
| 1721 | 1730 | ends := (x.mode = Item.mConst) and (x.val # 0) and (lp.brk = Gen.NoLabel); (* while true *) |
| @@ -1741,6 +1750,7 @@ | ||
| 1741 | 1750 | try statements(); |
| 1742 | 1751 | curLoop := old; |
| 1743 | 1752 | try expect(Scan.sUntil); |
| 1753 | + Gen.fix(lp.cont); (* a continue goes to the test *) | |
| 1744 | 1754 | try expression(x, nil); |
| 1745 | 1755 | ends := (x.mode = Item.mConst) and (x.val = 0) and (lp.brk = Gen.NoLabel); (* until false *) |
| 1746 | 1756 | L := Gen.NoLabel; |
| @@ -1823,6 +1833,7 @@ | ||
| 1823 | 1833 | try statements(); |
| 1824 | 1834 | curLoop := old; |
| 1825 | 1835 | try closeEnd(start, ind); |
| 1836 | + Gen.fix(lp.cont); (* a continue goes to the end of the round *) | |
| 1826 | 1837 | try Item.forNext(o, b, step, exitL, top, body); |
| 1827 | 1838 | Gen.fix(exitL); |
| 1828 | 1839 | Gen.fix(lp.brk); |
| @@ -2385,6 +2396,11 @@ | ||
| 2385 | 2396 | if curLoop = nil then return Scan.markAt(Scan.spanFrom(start), "break outside a loop"); end; |
| 2386 | 2397 | runDefers(curLoop^.base); |
| 2387 | 2398 | Gen.jump(curLoop^.brk); |
| 2399 | + | sContinue: | |
| 2400 | + Scan.next; | |
| 2401 | + if curLoop = nil then return Scan.markAt(Scan.spanFrom(start), "continue outside a loop"); end; | |
| 2402 | + runDefers(curLoop^.base); | |
| 2403 | + Gen.jump(curLoop^.cont); | |
| 2388 | 2404 | | sDefer: try deferStatement(); |
| 2389 | 2405 | | sTry: |
| 2390 | 2406 | try tryCall(x); |
| @@ -22,12 +22,14 @@ | ||
| 22 | 22 | sBecomes, sColon, sSemicolon, sComma, sPeriod, sUpto, sEllipsis, |
| 23 | 23 | sLparen, sRparen, sLbrak, sRbrak, sLbrace, sRbrace, sArrow, sAmp, sTilde, sBar, |
| 24 | 24 | sBlank, |
| 25 | - (* the reserved words, in the order of words below *) | |
| 25 | + (* the reserved words, in the order of words below: alphabetical | |
| 26 | + but for continue, which came last (report 2026-10.31), so that | |
| 27 | + the others keep the numbers the seed gives them *) | |
| 26 | 28 | sAnd, sBegin, sBreak, sBy, sCode, sConst, sDefer, sDiv, sDo, sElse, |
| 27 | 29 | sElsif, sEnd, sExtern, sFor, sForward, sIf, sImport, sIn, sLink, |
| 28 | 30 | sMatch, sMod, sModule, sNot, sOf, sOr, sPacked, sProc, sRecord, |
| 29 | 31 | sRepeat, sReturn, sSet, sShl, sShr, sThen, sTo, sTry, sType, sUntil, sVar, |
| 30 | - sVariant, sVolatile, sWhile, sXor, | |
| 32 | + sVariant, sVolatile, sWhile, sXor, sContinue, | |
| 31 | 33 | sEof); |
| 32 | 34 | |
| 33 | 35 | (* Where the scanner is. Importing a module compiles it in the middle |
| @@ -48,7 +50,7 @@ | ||
| 48 | 50 | Failed*: ERROR = "reported"; (* an error has been shown: the parser returns it *) |
| 49 | 51 | MaxIdent* = 63; |
| 50 | 52 | MaxStr* = 65536; |
| 51 | - NumWords = 43; | |
| 53 | + NumWords = 44; | |
| 52 | 54 | NumOps = 28; |
| 53 | 55 | words: [NumWords][]U8 = [ |
| 54 | 56 | "and", "begin", "break", "by", "code", "const", "defer", "div", "do", |
| @@ -56,7 +58,7 @@ | ||
| 56 | 58 | "in", "link", "match", "mod", "module", "not", "of", "or", "packed", |
| 57 | 59 | "proc", "record", "repeat", "return", "set", "shl", "shr", "then", |
| 58 | 60 | "to", "try", "type", "until", "var", "variant", "VOLATILE", "while", |
| 59 | - "xor"]; | |
| 61 | + "xor", "continue"]; | |
| 60 | 62 | (* sPlus to sBlank *) |
| 61 | 63 | ops: [NumOps][]U8 = [ |
| 62 | 64 | "+", "-", "*", "/", "=", "#", "<", "<=", ">", ">=", |
| @@ -15,8 +15,8 @@ | ||
| 15 | 15 | # and, through Math, test/bench/NBody.raz use; and returning a slice of |
| 16 | 16 | # the frame as an error (report 2026-10.27); an array constant typed |
| 17 | 17 | # []T (report 2026-10.29); [] as the empty slice, seen through a view |
| 18 | -# (report 2026-10.30); and U8, I8 and I16 widening to INT (report | |
| 19 | -# 2026-10.31). | |
| 18 | +# (report 2026-10.30); and U8, I8 and I16 widening to INT, and | |
| 19 | +# continue (report 2026-10.31). | |
| 20 | 20 | newer="conform/run/RawStrings.raz conform/err/ScanRawOpen.raz conform/err/ScanRawIndent.raz |
| 21 | 21 | conform/run/MatchStr.raz conform/err/MatchStrTwice.raz conform/err/MatchStrNoElse.raz |
| 22 | 22 | conform/err/MatchStrVar.raz conform/err/MatchReal.raz conform/err/AtMatch.raz |
| @@ -28,7 +28,9 @@ | ||
| 28 | 28 | conform/run/ArrayConstLen.raz conform/err/ArrayConstLenEmpty.raz conform/err/ArrayConstLenLiteral.raz |
| 29 | 29 | conform/run/EmptySlice.raz |
| 30 | 30 | conform/run/SmallWiden.raz conform/err/SmallWidenMade.raz conform/err/SmallWidenNeg.raz |
| 31 | - conform/err/SmallWidenI64.raz conform/err/SmallWidenMadeOp.raz" | |
| 31 | + conform/err/SmallWidenI64.raz conform/err/SmallWidenMadeOp.raz | |
| 32 | + conform/run/Continue.raz conform/err/ContinueOutside.raz conform/err/ContinueDefer.raz | |
| 33 | + conform/err/ContinueName.raz" | |
| 32 | 34 | newer() { |
| 33 | 35 | case $1 in conform/*/View*.raz) return 0 ;; esac |
| 34 | 36 | for g in $newer; do [ $g = $1 ] && return 0; done |
| @@ -5,7 +5,7 @@ | ||
| 5 | 5 | numbers, with a minus sign, and sums of them. } |
| 6 | 6 | program asmdump; |
| 7 | 7 | {$mode objfpc}{$H-} |
| 8 | -uses diag, scan, chunk, x64; | |
| 8 | +uses diag, scan, seedcontinue, chunk, x64; | |
| 9 | 9 | var i: longint; path: string; |
| 10 | 10 | |
| 11 | 11 | function ConstVal(whole: boolean): int64; |
| @@ -3,7 +3,7 @@ | ||
| 3 | 3 | ChunkDump.raz does the same and prints the same. } |
| 4 | 4 | program chunkdump; |
| 5 | 5 | {$mode objfpc}{$H-} |
| 6 | -uses diag, scan, chunk; | |
| 6 | +uses diag, scan, seedcontinue, chunk; | |
| 7 | 7 | var |
| 8 | 8 | seed: int64; |
| 9 | 9 | names: array[0..7] of longint; |
| @@ -5,7 +5,7 @@ | ||
| 5 | 5 | argument, the entry point is the dynamic one. } |
| 6 | 6 | program gendump; |
| 7 | 7 | {$mode objfpc}{$H-} |
| 8 | -uses diag, scan, sym, chunk, x64, gen; | |
| 8 | +uses diag, scan, seedcontinue, sym, chunk, x64, gen; | |
| 9 | 9 | |
| 10 | 10 | const |
| 11 | 11 | FirstProc = 3; |
| @@ -8,7 +8,7 @@ | ||
| 8 | 8 | so several scripts are run. } |
| 9 | 9 | program itemdump; |
| 10 | 10 | {$mode objfpc}{$H-} |
| 11 | -uses diag, scan, sym, chunk, x64, gen, item; | |
| 11 | +uses diag, scan, seedcontinue, sym, chunk, x64, gen, item; | |
| 12 | 12 | |
| 13 | 13 | const |
| 14 | 14 | FirstProc = 3; |
| @@ -5,7 +5,7 @@ | ||
| 5 | 5 | the same and writes the same file. } |
| 6 | 6 | program linkdump; |
| 7 | 7 | {$mode objfpc}{$H-} |
| 8 | -uses diag, scan, chunk, link, elf; | |
| 8 | +uses diag, scan, seedcontinue, chunk, link, elf; | |
| 9 | 9 | const NumC = 200; |
| 10 | 10 | var |
| 11 | 11 | seed: int64; |
| @@ -2,7 +2,7 @@ | ||
| 2 | 2 | against src/Scan.raz (ScanBench.raz). } |
| 3 | 3 | program scanbench; |
| 4 | 4 | {$mode objfpc}{$H-} |
| 5 | -uses diag, scan; | |
| 5 | +uses diag, scan, seedcontinue; | |
| 6 | 6 | var n: longint; |
| 7 | 7 | begin |
| 8 | 8 | if Open(ParamStr(1)) <> '' then Fatal('no file'); |
| @@ -3,7 +3,7 @@ | ||
| 3 | 3 | so that no formatting library decides what is the same. } |
| 4 | 4 | program scandump; |
| 5 | 5 | {$mode objfpc}{$H-} |
| 6 | -uses diag, scan; | |
| 6 | +uses diag, scan, seedcontinue; | |
| 7 | 7 | var i: longint; bits: int64; |
| 8 | 8 | begin |
| 9 | 9 | if Open(ParamStr(1)) <> '' then Fatal('no file'); |
| @@ -1,8 +1,18 @@ | ||
| 1 | 1 | (* Prints the symbols of a file, one per line: src/Scan.raz's side of a |
| 2 | - test against the seed's, ScanDump.pas, which prints the same. *) | |
| 2 | + test against the seed's, ScanDump.pas, which prints the same. The | |
| 3 | + symbols are numbered as the seed numbers them: it has no continue | |
| 4 | + (report 2026-10.31), the last reserved word here, so its end of the | |
| 5 | + file is one lower. A file with continue in it isn't compared. *) | |
| 3 | 6 | module ScanDump; |
| 4 | 7 | import Out, Fmt, Files, Diag, Scan; |
| 5 | 8 | |
| 9 | +(* s as the seed numbers it *) | |
| 10 | +proc seedSym(s: Scan.Sym): INT; | |
| 11 | +begin | |
| 12 | + if s = Scan.sEof then return INT(s) - 1; end; | |
| 13 | + return INT(s); | |
| 14 | +end; | |
| 15 | + | |
| 6 | 16 | proc main*; |
| 7 | 17 | var p: Diag.Pos; bits: ^U64; i: INT; str: []U8; r: F64; |
| 8 | 18 | begin |
| @@ -11,7 +21,7 @@ | ||
| 11 | 21 | Scan.next; |
| 12 | 22 | p := Scan.tokPos(); |
| 13 | 23 | Fmt.print("{}:{}:{} {}:{} {}", [Fmt.int(Diag.lineOf(p)), Fmt.int(p.a), Fmt.int(p.b), |
| 14 | - Fmt.int(Scan.curLine()), Fmt.int(Scan.curCol()), Fmt.int(INT(Scan.tok))]); | |
| 24 | + Fmt.int(Scan.curLine()), Fmt.int(Scan.curCol()), Fmt.int(seedSym(Scan.tok))]); | |
| 15 | 25 | match Scan.tok of |
| 16 | 26 | | sIdent: Fmt.print(" {} {}", [Fmt.str(Scan.nameOf(Scan.id)), Fmt.int(Scan.id)]); |
| 17 | 27 | | sInt: Fmt.print(" {}", [Fmt.int(Scan.ival)]); |
| @@ -5,7 +5,7 @@ | ||
| 5 | 5 | declared twice, or of too many scopes. } |
| 6 | 6 | program symdump; |
| 7 | 7 | {$mode objfpc}{$H-} |
| 8 | -uses diag, scan, sym; | |
| 8 | +uses diag, scan, seedcontinue, sym; | |
| 9 | 9 | const |
| 10 | 10 | Words: array[0..19] of string = ('alpha', 'alpho', 'beta', 'bet', 'gamma', 'gama', 'delta', 'Delta', |
| 11 | 11 | 'eps', 'zeta', 'eta', 'theta', 'iota', 'kappa', 'lambda', 'mu', 'nu', 'xi', 'omicron', 'pi'); |
| @@ -4,7 +4,7 @@ | ||
| 4 | 4 | src/X64.raz, whose X64Dump.raz does the same and prints the same. } |
| 5 | 5 | program x64dump; |
| 6 | 6 | {$mode objfpc}{$H-} |
| 7 | -uses diag, scan, chunk, x64; | |
| 7 | +uses diag, scan, seedcontinue, chunk, x64; | |
| 8 | 8 | var |
| 9 | 9 | seed: int64; |
| 10 | 10 | i, k, op, a, b, c, d, lab1, lab2: longint; |
| @@ -0,0 +1,20 @@ | ||
| 1 | +{ The seed has no continue, which report 2026-10.31 made a reserved | |
| 2 | + word, the last of them in src/Scan.raz. This unit interns the name | |
| 3 | + right after the seed's reserved words, before any other, so that | |
| 4 | + every name after it has the number src/ gives it: each dumper that is | |
| 5 | + compared with src/'s side uses it straight after scan. } | |
| 6 | +unit seedcontinue; | |
| 7 | + | |
| 8 | +{$mode objfpc}{$H-} | |
| 9 | + | |
| 10 | +interface | |
| 11 | + | |
| 12 | +implementation | |
| 13 | + | |
| 14 | +uses scan; | |
| 15 | + | |
| 16 | +const Word: string = 'continue'; | |
| 17 | + | |
| 18 | +initialization | |
| 19 | + Intern(@Word[1], length(Word)); | |
| 20 | +end. |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/ContinueDefer.raz:7:15: error: continue outside a loop | |
| 2 | + 7 | defer continue; | |
| 3 | + | ^^^^^^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/ContinueName.raz:3:5: error: expected "begin", found "continue" | |
| 2 | + 3 | var continue: INT; | |
| 3 | + | ^^^^^^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/ContinueOutside.raz:4:5: error: continue outside a loop | |
| 2 | + 4 | continue; | |
| 3 | + | ^^^^^^^^ | |
| 4 | +raz: 1 error |
| @@ -20,7 +20,7 @@ | ||
| 20 | 20 | end; |
| 21 | 21 | |
| 22 | 22 | const |
| 23 | - words = "and begin break by code const defer div do else elsif end extern for forward if import in link match mod module not of or packed proc record repeat return set shl shr then to try type until var variant VOLATILE while xor"; | |
| 23 | + words = "and begin break by code const continue defer div do else elsif end extern for forward if import in link match mod module not of or packed proc record repeat return set shl shr then to try type until var variant VOLATILE while xor"; | |
| 24 | 24 | |
| 25 | 25 | proc isSpace*(c: U8): BOOL; |
| 26 | 26 | begin |