Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Writing a simple parser [closed]

Tags:

c++

parsing

dsl

I need to write a simple parser to a sort of Domain Specific Language.
It needs to have basic arithmatics with proper operators evaluation order and a syntax to call functions of the underlying environment which can be overloaded.
What is the simplest way to write such a parser? Is there something I can adapt or use out of the box? I'm writing in C++.

like image 501
shoosh Avatar asked Apr 25 '09 12:04

shoosh


People also ask

How hard is it to write a parser?

Writing parsers can be challenging. The problem is simple to describe: convert an input string into a syntax tree. The same language can be parsed by many different algorithms, and all have different tradeoffs with regards to speed, memory usage, readability, and maintainability.

How do you write parser in Python?

The basic workflow of a parser generator tool is quite simple: you write a grammar that defines the language, or document, and you run the tool to generate a parser usable from your Python code.

How would an LL 0 parser work?

An LL(0) parser would mean that the parser could make a decision without knowing the next token in the stream. I would expect that if languages with that property exist, they're pretty darn rare. An LL(0) parser works on a grammar in which there are no decisions to make.


1 Answers

Take a look at Boost Spirit.

like image 99
dirkgently Avatar answered Sep 27 '22 20:09

dirkgently