"div", or "//", is now the operator of division.
This commit is contained in:
parent
75f1cd727c
commit
c5795c66c9
2 changed files with 32 additions and 15 deletions
|
|
@ -291,7 +291,7 @@ bool expr_t::op_t::print(std::ostream& out, const context_t& context) const
|
||||||
out << "(";
|
out << "(";
|
||||||
if (left() && left()->print(out, context))
|
if (left() && left()->print(out, context))
|
||||||
found = true;
|
found = true;
|
||||||
out << " / ";
|
out << " // ";
|
||||||
if (has_right() && right()->print(out, context))
|
if (has_right() && right()->print(out, context))
|
||||||
found = true;
|
found = true;
|
||||||
out << ")";
|
out << ")";
|
||||||
|
|
|
||||||
45
src/token.cc
45
src/token.cc
|
|
@ -38,12 +38,11 @@ int expr_t::token_t::parse_reserved_word(std::istream& in)
|
||||||
{
|
{
|
||||||
char c = in.peek();
|
char c = in.peek();
|
||||||
|
|
||||||
if (c == 'a' || c == 'f' || c == 'o' || c == 'n' || c == 't') {
|
if (c == 'a' || c == 'd' || c == 'f' || c == 'o' || c == 'n' || c == 't') {
|
||||||
length = 0;
|
length = 0;
|
||||||
|
|
||||||
char buf[256];
|
char buf[5];
|
||||||
READ_INTO_(in, buf, 255, c, length,
|
READ_INTO_(in, buf, 4, c, length, std::isalpha(c));
|
||||||
std::isalnum(c) || c == '_' || c == '.' || c == '-');
|
|
||||||
|
|
||||||
switch (buf[0]) {
|
switch (buf[0]) {
|
||||||
case 'a':
|
case 'a':
|
||||||
|
|
@ -55,6 +54,16 @@ int expr_t::token_t::parse_reserved_word(std::istream& in)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'd':
|
||||||
|
if (std::strcmp(buf, "div") == 0) {
|
||||||
|
symbol[0] = '/';
|
||||||
|
symbol[1] = '/';
|
||||||
|
symbol[2] = '\0';
|
||||||
|
kind = KW_DIV;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case 'f':
|
case 'f':
|
||||||
if (std::strcmp(buf, "false") == 0) {
|
if (std::strcmp(buf, "false") == 0) {
|
||||||
kind = VALUE;
|
kind = VALUE;
|
||||||
|
|
@ -255,17 +264,25 @@ void expr_t::token_t::next(std::istream& in, const uint_least8_t pflags)
|
||||||
|
|
||||||
case '/': {
|
case '/': {
|
||||||
in.get(c);
|
in.get(c);
|
||||||
|
c = in.peek();
|
||||||
|
if (c == '/') {
|
||||||
|
in.get(c);
|
||||||
|
symbol[1] = c;
|
||||||
|
symbol[2] = '\0';
|
||||||
|
kind = KW_DIV;
|
||||||
|
length = 2;
|
||||||
|
} else {
|
||||||
|
// Read in the regexp
|
||||||
|
char buf[256];
|
||||||
|
READ_INTO_(in, buf, 255, c, length, c != '/');
|
||||||
|
if (c != '/')
|
||||||
|
expected('/', c);
|
||||||
|
in.get(c);
|
||||||
|
length++;
|
||||||
|
|
||||||
// Read in the regexp
|
kind = MASK;
|
||||||
char buf[256];
|
value.set_string(buf);
|
||||||
READ_INTO_(in, buf, 255, c, length, c != '/');
|
}
|
||||||
if (c != '/')
|
|
||||||
expected('/', c);
|
|
||||||
in.get(c);
|
|
||||||
length++;
|
|
||||||
|
|
||||||
kind = MASK;
|
|
||||||
value.set_string(buf);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue