Fixed no-break.

This commit is contained in:
Neil 2022-07-05 19:21:56 -07:00
parent 5ed98f035d
commit debffaf7a6
3 changed files with 37 additions and 9 deletions

View File

@ -84,14 +84,15 @@ static union date32 date_to_32(const int y, const int m, const int d) {
/* Leap year calculations only work at y>=1 and Gregorian Calendar and max
23 bits. */
if(y < 1582 || y > 8388607 || m < 1 || m > 12 || d < 1 || d > 31)
return d32;
goto no;
switch(m) {
case 1: case 3: case 5: case 7: case 8: case 10: case 12: break;
case 4: case 6: case 9: case 11: if(d > 30) return d32; break;
case 2: if(d > 28 + leap(y)) return d32;
case 4: case 6: case 9: case 11: if(d > 30) goto no; break;
case 2: if(d > 28 + leap(y)) goto no; break;
default: assert(0); break;
}
d32.year = (unsigned)y, d32.month = (unsigned)m, d32.day = (unsigned)d;
no:
return d32;
}
@ -268,7 +269,7 @@ finally:
struct page *const page = entry.value;
char z[12];
date32_to_string(*entry.key, &z);
printf("Page %s gone.\n", z);
printf("Freeing %s.\n", z);
lex_array_(&page->lexx);
char_array_(&page->entry);
}

View File

@ -18,7 +18,10 @@ int lex_looks_like_day(const char *);
X(SIGNIFICANT), X(SIGNIFICANT_RECALL), \
\
/* Arguments. */ \
X(ARG_KEYWORD), X(ARG_DATE), X(ARG_NATURAL), X(ARG_FREEFORM)
X(ARG_KEYWORD), X(ARG_DATE), X(ARG_NATURAL), X(ARG_FREEFORM), \
\
/* Bible */ \
X(BIBLE_BOOK), X(BIBLE_CHAPTER_VERSE), X(BIBLE_TEXT), X(BIBLE_NEXT)
struct lex {
#define X(n) n

View File

@ -159,14 +159,38 @@ scan:
<line> "--" :=> source
<line> "->" :=> location
<line> "[" :=> edict
<line> "" / glyph :=> text
<line> ws* / glyph :=> text
<text> newline => line { x->line = ++scan.line; goto scan; }
<text> ws+ { goto scan; }
<text, bible> newline => line { x->line = ++scan.line; goto scan; }
<text, bible> ws+ { goto scan; }
<text> @s0 glyph+ @s1
{ x->s0 = s0, x->s1 = s1; return x->symbol = TEXT, 1; }
<source> @s0 keyword @s1 => expect_line
roman1 = "1"|"I";
roman2 = roman1|"2"|"II";
roman3 = roman2|"3"|"III";
<line> @s0 ("Genesis" | "Exodus" | "Leviticus" | "Numbers" | "Deuteronomy"
| "Joshua" | "Judges" | "Ruth" | roman2 " Samuel" | roman2 " Kings"
| roman2 " Chronicles" | "Ezra" | "Nehemiah" | "Esther" | "Job"
| "Psalms" | "Proverbs" | "Ecclesiastes" | "Song of Solomon" | "Isaiah"
| "Jeremiah" | "Lamentations" | "Ezekiel" | "Daniel" | "Hosea" | "Joel"
| "Amos" | "Obadiah" | "Jonah" | "Micah" | "Nahum" | "Habakkuk"
| "Zephaniah" | "Haggai" | "Zechariah" | "Malachi" | "Matthew" | "Mark"
| "Luke" | "John" | "Acts" | "Romans" | roman2 " Corinthians"
| "Galatians" | "Ephesians" | "Philippians" | "Colossians"
| roman2 " Thessalonians" | roman2 " Timothy" | "Titus" | "Philemon"
| "Hebrews" | "James" | roman2 " Peter" | roman3 " John" | "Jude"
| "Revelation") @s1 ws* / natural ":" natural ws* "--" ws* "``" [A-Z]
=> bible { x->s0 = s0, x->s1 = s1; return x->symbol = BIBLE_BOOK, 1; }
<bible> @s0 natural ":" natural @s1 ws* "--" ws* "``" / [A-Z]
{ x->s0 = s0, x->s1 = s1; return x->symbol = BIBLE_CHAPTER_VERSE, 1; }
<bible> "``" { return x->symbol = BIBLE_NEXT, 1; }
<bible> @s0 glyph+ @s1
{ x->s0 = s0, x->s1 = s1; return x->symbol = BIBLE_TEXT, 1; }
<bible> "''" :=> expect_line
<source> @s0 keyword @s1 => expect_line
{ x->s0 = s0, x->s1 = s1; return x->symbol = SOURCE_RECALL, 1; }
<location> "" / "(" :=> map