Support multiline comments
This commit is contained in:
parent
26b0e6771d
commit
e0bc4a361d
2 changed files with 16 additions and 1 deletions
|
|
@ -37,6 +37,16 @@ namespace pslang::ast
|
||||||
end.column = add(end.column, count, 1);
|
end.column = add(end.column, count, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void advance(char const * begin, char const * end)
|
||||||
|
{
|
||||||
|
for (; begin != end; ++begin) {
|
||||||
|
if (*begin == '\n')
|
||||||
|
move_lines(1);
|
||||||
|
else
|
||||||
|
move_columns(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static std::size_t add(std::size_t lhs, std::size_t rhs, std::size_t min)
|
static std::size_t add(std::size_t lhs, std::size_t rhs, std::size_t min)
|
||||||
{
|
{
|
||||||
return lhs + rhs < min ? min : lhs + rhs;
|
return lhs + rhs < min ? min : lhs + rhs;
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,12 @@ using bp = ::pslang::parser::bison::parser;
|
||||||
|
|
||||||
[ \r\t]+ { ctx.location.step(); }
|
[ \r\t]+ { ctx.location.step(); }
|
||||||
|
|
||||||
"//"[^\n]* { ctx.location.step(); }
|
"//".* ;
|
||||||
|
"/*"([^*]|\*+[^*/])*\*+"/" {
|
||||||
|
ctx.location.move_columns(-yyleng);
|
||||||
|
ctx.location.advance(yytext, yytext + yyleng);
|
||||||
|
ctx.location.step();
|
||||||
|
}
|
||||||
|
|
||||||
const { return bp::make_const(ctx.location); }
|
const { return bp::make_const(ctx.location); }
|
||||||
let { return bp::make_let(ctx.location); }
|
let { return bp::make_let(ctx.location); }
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue