gml_scanner.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * Copyright 2021 籽籮籮 籵籮籮籯类籲籷籰
  3. * (C) Universitaet Passau 1986-1991
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. *
  17. * These are the four essential freedoms with GNU GPL software:
  18. * 1: freedom to run the program, for any purpose
  19. * 2: freedom to study how the program works, and change it to make it do what you wish
  20. * 3: freedom to redistribute copies to help your Free Software friends
  21. * 4: freedom to distribute copies of your modified versions to your Free Software friends
  22. * , ,
  23. * / \
  24. * ((__-^^-,-^^-__))
  25. * `-_---' `---_-'
  26. * `--|o` 'o|--'
  27. * \ ` /
  28. * ): :(
  29. * :o_o:
  30. * "-"
  31. */
  32. #ifndef GML_SCANNER_H
  33. #define GML_SCANNER_H 1
  34. /*
  35. * start-size of buffers for reading strings. If too small it will be enlarged
  36. * dynamically
  37. */
  38. #define INITIAL_SIZE 1024
  39. typedef enum
  40. {
  41. GML_KEY, GML_INT, GML_DOUBLE, GML_STRING, GML_L_BRACKET,
  42. GML_R_BRACKET, GML_END, GML_LIST, GML_ERROR
  43. } GML_value;
  44. typedef enum
  45. {
  46. GML_UNEXPECTED, GML_SYNTAX, GML_PREMATURE_EOF, GML_TOO_MANY_DIGITS,
  47. GML_OPEN_BRACKET, GML_TOO_MANY_BRACKETS, GML_OK
  48. } GML_error_value;
  49. struct GML_error
  50. {
  51. GML_error_value err_num;
  52. int line;
  53. int column;
  54. };
  55. union GML_tok_val
  56. {
  57. long integer;
  58. double floating;
  59. char *string;
  60. struct GML_error err;
  61. };
  62. struct GML_token
  63. {
  64. GML_value kind;
  65. union GML_tok_val value;
  66. };
  67. /*
  68. * global variables
  69. */
  70. extern unsigned int GML_line;
  71. extern unsigned int GML_column;
  72. /*
  73. * if you are interested in the position where an error occured it is a good
  74. * idea to set GML_line and GML_column back.
  75. * This is what GML_init does.
  76. */
  77. extern void GML_init (void);
  78. /*
  79. * returns the next token in file. If an error occured it will be stored in
  80. * GML_token.
  81. */
  82. extern struct GML_token GML_scanner (FILE *);
  83. extern int GML_search_ISO (char *str, int len);
  84. #endif
  85. /* end */