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

MGCPGrammar: Be able to parse more difficult lines..

This commit is contained in:
Holger Hans Peter Freyther 2010-09-09 13:05:01 +08:00
parent 692369f7d6
commit 3561a1ab7d
2 changed files with 34 additions and 28 deletions

View File

@ -82,34 +82,38 @@ PP.PPCompositeParser subclass: MGCPGrammar [
^ ParameterValue, EOL
]
wordParser [
^ #word asParser / #punctuation asParser / ' ' asParser
]
ParameterValue [
^ ($K asParser, $: asParser, #blank asParser star, #word asParser star flatten) /
($B asParser, $: asParser, #blank asParser star, #word asParser star flatten) /
($C asParser, $: asParser, #blank asParser star, #word asParser star flatten) /
($I asParser, $: asParser, #blank asParser star, #word asParser star flatten) /
($N asParser, $: asParser, #blank asParser star, #word asParser star flatten) /
($X asParser, $: asParser, #blank asParser star, #word asParser star flatten) /
($L asParser, $: asParser, #blank asParser star, #word asParser star flatten) /
($M asParser, $: asParser, #blank asParser star, #word asParser star flatten) /
($R asParser, $: asParser, #blank asParser star, #word asParser star flatten) /
($S asParser, $: asParser, #blank asParser star, #word asParser star flatten) /
($D asParser, $: asParser, #blank asParser star, #word asParser star flatten) /
($O asParser, $: asParser, #blank asParser star, #word asParser star flatten) /
($P asParser, $: asParser, #blank asParser star, #word asParser star flatten) /
($E asParser, $: asParser, #blank asParser star, #word asParser star flatten) /
($Z asParser, $: asParser, #blank asParser star, #word asParser star flatten) /
($Z asParser, $: asParser, #blank asParser star, #word asParser star flatten) /
('Z2' asParser, $: asParser, #blank asParser star, #word asParser star flatten) /
('I2' asParser, $: asParser, #blank asParser star, #word asParser star flatten) /
($F asParser, $: asParser, #blank asParser star, #word asParser star flatten) /
($Q asParser, $: asParser, #blank asParser star, #word asParser star flatten) /
($T asParser, $: asParser, #blank asParser star, #word asParser star flatten) /
('RM' asParser, $: asParser, #blank asParser star, #word asParser star flatten) /
('RD' asParser, $: asParser, #blank asParser star, #word asParser star flatten) /
($A asParser, $: asParser, #blank asParser star, #word asParser star flatten) /
('ES' asParser, $: asParser, #blank asParser star, #word asParser star flatten) /
('PL' asParser, $: asParser, #blank asParser star, #word asParser star flatten) /
('MD' asParser, $: asParser, #blank asParser star, #word asParser star flatten)
^ ($K asParser, $: asParser, #blank asParser star, self wordParser star flatten) /
($B asParser, $: asParser, #blank asParser star, self wordParser star flatten) /
($C asParser, $: asParser, #blank asParser star, self wordParser star flatten) /
($I asParser, $: asParser, #blank asParser star, self wordParser star flatten) /
($N asParser, $: asParser, #blank asParser star, self wordParser star flatten) /
($X asParser, $: asParser, #blank asParser star, self wordParser star flatten) /
($L asParser, $: asParser, #blank asParser star, self wordParser star flatten) /
($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)
]
]

View File

@ -26,7 +26,9 @@ PP.PPCompositeParserTest subclass: MGCPGrammarTest [
| res |
res := self parse: 'AUEP 23444 13@mgw MGCP 1.0',
Character cr asString, Character lf asString.
Character cr asString, Character lf asString,
'K: 3445', Character cr asString, Character lf asString,
'L: p:20, a:GSM-EFR, nt:IN', Character cr asString, Character lf asString.
self assert: res size = 9.
self assert: (res at: 1) = 'AUEP'.
self assert: (res at: 3) = '23444'.