smalltalk
/
osmo-st-sip
Archived
1
0
Fork 0

grammar: Parse the Contact header properly

This commit is contained in:
Holger Hans Peter Freyther 2011-06-29 17:52:25 +02:00
parent ed42decd4a
commit 460b67e743
1 changed files with 50 additions and 2 deletions

View File

@ -21,7 +21,7 @@ PackageLoader fileInPackage: 'PetitParser'.
PP.PPCompositeParser subclass: SIPGrammar [
| Response StatusLine message_header
CRLF SP HTAB HCOLON SWS LWS WSP COMMA SEMI SLASH COLON EQUAL
LAQUOT RAQUOT DQUOTE
LAQUOT RAQUOT DQUOTE STAR
message_body SIPVersion StatusCode ReasonPhrase
extension_header header_name header_value
Request RequestLine Method extension_method
@ -304,7 +304,8 @@ PP.PPCompositeParser subclass: SIPGrammar [
"Simplified..."
<category: 'generic'>
^ (self Via / self CSeq / self From / self To /extension_header), CRLF
^ (self Via / self CSeq / self From /
self To / self Contact / extension_header), CRLF
]
message_body [
@ -491,11 +492,53 @@ PP.PPCompositeParser subclass: SIPGrammar [
^ self SIPURI / self SIPSURI "/ self absoluteURI"
]
Contact [
<category: 'contact'>
^ ('Contact' asParser / 'm' asParser), HCOLON,
(STAR / (self contact_param, (COMMA, self contact_param) star))
]
contact_param [
<category: 'contact'>
^ (self name_addr / self addr_spec), (SEMI, self contact_params) star
]
contact_params [
<category: 'contact'>
^ self c_p_q / self c_p_expires / self contact_extension
]
c_p_q [
<category: 'contact'>
^ $q asParser, EQUAL, self qvalue
]
c_p_expires [
<category: 'contact'>
^ 'expires' asParser, EQUAL, self delta_seconds
]
contact_extension [
<category: 'contact'>
^ self generic_param
]
delta_seconds [
<category: 'contact'>
^ #digit asParser plus
]
extension_header [
<category: 'generic'>
^ header_name, HCOLON, header_value
]
qvalue [
<category: 'generic'>
^ ($0 asParser, ($. asParser, #digit asParser max: 3) optional) /
($1 asParser, ($. asParser, $0 asParser max: 3) optional)
]
token [
<category: 'generic'>
@ -584,4 +627,9 @@ PP.PPCompositeParser subclass: SIPGrammar [
<category: 'generic'>
^ $" asParser
]
STAR [
<category: 'generic'>
^ SWS, $* asParser, SWS
]
]