Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00043 #ifndef parser_f_h
00044 #define parser_f_h
00045
00046 #include "../comp_defs.h"
00047 #include "../str.h"
00048
00049 char* eat_line(char* buffer, unsigned int len);
00050
00051
00052
00053 inline static char* eat_space_end(const char* p, const char* pend)
00054 {
00055 for(;(p<pend)&&(*p==' ' || *p=='\t') ;p++);
00056 return (char *)p;
00057 }
00058 #define SP(_c) ((_c)=='\t' || (_c)==' ')
00059 inline static char* eat_lws_end(const char* p, const char* pend)
00060 {
00061 while(p<pend) {
00062 if (SP(*p)) p++;
00063
00064 else if (*p=='\n' && p+1<pend && SP(*(p+1))) p+=2;
00065 else if (*p=='\r' && p+2<pend && *(p+1)=='\n'
00066 && SP(*(p+2))) p+=3;
00067 else break;
00068 }
00069 return (char *)p;
00070 }
00071
00072
00073
00074 inline static char* eat_token_end(const char* p, const char* pend)
00075 {
00076 for (;(p<pend)&&(*p!=' ')&&(*p!='\t')&&(*p!='\n')&&(*p!='\r'); p++);
00077 return (char *)p;
00078 }
00079
00080
00081
00082 inline static char* eat_token2_end(const char* p, const char* pend, char delim)
00083 {
00084 for (;(p<pend)&&(*p!=(delim))&&(*p!='\n')&&(*p!='\r'); p++);
00085 return (char *)p;
00086 }
00087
00088
00089
00090 inline static int is_empty_end(const char* p, const char* pend )
00091 {
00092 p=eat_space_end(p, pend );
00093 return ((p<(pend )) && (*p=='\r' || *p=='\n'));
00094 }
00095
00096
00097
00098
00099
00100 inline static char* find_not_quoted(str* _s, char _c)
00101 {
00102 int quoted = 0, i;
00103
00104 for(i = 0; i < _s->len; i++) {
00105 if (!quoted) {
00106 if (_s->s[i] == '\"') quoted = 1;
00107 else if (_s->s[i] == _c) return _s->s + i;
00108 } else {
00109 if ((_s->s[i] == '\"') && (_s->s[i - 1] != '\\')) quoted = 0;
00110 }
00111 }
00112 return 0;
00113 }
00114
00115
00116 #endif