klmr / streampunk

Compiler for a pipe-based stream language to construct complex pipelines
4 stars 0 forks source link

Some tweaks and a simple solution to the distinct keywords thing #1

Closed sehe closed 11 years ago

sehe commented 11 years ago

Look at the last commit only for the kw parser

I aimed for quick & dirty. IIRC Spirit Repository already contains a thing like this, but it's more fun to write it:

// a quick and dirty distinct keyword parser `kw`: Should be effective,
// at least to avoid parsing partial identifiers as keywords
static const qi::rule<Iterator, qi::unused_type(const char*)> kw = qi::lit(qi::_r1) >> !qi::alnum;

And use it wherever you needed it:

        kw(+"module") > qualified > eol;

Test still compiles and passes.

PS. Note how the absence of a skipper on kw means 'implied lexeme' semantics.