@@ -44,13 +44,57 @@ AssignmentList
4444 }
4545
4646Assignment
47+ = SimpleAssignment / CommentedAssignment
48+
49+ SimpleAssignment
4750 = id :Identifier _ "=" _ val :Value ";"
4851 {
4952 var result = Object .create (null );
5053 result[id] = val
5154 return result
5255 }
5356
57+ CommentedAssignment
58+ = commentedId :CommentedIdentifier _ "=" _ val :Value ";"
59+ {
60+ commentedId[commentedId .id ] = val;
61+ delete (commentedId, ' id' )
62+ return commentedId;
63+ }
64+ /
65+ id :Identifier _ "=" _ commentedVal :CommentedValue ";"
66+ {
67+ var result = Object .create (null );
68+ result[id] = commentedVal .value ;
69+ result[id + " _comment" ] = commentedVal .comment ;
70+ return result;
71+ }
72+
73+ CommentedIdentifier
74+ = id :Identifier _ comment :InlineComment
75+ {
76+ var result = Object .create (null );
77+ result .id = id;
78+ result[id + " _comment" ] = comment .trim ();
79+ return result
80+ }
81+
82+ CommentedValue
83+ = literal :Literal _ comment :InlineComment
84+ {
85+ var result = Object .create (null )
86+ result .comment = comment .trim ();
87+ result .value = literal .trim ();
88+ return result;
89+ }
90+
91+ InlineComment
92+ = "/*" body :[^*]+ "*/"
93+ { return body .join (' ' ) }
94+
95+ InlineCommentOpen
96+ = "/*"
97+
5498DelimitedSection
5599 = begin :DelimitedSectionBegin _ fields :(AssignmentList / EmptyBody ) _ DelimitedSectionEnd
56100 {
@@ -74,10 +118,15 @@ Identifier
74118
75119Value
76120 = obj :Object { return obj }
77- / literal :Literal { return literal . join ( ' ' ) }
121+ / literal :Literal { return literal }
78122
79123Literal
80- = [^;\n ]+
124+ = literal :LiteralChar +
125+ { return literal .join (' ' ) }
126+
127+ LiteralChar
128+ = ! InlineCommentOpen char :[^;\n ]
129+ { return char }
81130
82131SingleLineComment
83132 = "//" _ contents :OneLineString NewLine
0 commit comments