}
void operator +=(const std::string &command) {
- add_history(command_.c_str());
+ add_history(command.c_str());
++histlines_;
}
};
}
command_ += line;
+ command_ += "\n";
char *begin(line), *end(line + strlen(line));
while (char *nl = reinterpret_cast<char *>(memchr(begin, '\n', end - begin))) {
if (parser.parse() != 0 || !driver.errors_.empty()) {
for (CYDriver::Errors::const_iterator error(driver.errors_.begin()); error != driver.errors_.end(); ++error) {
CYPosition begin(error->location_.begin);
- if (begin.line != lines.size() || begin.column < lines.back().size() || error->warning_) {
+ if (begin.line != lines.size() + 1 || error->warning_) {
CYPosition end(error->location_.end);
if (begin.line != lines.size()) {
std::cerr << " | ";
std::cerr << error->message_ << std::endl;
- history += command_;
+ history += command_.substr(0, command_.size() - 1);
goto restart;
}
}
driver.errors_.clear();
- command_ += '\n';
prompt = "cy> ";
goto read;
}
code = str.str();
}
- history += command_;
+ history += command_.substr(0, command_.size() - 1);
if (debug) {
std::cout << "cy= ";
"=" L C F(tk::Equal, hi::Operator);
"==" L C F(tk::EqualEqual, hi::Operator);
"===" L C F(tk::EqualEqualEqual, hi::Operator);
-"=>" L C F(tk::EqualRight, hi::Operator);
+"=>" L C F(yylval->newline_ ? tk::EqualRight_ : tk::EqualRight, hi::Operator);
"!" L C F(tk::Exclamation, hi::Operator);
"!=" L C F(tk::ExclamationEqual, hi::Operator);
"!==" L C F(tk::ExclamationEqualEqual, hi::Operator);
"volatile" L C I(identifier, Identifier("volatile"), tk::Volatile, hi::Meta);
"let" L C I(identifier, Identifier("let"), tk::Let, hi::Meta);
-"yield" L C I(identifier, Identifier("yield"), tk::Yield, hi::Control);
+"yield" L R I(identifier, Identifier("yield"), tk::Yield, hi::Control);
"each" L C I(identifier, Identifier("each"), tk::Each, hi::Control);
"of" L C I(identifier, Identifier("of"), tk::Of, hi::Operator);
%token EqualEqual "=="
%token EqualEqualEqual "==="
%token EqualRight "=>"
+%token EqualRight_ "\n=>"
%token Exclamation "!"
%token ExclamationEqual "!="
%token ExclamationEqualEqual "!=="
// XXX: currently I only have this as Word
// | "let" { $$ = $1; }
- | "yield" { $$ = $1; }
+ | "yield" NewLineOpt { $$ = $1; }
| "each" { $$ = $1; }
| "of" { $$ = $1; }
/* }}} */
/* 12.13 The throw Statement {{{ */
ThrowStatement
- : "throw" LexSetRegExp "\n" StrictSemi { YYABORT; }
+ : "throw" LexSetRegExp "\n" StrictSemi { error(@1, "throw without exception"); }
| "throw" Expression Terminator { $$ = CYNew cy::Syntax::Throw($2); }
;
/* }}} */