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.

38 lines
905 B

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include "fbrp.h"
  5. struct FbrpReference ref;
  6. void debugPrint(struct FbrpReference *ref) {
  7. printf("Book: %s\n", ref->book);
  8. for (int c = 0; c < ref->chapterLength; c++) {
  9. printf("Chapter: [%d]-[%d]\n", ref->chapter[c].range[0], ref->chapter[c].range[1]);
  10. }
  11. for (int c = 0; c < ref->verseLength; c++) {
  12. printf("Verse: [%d]-[%d]\n", ref->verse[c].range[0], ref->verse[c].range[1]);
  13. }
  14. }
  15. void parse(char *text) {
  16. puts(text);
  17. fbrp_parse(&ref, text);
  18. debugPrint(&ref);
  19. puts("------");
  20. }
  21. int main() {
  22. parse("1Kgs 1, 3-5:2-4, 3-6, 1-2");
  23. parse("John 3 16-20, 17, 18-19");
  24. parse("1 John 3-4 16-17-18-19,-,-,-");
  25. parse("2983yr92y8392r839");
  26. parse("8AUW8DQ98DU98SD9W87DUASDJA");
  27. parse("AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH!!!");
  28. parse("John 3 4294967312"); // == John 3 16 (uint overflow)
  29. parse("John 3 v16");
  30. return 0;
  31. }