I am currently designing a DHCPD GUI for my final major project at university but i cant find anything about whats the best language for text file parsing. I am obviously trying to parse the DHCPD.conf file and edit it accordingly.
Thanks!

Dani AI

Generated

Short expert note for : pick the same language you plan to build the GUI in and treat dhcpd.conf as a small programming language, not just key=value lines. The ISC dhcpd.conf format supports nested brace blocks, quoted strings and inline comments, and the real dhcpd binary uses a recursive‑descent parser — so a real parser will handle edge cases reliably. (See the dhcpd.conf reference.)
dhcpd.conf manual

If the GUI is Python (practical for rapid GUI work via Tk/PyQt/PySide), use a parsing library rather than fragile ad‑hoc text hacks. PyParsing lets grammars be expressed directly in Python and handles quoted strings/comments well; PLY gives a classic lex/yacc workflow if an LALR parser is preferred. If pure parsing speed or functional parsing style is desired, Haskell/Parsec is an industrial‑strength option. Links: pyparsing, PLY, Parsec

Practical rules: tokenize -> build a small AST -> modify -> reserialize (or edit tokens to preserve comments/formatting) and always validate the result with dhcpd -t before replacing a live file. Avoid trying to handle nested blocks with plain regex (regular expressions have formal limits for nested/context‑free constructs). Back up files and add unit tests that include comments, malformed lines and nested blocks.

Recommended Answers

All 10 Replies

For just parsing, it's probably Haskell, using the library Parsec.

Thanks, this is a start for me to look into! I have looked a little into Haskell but the loading times seem to be a bit high, i would settle for a happy medium between speed and text file parsing

Loading times? What are you talking about?

I'm not valueing Perl above Haskell, but you could look into it.

There is no such thing as "best langauge for text file parsing". There are number of langiages which ccould be suitable for example Python or Perl

If you're making a GUI, you should just use what ever language you prefer for writing the GUI. Loading a configuration file like that in just about any language will likely be parsed quicker than you'll even notice.

Python has a very good support for Regular Expressions. It is very fast also.
Microsoft is about to release a new language called "M". Currently, the CTP version is available.It has a support wherein you can define your own grammar and the M language will be able to help you parse the input file based on the grammar defined by you. So you can define the grammar for DHCPD.conf file and parse it very easily.

Perl is supposed to be one for this purpose..
But as someone already pointed out you should use the language selected for rest of your application, unless you really have a huge amount of data to process, in which case you might wanna do it separately using a more efficient tool.

I vote for python too, have used a lot for parsing and simple GUI dev... works like a charm and needs no getting used too, plus support is everywhere on the web...

Snobol is designed specifically for string manipulation

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.