tmsrp_machine_utils.rl 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * Copyright (C) 2009 Mamadou Diop.
  3. *
  4. * Contact: Mamadou Diop <diopmamadou(at)doubango.org>
  5. *
  6. * This file is part of Open Source Doubango Framework.
  7. *
  8. * DOUBANGO is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * DOUBANGO is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with DOUBANGO.
  20. *
  21. */
  22. /**@file tsip_machine_utils.rl
  23. * @brief Ragel file.
  24. *
  25. * @author Mamadou Diop <diopmamadou(at)doubango.org>
  26. *
  27. */
  28. %%{
  29. machine tmsrp_machine_utils;
  30. OCTET = "0x"[0-9A-Fa-f]+;
  31. CHAR = 0x01..0x7f;
  32. VCHAR = 0x21..0x7e;
  33. ALPHA = 0x41..0x5a | 0x61..0x7a;
  34. DIGIT = 0x30..0x39;
  35. CTL = 0x00..0x1f | 0x7f;
  36. HTAB = "\t";
  37. LF = "\n";
  38. CR = "\r";
  39. SP = " ";
  40. DQUOTE = "\"";
  41. BIT = "0" | "1";
  42. HEXDIG = DIGIT | "A"i | "B"i | "C"i | "D"i | "E"i | "F"i;
  43. CRLF = CR LF;
  44. WSP = SP | HTAB;
  45. LWSP = ( WSP | ( CRLF WSP ) )*;
  46. LWS = ( WSP* CRLF )? WSP+;
  47. SWS = LWS?;
  48. EQUAL = SWS "=" SWS;
  49. LHEX = DIGIT | 0x61..0x66;
  50. HCOLON = ( SP | HTAB )* ":" SWS;
  51. separators = "(" | ")" | "<" | ">" | "@" | "," | ";" | ":" | "\\" | DQUOTE | "/" | "[" | "]" | "?" | "=" | "{" | "}" | SP | HTAB;
  52. STAR = SWS "*" SWS;
  53. SLASH = SWS "/" SWS;
  54. LPAREN = SWS "(" SWS;
  55. RPAREN = SWS ")" SWS;
  56. COMMA = SWS "," SWS;
  57. SEMI = SWS ";" SWS;
  58. COLON = SWS ":" SWS;
  59. LAQUOT = SWS "<";
  60. LDQUOT = SWS DQUOTE;
  61. RAQUOT = ">" SWS;
  62. RDQUOT = DQUOTE SWS;
  63. UTF8_CONT = 0x80..0xbf;
  64. ##### FIXME: UTF8_NONASCII up to 2bytes will fail on Android
  65. UTF8_NONASCII = ( 0x80..0xff );
  66. #UTF8_NONASCII = ( 0xc0..0xdf UTF8_CONT ) | ( 0xe0..0xef UTF8_CONT{2} ) | ( 0xf0..0xf7 UTF8_CONT{3} ) | ( 0xf8..0xfb UTF8_CONT{4} ) | ( 0xfc..0xfd UTF8_CONT{5} ); ctext = 0x21..0x27 | 0x2a..0x5b | 0x5d..0x7e | UTF8_NONASCII | LWS;
  67. qvalue = ( "0" ( "." DIGIT{,3} )? ) | ( "1" ( "." "0"{,3} )? );
  68. alphanum = ALPHA | DIGIT;
  69. token = ( alphanum | "-" | "." | "!" | "%" | "*" | "_" | "+" | "`" | "'" | "~" )+;
  70. ietf_token = token;
  71. x_token = "x-"i token;
  72. iana_token = token;
  73. token_nodot = ( alphanum | "-" | "!" | "%" | "*" | "_" | "+" | "`" | "'" | "~" )+;
  74. word = ( alphanum | "-" | "." | "!" | "%" | "*" | "_" | "+" | "`" | "'" | "~" | "(" | ")" | "<" | ">" | ":" | "\\" | DQUOTE | "/" | "[" | "]" | "?" | "{" | "}" )+;
  75. domainlabel = alphanum | ( alphanum ( alphanum | "-" )* alphanum );
  76. toplabel = ALPHA | ( ALPHA ( alphanum | "-" )* alphanum );
  77. hostname = ( domainlabel "." )* toplabel "."?;
  78. IPv4address = DIGIT{1,3} "." DIGIT{1,3} "." DIGIT{1,3} "." DIGIT{1,3};
  79. hex4 = HEXDIG{1,4};
  80. hexseq = hex4 ( ":" hex4 )*;
  81. hexpart = hexseq | ( hexseq "::" hexseq? ) | ( "::" hexseq? );
  82. IPv6address = hexpart ( ":" IPv4address )?;
  83. IPv6reference = "[" IPv6address "]";
  84. host = hostname | IPv4address | IPv6reference;
  85. qdtext = LWS | "!" | 0x23..0x5b | 0x5d..0x7e | UTF8_NONASCII;
  86. quoted_pair = "\\" ( 0x00..0x09 | 0x0b..0x0c | 0x0e..0x7f );
  87. quoted_string = SWS DQUOTE ( qdtext | quoted_pair )* DQUOTE;
  88. gen_value = token | host | quoted_string;
  89. generic_param = token ( EQUAL gen_value )?;
  90. accept_param = ( "q"i EQUAL qvalue ) | generic_param;
  91. mark = "-" | "_" | "." | "!" | "~" | "*" | "'" | "(" | ")";
  92. unreserved = alphanum | mark;
  93. escaped = "%" HEXDIG HEXDIG;
  94. user_unreserved = "&" | "=" | "+" | "$" | "," | ";" | "?" | "/";
  95. user = ( unreserved | escaped | user_unreserved )+;
  96. visual_separator = "-" | "." | "(" | ")";
  97. phonedigit = DIGIT | visual_separator?;
  98. global_number_digits = "+" phonedigit* DIGIT phonedigit*;
  99. param_unreserved = "[" | "]" | "/" | ":" | "&" | "+" | "$";
  100. pct_encoded = "%" HEXDIG HEXDIG;
  101. paramchar = param_unreserved | unreserved | pct_encoded;
  102. pname = paramchar+;
  103. pvalue = paramchar+;
  104. parameter = ";" pname ( "=" pvalue )?;
  105. port = DIGIT+;
  106. gen_delims = ":" | "/" | "?" | "#" | "[" | "]" | "@";
  107. sub_delims = "!" | "$" | "&" | "'" | "(" | ")" | "*" | "+" | "," | ";" | "=";
  108. utf8text = (HTAB | 0x20..0x7e | UTF8_NONASCII)*;
  109. UPALPHA = 0x41..0x5A;
  110. hname = ALPHA *token;
  111. hval = utf8text;
  112. ident_char = alphanum | "." | "-" | "+" | "%" | "=";
  113. ident = alphanum ident_char{3,31};
  114. }%%