OSDN Git Service

エラーメッセージを改善
authorstarg <starg@users.osdn.me>
Fri, 26 Aug 2016 00:32:33 +0000 (09:32 +0900)
committerstarg <starg@users.osdn.me>
Fri, 26 Aug 2016 00:32:33 +0000 (09:32 +0900)
include/message/id.hpp
src/driver/msgcallback.cpp
src/parser/error_common.hpp
src/parser/error_phrase.hpp
src/parser/parser_composition.hpp

index 45d475b..a44f30a 100644 (file)
@@ -34,6 +34,7 @@ enum class MessageID : int
     GrammarBlockBegin,
     GrammarBlockEnd,
     GrammarEndParenthesis,
+    GrammarSemicolon,
 
     // error_composition.hpp
     GrammarCommandArgument,
@@ -71,7 +72,6 @@ enum class MessageID : int
     GrammarPhrase2,
     GrammarPhrase3,
     GrammarPhrase4,
-    GrammarSemicolon,
     GrammarPhraseName,
 
     // IR2MIDI
index c4b07bb..38035fa 100644 (file)
@@ -45,7 +45,7 @@ MessagePrinter::MessagePrinter(IStdErrWriter* pStdErrWriter)
         {Message::MessageID::OctaveOutOfRange, "octave value '{0}' is out of range (must be between 0 and 10)"},
 
         // error_attribute.hpp
-        {Message::MessageID::GrammarAttributeArgument, "parse error: GrammarAttributeArgument"},
+        {Message::MessageID::GrammarAttributeArgument, "expecting numeric constant, string literal or identifier after ','"},
         {Message::MessageID::GrammarCommaSeparatedOptionalAttributeArguments, "parse error: GrammarCommaSeparatedOptionalAttributeArguments"},
         {Message::MessageID::GrammarAttributeList, "expecting identifier after '['"},
         {Message::MessageID::GrammarAttributeNameAndArguments, "expecting identifier here (consider removing trailing ',')"},
@@ -53,11 +53,12 @@ MessagePrinter::MessagePrinter(IStdErrWriter* pStdErrWriter)
 
         // error_common.hpp
         {Message::MessageID::GrammarBlockBegin, "unexpected token '{0}'. expecting '{'"},
-        {Message::MessageID::GrammarBlockEnd, "unexpected token '{0}'"},
-        {Message::MessageID::GrammarEndParenthesis, "missing ')'"},
+        {Message::MessageID::GrammarBlockEnd, "unexpected token '{0}', did you forget ';' or '}'?"},
+        {Message::MessageID::GrammarEndParenthesis, "unexpected token '{0}', did you forget ')'?"},
+        {Message::MessageID::GrammarSemicolon, "unexpected token '{0}', did you forget ';'?"},
 
         // error_composition.hpp
-        {Message::MessageID::GrammarCommandArgument, "parse error: GrammarCommandArgument"},
+        {Message::MessageID::GrammarCommandArgument, "expecting numeric constant, string literal or identifier after ','"},
         {Message::MessageID::GrammarCommandsAndTrackListBlocks, "parse error: GrammarCommandsAndTrackListBlocks"},
         {Message::MessageID::GrammarOneOrMoreTrackBlocks, "unexpected token '{0}'. expecting track blocks"},
         {Message::MessageID::GrammarSpaceSeparatedOptionalTrackItems, "parse error: GrammarSpaceSeparatedOptionalTrackItems"},
@@ -84,15 +85,14 @@ MessagePrinter::MessagePrinter(IStdErrWriter* pStdErrWriter)
         {Message::MessageID::GrammarSimpleDurationModifier, "parse error: GrammarSimpleDurationModifier"},
         {Message::MessageID::GrammarNoteNumber, "parse error: GrammarNoteNumber"},
         {Message::MessageID::GrammarNoteSequenceStatementsAndBlocks, "parse error: GrammarNoteSequenceStatementsAndBlocks"},
-        {Message::MessageID::GrammarNoteSequenceAndSeparators, "parse error: GrammarNoteSequenceAndSeparators"},
+        {Message::MessageID::GrammarNoteSequenceAndSeparators, "unexpected token '{0}', expecting notes"},
         {Message::MessageID::GrammarSpaceDelimitedChords, "parse error: GrammarSpaceDelimitedChords"},
         {Message::MessageID::GrammarDurationOrDurationSet, "expecting duration specifier after '/'"},
         {Message::MessageID::GrammarSpaceDelimitedDurations, "expecting duration specifiers, not '{0}'"},
         {Message::MessageID::GrammarMissingRepeatOperator, "expecting '*' or '%' after numeric constant"},
-        {Message::MessageID::GrammarPhrase2, "parse error: GrammarPhrase2"},
-        {Message::MessageID::GrammarPhrase3, "parse error: GrammarPhrase3"},
-        {Message::MessageID::GrammarPhrase4, "parse error: GrammarPhrase4"},
-        {Message::MessageID::GrammarSemicolon, "unexpected token '{0}'"},
+        {Message::MessageID::GrammarPhrase2, "unexpected token '{0}', expecting notes"},
+        {Message::MessageID::GrammarPhrase3, "unexpected token '{0}', expecting notes"},
+        {Message::MessageID::GrammarPhrase4, "unexpected token '{0}', expecting notes"},
         {Message::MessageID::GrammarPhraseName, "expecting valid name for phrase"},
 
         // IR2MIDI
index 659ace5..b1b350c 100644 (file)
@@ -21,6 +21,9 @@ const Message::MessageID ErrorControl<Grammar::BlockEnd>::ID = Message::MessageI
 template<>
 const Message::MessageID ErrorControl<pegtl::one<')'>>::ID = Message::MessageID::GrammarEndParenthesis;
 
+template<>
+const Message::MessageID ErrorControl<pegtl::one<';'>>::ID = Message::MessageID::GrammarSemicolon;
+
 } // namespace Parser
 
 } // namespace YAMML
index afe679d..e685929 100644 (file)
@@ -52,9 +52,6 @@ const Message::MessageID ErrorControl<
 >::ID = Message::MessageID::GrammarPhrase4;
 
 template<>
-const Message::MessageID ErrorControl<pegtl::one<';'>>::ID = Message::MessageID::GrammarSemicolon;
-
-template<>
 const Message::MessageID ErrorControl<Grammar::PhraseName>::ID = Message::MessageID::GrammarPhraseName;
 
 } // namespace Parser
index 44e184d..154c0b9 100644 (file)
@@ -21,11 +21,20 @@ class CommandArgument : public pegtl::seq<Value>
 {
 };
 
-class Command : public pegtl::seq<Identifier, pegtl::pad_opt<pegtl::list_must<CommandArgument, pegtl::one<','>, Separator>, Separator>, pegtl::one<';'>>
+class Command
+    : public pegtl::seq<
+        Identifier,
+        pegtl::pad_opt<pegtl::list_must<CommandArgument, pegtl::one<','>, Separator>, Separator>,
+        pegtl::must<pegtl::one<';'>>
+    >
 {
 };
 
-class TrackItem : public pegtl::seq<AttributeOptionalSequence, pegtl::pad_opt<Identifier, Separator>, pegtl::one<';'>>
+class TrackItem
+    : public pegtl::seq<
+        AttributeOptionalSequence,
+        pegtl::if_must<pegtl::pad<Identifier, Separator>, pegtl::one<';'>>
+    >
 {
 };