Flexible Bible Reference Parser
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
681 B

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include "fbrp.h"
  5. struct Reference ref;
  6. void debugPrint(struct Reference *ref) {
  7. printf("Book: %s\n", ref->book);
  8. for (size_t c = 0; c < ref->chapterLength; c++) {
  9. printf("Chapter: %d-%d\n", ref->chapter[c].r[0], ref->chapter[c].r[1]);
  10. }
  11. for (size_t c = 0; c < ref->verseLength; c++) {
  12. printf("Verse: %d-%d\n", ref->verse[c].r[0], ref->verse[c].r[1]);
  13. }
  14. }
  15. void parse(char *text) {
  16. puts(text);
  17. parseReference(&ref, text);
  18. debugPrint(&ref);
  19. putchar('\n');
  20. }
  21. int main() {
  22. char ref1[] = "ABCDEFGHIJKLMNOPQSRTYCUVZ 3 16";
  23. char ref2[] = "John 3 16-20, 17, 18-19";
  24. parse(ref1);
  25. parse(ref2);
  26. return 0;
  27. }