boostorg / wave

Boost.org wave module
http://boost.org/libs/wave
21 stars 49 forks source link

[LOW] Support C++14 integer literal digit separators #83

Open jefftrull opened 4 years ago

jefftrull commented 4 years ago

Filing this chiefly for the record. cppreference states that since C++14:

Optional single quotes(') may be inserted between the digits as a separator. They are ignored by the compiler.

I verified this is true in gcc. At this time Wave does not understand them. For example:

#include <iostream>

// can insert single quotes between digits starting in C++14:
int foo = 1'2'3;   // wave thinks this is two ints and one char literal
int bar = 0x2'3;   // wave thinks this is two ints and a single quote

int main() {
    std::cout << foo << "\n";   // 123
    std::cout << bar << "\n";   // 35

    return 0;
}

I don't need this functionality but wanted to record it for some future maintainer.

jefftrull commented 4 years ago

A test case to demonstrate that Wave breaks these literals up into separate tokens testcase.cpp

hkaiser commented 4 years ago

This shouldn't be too hard to add to the lexers, I think.

jefftrull commented 3 years ago

The lexers won't be too hard, as they seem to treat everything as a string. The grammars that use them, on the other hand, may need some work - like here, where a Spirit integer parser is invoked.