Skip to content
Snippets Groups Projects
Commit eb74bd20 authored by Ben Cumming's avatar Ben Cumming Committed by GitHub
Browse files

Merge pull request #21 from vkarak/feature/modcc/qmark-comments

modcc: support for comments starting with '?'
parents 822d8cae 6736546f
No related branches found
No related tags found
No related merge requests found
: sample file
? another style of comments
NEURON {
THREADSAFE
......@@ -26,7 +27,7 @@ PARAMETER {
gkbar = 0.1 (mho/cm2)
celsius
ek = -100 (mV) : must be explicitly def. in hoc
v (mV)
v (mV) ? another style of comment
vhalfm =-43 (mV)
km =8
vhalfh =-67 (mV)
......
......@@ -78,8 +78,9 @@ Token Lexer::parse() {
location_.line++;
continue; // skip to next line
// comment (everything after : on a line is a comment)
case ':' :
// comment (everything after : or ? on a line is a comment)
case ':' :
case '?' :
// strip characters until either end of file or end of line
while( !is_eof(*current_) && *current_ != '\n') {
++current_;
......
......@@ -31,7 +31,7 @@ bool is_keyword(Token const& t);
// takes a range of characters as input parameters
class Lexer {
public:
Lexer(const char * begin, const char* end)
Lexer(const char* begin, const char* end)
: begin_(begin),
end_(end),
current_(begin),
......@@ -114,4 +114,3 @@ protected:
Token token_;
};
......@@ -205,7 +205,9 @@ TEST(Lexer, braces) {
// test comments
TEST(Lexer, comments) {
char string[] = "foo:this is one line\nbar : another comment\n";
char string[] = "foo:this is one line\n"
"bar : another comment\n"
"foobar ? another comment\n";
PRINT_LEX_STRING
Lexer lexer(string, string+sizeof(string));
......@@ -218,7 +220,12 @@ TEST(Lexer, comments) {
EXPECT_EQ(t2.location.line, 2);
auto t3 = lexer.parse();
EXPECT_EQ(t3.type, tok::eof);
EXPECT_EQ(t3.type, tok::identifier);
EXPECT_EQ(t3.spelling, "foobar");
EXPECT_EQ(t3.location.line, 3);
auto t4 = lexer.parse();
EXPECT_EQ(t4.type, tok::eof);
}
// test numbers
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment