[Asterisk-Dev] Dialplan syntax changes.. Option: work on a
radically different design..
Tzafrir Cohen
tzafrir.cohen at xorcom.com
Wed May 18 10:55:58 MST 2005
On Wed, May 18, 2005 at 10:40:29AM -0400, Steve Kann wrote:
> CONSOLE=Console/dsp ; Console interface for demo
> ;CONSOLE=Zap/1
> ;CONSOLE=Phone/phone0
> IAXINFO=guest ; IAXtel username/password
> ;IAXINFO=myuser:mypass
> TRUNK=Zap/g2 ; Trunk interface
>
>
> macro LocalDial (dialed) {
> Dial($dialed);
> switch($?) {
> }
> return something;
> }
>
> context mycontext {
> extension 2125551212 () {
> Dial(SIP/Grandstream1,DIAL_RINGBACK|DIAL_ARGUMENT)
c-like, but with no clear distinction betwen strings and variables. Are
you sure this is still close enough to C syntax? A very common mistake
with editing isc-dhcpd's config file (uses c-like syntax as well, the
only example for such a program I could think of) is forgetting to quote
strings. Proper brace nesting is also a trouble-maker.
> switch ($?) {
> case NOANSWER {
> 2125551333 ();
> }
> case CONGESTION {
> Play(busy);
> }
> default {}
> }
> }
> extension _212555XXXX () {
> Dial(Local/$EXTEN);
> }
> }
> ============
>
> I think that we could get together and define a grammar for this, parse
> it with yacc/lex, etc.
>
> There was lots of talk about the "pluggable PBX" concept earlier, on dev
> chats, etc. I think if you're going to break everyone's dialplans
> anyway, you might as well really break them, and do it right.
>
> It seems like what's happening here is that we're making the language
> look like spreadsheet expressions..
That will never happen with C, as C has just about zero syntactic
support for decent data structures.
>
> I'm surely oversimplifying the problem here, in at least two ways:
>
> 1) The dialplan is not only looked at as calls pass through it, but it
> is also consulted to determine the existence of extensions and pattern
> matching.
Then why are we looking at procedural languages for inspiration?
>
> 2) The dialplan was originally designed to be modifiable at run-time,
> where you could, e.g. change things in the CLI, and then have asterisk
> spit out the new dialplan. But you can't do that now anyway.
Linux's iptables has somewhat similar requirements. It is a low-level API
where rules are chained in chains. The API supports:
* creating/deleting chain/all-the-chains
* adding a rule to the end of the chain
* adding a rule to the beginning of the chain
* deleting a specific rule in a chain (identified by name or by number)
* replacing a specific rule in a chain
* "jumping" to a chain is a kind of a procedure call: if the packet has
survived the chain it will continue from where it was
iptables had to remain low-level as it is implemented in the kernel and
the policy should be implemented in user-space.
--
Tzafrir Cohen icq#16849755 +972-50-7952406
tzafrir.cohen at xorcom.com http://www.xorcom.com
More information about the asterisk-dev
mailing list