summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-11-26 10:31:04 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-11-26 10:31:04 +0200
commit667130a0eb2c0e42125738f232f4652706b58556 (patch)
tree1e26ccb5c6249528b34769fdbb7108ca6c37ee7c /cli
parenta9fd81899df8a412f20784b3575b9707c530d1d1 (diff)
Don't require ';' after option documentation block
Diffstat (limited to 'cli')
-rw-r--r--cli/parser.cxx30
1 files changed, 21 insertions, 9 deletions
diff --git a/cli/parser.cxx b/cli/parser.cxx
index aee5c04..b63efcb 100644
--- a/cli/parser.cxx
+++ b/cli/parser.cxx
@@ -143,14 +143,16 @@ private:
void parser::
recover (token& t)
{
- // Recover by skipping past next ';'.
+ // Recover by skipping past next ';' or '}'.
//
for (;; t = lexer_->next ())
{
if (t.type () == token::t_eos)
break;
- if (t.punctuation () == token::p_semi)
+ token::punctuation_type p (t.punctuation ());
+
+ if (p == token::p_semi || p == token::p_rcbrace)
{
t = lexer_->next ();
break;
@@ -695,14 +697,13 @@ class_def ()
t.punctuation () == token::p_lcbrace)
{
scope_doc (t);
+ t = lexer_->next ();
}
else
{
if (!option_def (t))
break;
}
-
- t = lexer_->next ();
}
catch (error const&)
{
@@ -907,6 +908,8 @@ option_def (token& t)
root_->new_edge<initialized> (*o, e);
}
+ // option-def-trailer
+ //
if (t.punctuation () == token::p_lcbrace)
{
// doc-string-seq
@@ -938,13 +941,22 @@ option_def (token& t)
}
t = lexer_->next ();
- }
- if (t.punctuation () != token::p_semi)
+ // Allow semicolon after option-doc for backwards compatibility.
+ //
+ if (t.punctuation () == token::p_semi)
+ t = lexer_->next ();
+ }
+ else
{
- cerr << *path_ << ':' << t.line () << ':' << t.column () << ": error: "
- << "expected ';' instead of " << t << endl;
- throw error ();
+ if (t.punctuation () != token::p_semi)
+ {
+ cerr << *path_ << ':' << t.line () << ':' << t.column () << ": error: "
+ << "expected ';' instead of " << t << endl;
+ throw error ();
+ }
+
+ t = lexer_->next ();
}
return true;