Okay, this is really strange, s0, s1 are corrupted?
This commit is contained in:
parent
ba74302f04
commit
4accda5d56
@ -174,14 +174,14 @@ static int bible_graph(/*const*/ struct page_tree *const journal) {
|
||||
case BIBLE_BOOK:
|
||||
if(state != CHILL && state != WORD) goto catch;
|
||||
if(state == WORD) printf("\n");
|
||||
fprintf(stderr, "%d-%.2d-%.2d: %.*s ",
|
||||
fprintf(stderr, "%d-%.2d-%.2d: \"%.*s\", ",
|
||||
entry.key->year, entry.key->month, entry.key->day,
|
||||
(int)(lex->s1 - lex->s0), lex->s0);
|
||||
state = BOOK;
|
||||
break;
|
||||
case BIBLE_CHAPTER_VERSE:
|
||||
if(state != BOOK) goto catch;
|
||||
printf("%.*s -- \"", (int)(lex->s1 - lex->s0), lex->s0);
|
||||
printf("\"%.*s\", \"", (int)(lex->s1 - lex->s0), lex->s0);
|
||||
state = CHAPTER;
|
||||
break;
|
||||
case BIBLE_NEXT:
|
||||
@ -191,8 +191,8 @@ static int bible_graph(/*const*/ struct page_tree *const journal) {
|
||||
case BIBLE_TEXT:
|
||||
if(state != WORD && state != CHAPTER && state != NEXT)
|
||||
goto catch;
|
||||
printf("%s%.*s", state == WORD ? "*" : "",
|
||||
(int)(lex->s1 - lex->s0), lex->s0);
|
||||
printf("%s%.*s<%d>", state == WORD ? "*" : "",
|
||||
(int)(lex->s1 - lex->s0 < 0 ? 10 : lex->s1 - lex->s0), lex->s0, (int)(lex->s1 - lex->s0));
|
||||
count++;
|
||||
state = WORD;
|
||||
break;
|
||||
@ -322,9 +322,8 @@ int main(int argc, char **argv) {
|
||||
syntax:
|
||||
fprintf(stderr, "On date: %d-%.2d-%.2d.\n", *y, *m, *d);
|
||||
if(!page) goto catch;
|
||||
fprintf(stderr, "While parsing <<<\n%s>>>.\n",
|
||||
page->entry.data);
|
||||
if(!lex) goto catch;
|
||||
if(!lex) { fprintf(stderr, "While parsing <<<\n%s>>>.\n",
|
||||
page->entry.data); goto catch; }
|
||||
for(struct lex_array_iterator it
|
||||
= lex_array_iterator(&page->meaning);
|
||||
lex = lex_array_next(&it); ) {
|
||||
|
@ -27,7 +27,7 @@ struct lex {
|
||||
#define X(n) n
|
||||
enum lex_symbol { LEX_SYMBOL } symbol;
|
||||
#undef X
|
||||
int ws_before, new_paragraph;
|
||||
/*int ws_before, new_paragraph; ???*/
|
||||
const char *s0, *s1;
|
||||
size_t line;
|
||||
};
|
||||
|
@ -167,32 +167,35 @@ scan:
|
||||
<text> @s0 glyph+ @s1
|
||||
{ x->s0 = s0, x->s1 = s1; return x->symbol = TEXT, 1; }
|
||||
|
||||
roman1 = "1"|"I";
|
||||
roman2 = roman1|"2"|"II";
|
||||
roman3 = roman2|"3"|"III";
|
||||
bible_ref = natural ":" natural [ab]? ("-" (natural ":")? natural [ab]?)?;
|
||||
glyph_minus = glyph \ ['];
|
||||
|
||||
<text> @s0 ("Genesis" | "Exodus" | "Leviticus" | "Numbers" | "Deuteronomy"
|
||||
| "Joshua" | "Judges" | "Ruth" | roman2 " Samuel" | roman2 " Kings"
|
||||
| roman2 " Chronicles" | "Ezra" | "Nehemiah" | "Esther" | "Job"
|
||||
| "Joshua" | "Judges" | "Ruth" | "I"{1,2} " Samuel" | "I"{1,2} " Kings"
|
||||
| "I"{1,2} " 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"
|
||||
| "Luke" | "John" | "Acts" | "Romans" | "I"{1,2} " Corinthians"
|
||||
| "Galatians" | "Ephesians" | "Philippians" | "Colossians"
|
||||
| roman2 " Thessalonians" | roman2 " Timothy" | "Titus" | "Philemon"
|
||||
| "Hebrews" | "James" | roman2 " Peter" | roman3 " John" | "Jude"
|
||||
| "I"{1,2} " Thessalonians" | "I"{1,2} " Timothy" | "Titus" | "Philemon"
|
||||
| "Hebrews" | "James" | "I"{1,2} " Peter" | "I"{1,3} " John" | "Jude"
|
||||
| "Revelation") @s1 ws* / bible_ref ws+ "--" ws+ "``"
|
||||
=> bible { x->s0 = s0, x->s1 = s1; return x->symbol = BIBLE_BOOK, 1; }
|
||||
<bible> @s0 bible_ref @s1 ws+ "--" ws+ "``"
|
||||
{ x->s0 = s0, x->s1 = s1; return x->symbol = BIBLE_CHAPTER_VERSE, 1; }
|
||||
<bible> "``" { return x->symbol = BIBLE_NEXT, 1; }
|
||||
<bible> "''" => expect_line { printf("**reset;\n"); }
|
||||
/* HACK! Bible verses generally don't contain apostrophes. */
|
||||
<bible> @s0 (glyph \ ['])+ @s1
|
||||
<bible> "''" :=> text
|
||||
/* fixme: This is a hack that doesn't allow apostrophes at the end of a
|
||||
word, (not sure there are any in the bible.) Is ' terminated by '';
|
||||
otherwise same as glyph+ above. */
|
||||
<bible> @s0 (glyph_minus+ ("'" glyph_minus+)*) | (("'" glyph_minus+)+) @s1
|
||||
{ x->s0 = s0, x->s1 = s1; return x->symbol = BIBLE_TEXT, 1; }
|
||||
<bible> newline { x->line = ++scan.line; goto scan; }
|
||||
/* Multiple verses can be present, but they end in ''.
|
||||
Not strictly enforced. */
|
||||
<bible> newline / (newline | "``") { x->line = ++scan.line; goto scan; }
|
||||
<bible> newline { return x->symbol = SYNTAX, 0; }
|
||||
|
||||
<source> @s0 keyword @s1 => expect_line
|
||||
{ x->s0 = s0, x->s1 = s1; return x->symbol = SOURCE_RECALL, 1; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user