mgcp: Reduce the amount of parsers needed and maybe speed-up parsing
Do not create so many blank/word/: parsers and simplify the parameter matching. We can check for legal keywords in a better and probably more quick way in case we need to. I could use "trim" instead of matching blanks and throwing them away.
This commit is contained in:
parent
d5248eceec
commit
31c7c8e55b
|
@ -86,7 +86,7 @@ Object subclass: MGCPCommandBase [
|
||||||
<category: 'private'>
|
<category: 'private'>
|
||||||
"TODO: Share code with MGCPResponse"
|
"TODO: Share code with MGCPResponse"
|
||||||
anArray do: [:each |
|
anArray do: [:each |
|
||||||
self addParameter: each first first asString with: each first fourth].
|
self addParameter: each first first with: each first fourth].
|
||||||
]
|
]
|
||||||
|
|
||||||
parameterAt: aKey [
|
parameterAt: aKey [
|
||||||
|
|
|
@ -86,7 +86,7 @@ Object subclass: MGCPResponse [
|
||||||
<category: 'creation'>
|
<category: 'creation'>
|
||||||
|
|
||||||
aList do: [:each |
|
aList do: [:each |
|
||||||
params at: each first first asString put: each first fourth].
|
params at: each first first put: each first fourth].
|
||||||
]
|
]
|
||||||
|
|
||||||
addSDPFromDict: aDict [
|
addSDPFromDict: aDict [
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
PackageLoader fileInPackage: 'PetitParser'.
|
PackageLoader fileInPackage: 'PetitParser'.
|
||||||
|
|
||||||
PP.PPCompositeParser subclass: MGCPGrammar [
|
PP.PPCompositeParser subclass: MGCPGrammar [
|
||||||
| MGCPMessage EOL One_WSP MGCPMessage MGCPCommandLine MGCPVerb transaction_id endpointName MGCPversion MGCPParameter MGCPCommand ParameterValue SDPRecord SDPLine SDPinformation MGCPResponseLine responseCode responseString packageName |
|
| MGCPMessage EOL One_WSP MGCPMessage MGCPCommandLine MGCPVerb transaction_id endpointName MGCPversion MGCPParameter MGCPCommand ParameterValue SDPRecord SDPLine SDPinformation MGCPResponseLine responseCode responseString packageName wordParser |
|
||||||
<category: 'OsmoMGCP-Core'>
|
<category: 'OsmoMGCP-Core'>
|
||||||
<comment: 'I am a the Grammar of the Media Gateway Control Protocol'>
|
<comment: 'I am a the Grammar of the Media Gateway Control Protocol'>
|
||||||
|
|
||||||
|
@ -99,39 +99,17 @@ PP.PPCompositeParser subclass: MGCPGrammar [
|
||||||
]
|
]
|
||||||
|
|
||||||
wordParser [
|
wordParser [
|
||||||
^ #word asParser / #punctuation asParser / ' ' asParser
|
^ (#word asParser / #punctuation asParser / ' ' asParser) star flatten
|
||||||
]
|
]
|
||||||
|
|
||||||
ParameterValue [
|
ParameterValue [
|
||||||
^ ($K asParser, $: asParser, #blank asParser star, self wordParser star flatten) /
|
"This code used to check for legal variable names but the way
|
||||||
($B asParser, $: asParser, #blank asParser star, self wordParser star flatten) /
|
it was done created a lot of parsers and choice. Norbert has
|
||||||
($C asParser, $: asParser, #blank asParser star, self wordParser star flatten) /
|
pointed me to use >=> (or >< in GST) to make the keyword check
|
||||||
($I asParser, $: asParser, #blank asParser star, self wordParser star flatten) /
|
in the parser. One example is >>#failOnReservedWords: inside
|
||||||
($N asParser, $: asParser, #blank asParser star, self wordParser star flatten) /
|
the ASN1 code."
|
||||||
($X asParser, $: asParser, #blank asParser star, self wordParser star flatten) /
|
^ (#word asParser / $- asParser) plus flatten, $: asParser,
|
||||||
($L asParser, $: asParser, #blank asParser star, self wordParser star flatten) /
|
#blank asParser plus, wordParser
|
||||||
($M asParser, $: asParser, #blank asParser star, self wordParser star flatten) /
|
|
||||||
($R asParser, $: asParser, #blank asParser star, self wordParser star flatten) /
|
|
||||||
($S asParser, $: asParser, #blank asParser star, self wordParser star flatten) /
|
|
||||||
($D asParser, $: asParser, #blank asParser star, self wordParser star flatten) /
|
|
||||||
($O asParser, $: asParser, #blank asParser star, self wordParser star flatten) /
|
|
||||||
($P asParser, $: asParser, #blank asParser star, self wordParser star flatten) /
|
|
||||||
($E asParser, $: asParser, #blank asParser star, self wordParser star flatten) /
|
|
||||||
($Z asParser, $: asParser, #blank asParser star, self wordParser star flatten) /
|
|
||||||
($Z asParser, $: asParser, #blank asParser star, self wordParser star flatten) /
|
|
||||||
('Z2' asParser, $: asParser, #blank asParser star, self wordParser star flatten) /
|
|
||||||
('I2' asParser, $: asParser, #blank asParser star, self wordParser star flatten) /
|
|
||||||
($F asParser, $: asParser, #blank asParser star, self wordParser star flatten) /
|
|
||||||
($Q asParser, $: asParser, #blank asParser star, self wordParser star flatten) /
|
|
||||||
($T asParser, $: asParser, #blank asParser star, self wordParser star flatten) /
|
|
||||||
('RM' asParser, $: asParser, #blank asParser star, self wordParser star flatten) /
|
|
||||||
('RD' asParser, $: asParser, #blank asParser star, self wordParser star flatten) /
|
|
||||||
($A asParser, $: asParser, #blank asParser star, self wordParser star flatten) /
|
|
||||||
('ES' asParser, $: asParser, #blank asParser star, self wordParser star flatten) /
|
|
||||||
('PL' asParser, $: asParser, #blank asParser star, self wordParser star flatten) /
|
|
||||||
('MD' asParser, $: asParser, #blank asParser star, self wordParser star flatten) /
|
|
||||||
('X-Osmo-CP' asParser, $: asParser, #blank asParser star, self wordParser star flatten) /
|
|
||||||
('X-Osmux' asParser, $: asParser, #blank asParser star, self wordParser star flatten)
|
|
||||||
]
|
]
|
||||||
|
|
||||||
MGCPResponse [
|
MGCPResponse [
|
||||||
|
@ -179,7 +157,7 @@ PP.PPCompositeParser subclass: MGCPGrammar [
|
||||||
]
|
]
|
||||||
|
|
||||||
SDPLine [
|
SDPLine [
|
||||||
^ self wordParser star flatten
|
^wordParser
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
Reference in New Issue