@@ -28,7 +28,7 @@ for (const filename of filenames) {
28
28
const matches = line . match ( / ^ ( [ a - z 0 - 9 A - Z ] + ) ( \s * ) \( ( [ ^ ) ] * ) \) ( \s * ) : ( \s * ) $ / ) ;
29
29
const grammarMatches =
30
30
filename === "Section 2 -- Language.md" &&
31
- line . match ( / ^ ( [ A - Z a - z 0 - 9 ] + ) : \s + ( ( \S ) .* ) $ / ) ;
31
+ line . match ( / ^ ( [ A - Z a - z 0 - 9 ] + ) : : ? \s + ( ( \S ) .* ) $ / ) ;
32
32
if ( matches ) {
33
33
const [ , algorithmName , ns1 , _args , ns2 , ns3 ] = matches ;
34
34
if ( ns1 || ns2 || ns3 ) {
@@ -67,14 +67,23 @@ for (const filename of filenames) {
67
67
console . log ( ) ;
68
68
process . exitCode = 1 ;
69
69
}
70
- if ( step . match ( / ^ \s * ( - | [ 0 - 9 ] \. ) \s + [ a - z ] / ) ) {
70
+ if ( step . match ( / ^ \s * ( - | [ 0 - 9 ] + \. ) \s + [ a - z ] / ) ) {
71
71
console . log (
72
72
`Bad formatting of '${ algorithmName } ' step (should start with a capital) in '${ filename } ':`
73
73
) ;
74
74
console . dir ( step ) ;
75
75
console . log ( ) ;
76
76
process . exitCode = 1 ;
77
77
}
78
+ const assertMatch = step . match ( / ^ \s * ( - | [ 0 - 9 ] + \. ) \s * A s s e r t ( [ ^ : ] ) / ) ;
79
+ if ( assertMatch ) {
80
+ console . log (
81
+ `Bad formatting of '${ algorithmName } ' step (Assert should be immediately followed by ':'; found '${ assertMatch [ 2 ] } ') in '${ filename } ':`
82
+ ) ;
83
+ console . dir ( step ) ;
84
+ console . log ( ) ;
85
+ process . exitCode = 1 ;
86
+ }
78
87
79
88
const stepWithoutValueLiterals = step . replace (
80
89
valueLiteralsRegexp ,
@@ -131,6 +140,10 @@ for (const filename of filenames) {
131
140
console . log ( ) ;
132
141
process . exitCode = 1 ;
133
142
}
143
+ while ( lines [ i + 1 ] . trim ( ) !== "" ) {
144
+ // Continuation of definition
145
+ i ++ ;
146
+ }
134
147
if ( ! lines [ i + 2 ] . startsWith ( "- " ) ) {
135
148
// Not an algorithm; probably more grammar
136
149
continue ;
@@ -176,6 +189,15 @@ for (const filename of filenames) {
176
189
console . log ( ) ;
177
190
process . exitCode = 1 ;
178
191
}
192
+ const assertMatch = step . match ( / ^ \s * ( - | [ 0 - 9 ] + \. ) \s * A s s e r t ( [ ^ : ] ) / ) ;
193
+ if ( assertMatch ) {
194
+ console . log (
195
+ `Bad formatting of '${ grammarName } ' step (Assert should be immediately followed by ':'; found '${ assertMatch [ 2 ] } ') in '${ filename } ':`
196
+ ) ;
197
+ console . dir ( step ) ;
198
+ console . log ( ) ;
199
+ process . exitCode = 1 ;
200
+ }
179
201
}
180
202
}
181
203
}
0 commit comments