[antlr-interest] Query: Rule Based Command Line Response Parsing using ANTLR

Anuj Mehta mehta.anuj at wipro.com
Wed Jan 16 01:51:00 PST 2008


Hi 

 

Can we use ANTLR for parsing "response" from a command (CLI)?

 

Example: For command 'route' following is response. 

 

[anuj at anuj ~]$ /sbin/route 

Kernel IP routing table 

Destination     Gateway         Genmask         Flags Metric Ref 

Use    Iface 

172.31.44.0     *               255.255.255.0          U     0 

0         0         eth0 

169.254.0.0     *               255.255.0.0              U     0 

0         0         eth0 

default         172.31.44.1     0.0.0.0                  UG    0 

0        0        eth0 

 

Now I want to save above data in a HashMap/Table (row wise or 

column wise). So for that I may create an input file which will contain
rules like

1) Check for correct order of following headers i.e.  Destination, Gateway,
Genmask, Flags etc.

2) Skip empty lines.

3) Store all the values (say row wise) in a HashTable i.e.  "172.31.44.0
*               255.255.255.0          U     0 

0         0         eth0"

 

 

Do let me know your suggestions for doing this.

 

Thanks, 

Anuj


The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. 

WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.

www.wipro.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080116/d5803ad6/attachment.html 


More information about the antlr-interest mailing list