• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Efficient parsing algorithm for String Parsing

 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please let me know any efficient parsing generator for String parsing.

Be specific the following are my requirements - the issues that i expect the parser to tackle

* The strings that is to be parsed will be too big, may be in thousands of lines.
* My parsing should check for the grammer syntax and get me the values. For eg my String will be something like "IPADDR:198.187.90.99,MAC:321612aaff21". The parser should get the value for ip as 198.187.90.99 and mac as 321612aaff21.

I tried javacc, but the limitation is that i do not want my grammer to be something static.. i mean i expect something like the whenever there is a change in the grammer, I need not write the jj file from scratch, instead i can just define the structure somewhere and the rest will be taken care by my parser... I dont think javacc supports such behaviour...


Please help

Thanks
 
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

akhil achuthan wrote:i mean i expect something like the whenever there is a change in the grammer, I need not write the jj file from scratch, instead i can just define the structure somewhere and the rest will be taken care by my parser... I dont think javacc supports such behaviour...

Do any parsers support such behaviour?

But what you quote doesn't use a context-free grammar which requires parsing. "IPADDR:198.187.90.99,MAC:321612aaff21" look to me like something out of a regular grammar. Can you think up a regular expression or a set of regular expressions which will split your String? You could pass in a String for a regular expression from the command line if you need to alter it each time.
 
akhil achuthan
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I do not need to change the grammer at run time.. Only in case if the grammer is getting modified at some stage... I just wanted to keep my grammer as configurable and rather than being hard coded...

I can write code bits to pass this grammer to my parser, but in javacc, the .jj file in which we define the grammer is a non executable one. So there is no option by which i can pass any grammer into it.... Once the .jj is compiled, it creates the java file can be modified, but i do not want to disturb a tool created piece of code.....
 
akhil achuthan
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The grammer of the string that i need to parse will vary depending on my request that i issue to my target. So im in need of having one parser for each type of target request.
 
Campbell Ritchie
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you really need a posh parser like javacc or CUP at all? I suspect you only would if the strings are more complicated than what you have already quoted.
 
akhil achuthan
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That was just a sample string that i had given over there.

The string that i get as response for my request will have thousands of lines, each line having a bare minimum of 30+ key value pair like IPADDR:....

I cannot rely on a normal string parsing as it takes a very long time to parse....
reply
    Bookmark Topic Watch Topic
  • New Topic