Skip to content
  • 0 Votes
    14 Posts
    3k Views
    IMAN4KI

    @raven-worx
    Oh..
    Sorry i think that was qt-bug (getter return invalid) but now it's work

    For last question !
    Could i use qcssparser_p.h for retrieving values for my purpose ? (i'm a lover of parsing :) )
    Thanks.

  • 0 Votes
    12 Posts
    3k Views
    JohanSoloJ

    @Aashu10 said:

    Thanks for replying, How do i check the return value of that. Sorry not so proficient with DomDocument.

    Have a look at the doc

  • 0 Votes
    4 Posts
    7k Views
    A

    Like @Ratzz said. QXmlPutGet is very easy.

    QStringList list_IO; QXmlGet xml; xml.load(Sample.xml) xml.findAndDescend("General"); while(xml.findNext("IO") { list_IO = xml.getString(); } xml.rise();
  • Parse this string

    Unsolved General and Desktop
    5
    0 Votes
    5 Posts
    3k Views
    kshegunovK

    @AliReza-Beytari
    Hello,
    If this is your own format, I'd suggest first to reconsider and use something that's instead available to standard parsers. You could use XML to the same effect., which is readily extensible and can be parsed through standard means. If you're still insistent on using your own format then the boost's spirit module might be your best bet. With it you define your language's grammar and it allows for parsing based on that grammar. If you still want to write your own parser, then @mrjj's suggestion is a good starting point. Usually when you need to write a parser you start from the language's grammar and based on it you create a tokenizer that breaks up the input into lexemes. Then from the tokens you build up a parse tree that can be handled by the parser itself. The simplest is to have LL(1) parser (recursive-descent with a single token look-ahead) but it depends on the grammar really. Most will use an automated tool to provide the lexing and parsing (i.e. Flex and Bison) but this is not so much a requirement as it's convenience, because if the grammar is complex (which usually is the case) writing the parser by hand might get very involved. A few years ago I had to write a C++ syntax parser (no semantics) used to change formatting for source files, but unfortunately that code is copyrighted and I can't share it with you. As a guide, after tokenization, you mirror the grammar in the source code (like in @mrjj's example) and from there you handle the parse tree directly. You could go around the internet and look up some ready-made parsers (there are quite a few) and try to deduce how it's done. I hope this helps.

    Kind regards.

  • 0 Votes
    4 Posts
    3k Views
    mrjjM

    @Ralf
    Oh, :(
    Well in that case I would download source code for whole Qt
    and have a look of what they use for
    the qss (css) parsing and see if some could be reused. ( i have no idea)

    Also
    http://www.codeproject.com/Articles/20450/Simple-CSS-Parser

    is a good read (IMO) for toughs about writing such parser.

    Good luck