antlr4 - What is the grammar to have parentheses take place of linebreaks? -
For example, I'm trying to write a grammar to parse the DNS zone files. Resource records are usually separated by Newline. However, using a bracket, a record can be broken into several rows. For example:
or How do I allow brackets to exist in any place within the record. How about (not well tested). Grammar: Test case (from Wikipedia): Result (Large Image) in 1800: record1 part1 part2 part3 part4
record 1 part 1 (part 2 part3 part4 )
grammar DNS; File: (record | NL) + EOF; Record: record name recordpart + (nl | eof); Record Name: Some; RecordParty: '(' RecordPartyoneNewline ')' | something ; RecordPartyoneNew Line: NL | Recordpart; Some: [a-zA-Z0-9 :.] +; // be adjusted! WS: [\ t] + - - Skip; NL: ('\ r'? '\ N') | '\ r'; Comment : ';' ~ [\ R \ n] * - & gt; Skip;
example.com. SOA ns1.example.com in 1800 Mailbox.example.com. (100; chennaiemar 300; refresh time 100; retire time 6000; expiration time 600; negative caching jit) example.com. 1800s NS NS1 Export Ns1.example.com. AAAA 2001: DB8 :: F: A www.example.com, in 1800, a 172.27.182.17 ns1.example.com 1800. In 1800 a 1902.06.1.2 www.example.com. AAAA 2001: DB8 :: 1: 2
Comments
Post a Comment