@@ -28,7 +28,7 @@ for (const filename of filenames) {
2828 const matches = line . match ( / ^ ( [ a - z 0 - 9 A - Z ] + ) ( \s * ) \( ( [ ^ ) ] * ) \) ( \s * ) : ( \s * ) $ / ) ;
2929 const grammarMatches =
3030 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 ) .* ) $ / ) ;
3232 if ( matches ) {
3333 const [ , algorithmName , ns1 , _args , ns2 , ns3 ] = matches ;
3434 if ( ns1 || ns2 || ns3 ) {
@@ -67,14 +67,23 @@ for (const filename of filenames) {
6767 console . log ( ) ;
6868 process . exitCode = 1 ;
6969 }
70- if ( step . match ( / ^ \s * ( - | [ 0 - 9 ] \. ) \s + [ a - z ] / ) ) {
70+ if ( step . match ( / ^ \s * ( - | [ 0 - 9 ] + \. ) \s + [ a - z ] / ) ) {
7171 console . log (
7272 `Bad formatting of '${ algorithmName } ' step (should start with a capital) in '${ filename } ':`
7373 ) ;
7474 console . dir ( step ) ;
7575 console . log ( ) ;
7676 process . exitCode = 1 ;
7777 }
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+ }
7887
7988 const stepWithoutValueLiterals = step . replace (
8089 valueLiteralsRegexp ,
@@ -131,6 +140,10 @@ for (const filename of filenames) {
131140 console . log ( ) ;
132141 process . exitCode = 1 ;
133142 }
143+ while ( lines [ i + 1 ] . trim ( ) !== "" ) {
144+ // Continuation of definition
145+ i ++ ;
146+ }
134147 if ( ! lines [ i + 2 ] . startsWith ( "- " ) ) {
135148 // Not an algorithm; probably more grammar
136149 continue ;
@@ -176,6 +189,15 @@ for (const filename of filenames) {
176189 console . log ( ) ;
177190 process . exitCode = 1 ;
178191 }
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+ }
179201 }
180202 }
181203 }
0 commit comments