Grammar into Object Structure

R

Rene Theisen

Hello!

I want to transform the grammar for linear time logic (LTL) into an
C++ Object structure. More precisely:

I want some classes like this

class primary {

void operator(); // object is function object
}

class U {
void operator();
}

[...]

Some ltl formula such as "G (phi U psi)" should be represented using
the c++ objects like:

G( U(phi,psi) )


But I've no idea how to implement the structure elegant and efficient.


Any hints?

Rene


LTL-Grammar:

// primary:
// '(' impl-or-equiv ')'
// '1'
// '0'
// ID

// prefix:
// '!' prefix
// 'X' prefix
// 'F' prefix
// 'G' prefix
// primary

// until-or-release:
// prefix
// prefix 'U' prefix
// prefix 'V' prefix

// and:
// until-or-release { '&' until-or-release }*

// or:
// and { '|' and }*

// impl-or-equiv:
// or '->' or
// or '<->' or

// element:
// impl-or-equiv
 
V

Victor Bazarov

Rene said:
I want to transform the grammar for linear time logic (LTL) into an
C++ Object structure. More precisely:

I want some classes like this

class primary {

void operator(); // object is function object

void operator()();
} ;

class U {
void operator();

void operator()();
} ;

[...]

Some ltl formula such as "G (phi U psi)" should be represented using
the c++ objects like:

G( U(phi,psi) )


But I've no idea how to implement the structure elegant and efficient.


Any hints?

See chapter 6 "Expressions" in "The C++ Programming Language". There
is an example of expression parser there. Should give you an idea.

Search the web for expression parsers, reverse polish notation, etc.

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,146
Messages
2,570,832
Members
47,374
Latest member
anuragag27

Latest Threads

Top