I am planning to build a parser, that parse only particular format as below.
Dec 17 14:00:00 IP firewall,info FFFW forward: in:<pppoe-mm.demo.649> out:sfp-sfpplus1.vlan113, proto TCP (ACK,PSH), IP:PORT->IP:PORT, NAT (IP:PORT->IP:PORT)->IP:PORT, len 250
This is one of the log for the router. I am naive developer. And just encountered ANTLR4 few days back. Using ANTLRWorks2 I checked my grammar. I created lexer and parser - two classes using ANTLR4. From now I don't know what to do. Please guide.
I guess, I have to create another java file which imports parser.java file and in that file I have to write parser logic.
I am attaching grammar file herewith.
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
grammar Hello;
r : MONTH ID TIME IP X UNAME Y PROTOCOL Z FULLIP SEP FULLIP W FULLIP SEP FULLIP V SEP FULLIP P; // match keyword hello followed by an identifier
MONTH:[A-Z][a-z]+;
ID : [0-9]+ ; // match lower-case identifiers
TIME : ID SEPERATOR ID SEPERATOR ID;
SEPERATOR: [:] | [.];
SEP: [-][>] ;
IP: ID SEPERATOR ID SEPERATOR ID SEPERATOR ID ;
FULLIP: IP SEPERATOR ID/*Port*/ ;
X: [a-z]+[,][a-z]+[ ][A-Z]+[ ][a-z]+[:][ ][a-z]+[:][<] ;
UNAME: [a-z]+[-][a-z]+[.][a-z]+[.][0-9]+ ;
Y: [>][ ][a-z]+[:][a-z]+[-][a-z]+[0-9][.][a-z]+[0-9]+[,][ ][a-z]+[ ] ;
PROTOCOL: [A-Z]+ ;
Z: [(][A-Z]+[,][A-Z]+[)][,];
W: [,][ ][A-Z]+[ ][(] ;
V: [)];
P: [,][ ][a-z]+[ ][0-9]+ ;
WS : [ \t\r\n]+ -> skip ; // skip spaces, tabs, newlines, \r (Windows)