Results 1 to 14 of 14

Thread: Parsing Files

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2007
    Posts
    31
    Thanks
    2
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Parsing Files

    If You want store some settings, easiest way is to use QSettings.

  2. #2

    Default Re: Parsing Files

    Storing isn't that problem. An Alghorithm for parsing these files is the problem ...

    After cutting all whitespaces, I've to go through it via QRegExp I think ... The best way I think ...

  3. #3
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Parsing Files

    A lexer can be implemented in any number of ways. Using regular expressions is one of the hardest/slowest.

    I say to look in the opposite direction, towards finite automata , especially if you are interested in only one language.

    Regards

  4. #4
    Join Date
    Mar 2006
    Location
    The Netherlands
    Posts
    300
    Thanks
    9
    Thanked 29 Times in 29 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Parsing Files

    Quote Originally Posted by JayJay View Post
    Storing isn't that problem. An Alghorithm for parsing these files is the problem ...

    After cutting all whitespaces, I've to go through it via QRegExp I think ... The best way I think ...
    Why? I don't think you'll need QRegExp at all. What's your plan?
    "The strength of a civilization is not measured by its ability to wage wars, but rather by its ability to prevent them." - Gene Roddenberry

  5. #5
    Join Date
    Jan 2006
    Posts
    371
    Thanks
    14
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Parsing Files

    Quote Originally Posted by JayJay View Post
    Storing isn't that problem. An Alghorithm for parsing these files is the problem ...

    After cutting all whitespaces, I've to go through it via QRegExp I think ... The best way I think ...
    bad idea, you are not aware of the context in which the string is found. some bad examples (FullMetalCoder will be able to explain about NFA and DFA, I suggest you to read about Turing machines as well)

    Qt Code:
    1. QString s = "class a { int foo; };";
    2.  
    3. // class a { int foo; };
    4.  
    5. #if 0
    6. class a
    7. {
    8. int foo;
    9. };
    10. #endif
    11.  
    12. /*
    13. class a
    14. {
    15.   int foo;
    16. };
    17. */
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Mar 2006
    Location
    The Netherlands
    Posts
    300
    Thanks
    9
    Thanked 29 Times in 29 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Parsing Files

    Quote Originally Posted by elcuco View Post
    bad idea, you are not aware of the context in which the string is found. some bad examples (FullMetalCoder will be able to explain about NFA and DFA, I suggest you to read about Turing machines as well)
    Note to JayJay: That's (Non)Deterministic Finite Automata. And while Turing Machines are very interesting, I don't think they're relevant for this at all.

    Anyway, I think everyone here is pointing you in the right direction. You need to create a token-stream/list and go through them with a finite automaton. But how formal and elaborate you want to make your parser really depends on what kind of stuff you expect to find in these header files. Are they more predictable than elcuco's example?
    "The strength of a civilization is not measured by its ability to wage wars, but rather by its ability to prevent them." - Gene Roddenberry

Similar Threads

  1. XML Parsing in Qt 3.3
    By ToddAtWSU in forum Qt Programming
    Replies: 5
    Last Post: 18th April 2007, 18:54
  2. Replies: 5
    Last Post: 22nd September 2006, 08:04
  3. Parsing of Text files in Qt
    By shailesh in forum Qt Programming
    Replies: 3
    Last Post: 21st April 2006, 15:35
  4. [Win32/VC++ 8.0] Strange problems with qrc_*.cpp files
    By mloskot in forum Installation and Deployment
    Replies: 6
    Last Post: 6th March 2006, 10:28
  5. Visual Studio 2003 and .vcproj files
    By mbjerkne in forum General Discussion
    Replies: 2
    Last Post: 1st February 2006, 00:51

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.