Hello guys,
I have some doubts.I think one of you can solve this.I'm c++ fresher.My doubts are:
1.What's a parser in C++?:?:
2.How to create a parser cum interface window in c++.:?:
Help me please.Thanks in advance.:icon_neutral:

Dani AI

Generated

A compact, practical plan that builds on the earlier posts by , and : pick a parsing approach, keep parsing and UI separate, and use an existing GUI toolkit. The two common C++ routes are (a) a generator-based parser (Bison/Flex, ANTLR) so a grammar produces C++ parsing code, or (b) an in-C++ parser library (Boost.Spirit) to keep grammar inside C++ templates. For the interface, a cross-platform widget toolkit such as Qt is a good fit because of its editor widgets and thread/async helpers.

Typical workflow:

  • Design the grammar (BNF) and pick a tool: see the Bison manual or ANTLR home.
  • Generate or implement the parser and expose a simple parse() API that returns success/failure, an AST, and error positions. For a C++-embedded option see Boost.Spirit.
  • Build the GUI with a text editor widget, an error/results pane, and a Parse command. Put parsing on a background thread so the UI stays responsive; use the toolkit’s thread-to-UI mechanism to deliver results (signals/slots, message posting, etc.). Qt widgets docs and concurrency helpers are at and QtConcurrent.

Example pattern (non-blocking parse using QtConcurrent):

QFuture<ParseResult> f = QtConcurrent::run(&parser, &Parser::parse, editor->toPlainText());
watcher.setFuture(f); // QFutureWatcher<ParseResult> watcher member
// on watcher.finished -> retrieve result and update UI on main thread

Troubleshooting notes: watch grammar ambiguity and left-recursion rules (generator specifics vary); avoid heavy template compile times with Spirit for very large grammars; always validate line/column error mapping; and add unit tests for the parser separately from the GUI. This separates concerns and makes debugging far easier.

Recommended Answers

All 3 Replies

If you have an assignment you want help with, describe the goal, any requirements and post YOUR code to show what you've done.

Then we'll help you get from where you are to where its done.

PS- please surround your c++ code with code tags:
[code=c++] // your code here

[/code]

A parser is a computerprogram and does not have to be in C++.
It can be written in any convienient language.
From wiki :
A parser is one of the components in an interpreter or compiler, which checks for correct syntax and builds a data structure (often some kind of parse tree, abstract syntax tree or other hierarchical structure) implicit in the input tokens. The parser often uses a separate lexical analyser to create tokens from the sequence of input characters. Parsers may be programmed by hand or may be semi-automatically generated (in some programming language) by a tool (such as Yacc) from a grammar written in Backus-Naur form.

I'm surprised the filter didn't list this as profanity, when it doesn't even allow the mildest things....

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.