@@ -381,9 +381,6 @@ export class SchemeParser implements Parser {
381381 return unquotedExpression ;
382382 case TokenType . COMMA_AT :
383383 case TokenType . UNQUOTE_SPLICING :
384- // Unquote-splicing will be evaluated at runtime,
385- // Proper unquote splicing will be dealt with in semester 2.
386-
387384 this . validateChapter ( < Token > affector , QUOTING_CHAPTER ) ;
388385 let preUnquoteSplicingMode = this . quoteMode ;
389386 if ( preUnquoteSplicingMode === QuoteMode . NONE ) {
@@ -404,11 +401,6 @@ export class SchemeParser implements Parser {
404401 // wrap the entire expression in a list
405402 return new Extended . List ( newLocation , [ newSymbol , innerGroup ] ) ;
406403 }
407- throw new ParserError . UnsupportedTokenError (
408- this . source ,
409- ( < Token > affector ) . pos ,
410- < Token > affector
411- ) ;
412404 this . quoteMode = QuoteMode . NONE ;
413405 const unquoteSplicedExpression = this . parseExpression ( target ) ;
414406 this . quoteMode = preUnquoteSplicingMode ;
@@ -496,8 +488,12 @@ export class SchemeParser implements Parser {
496488 this . validateChapter ( firstElement , MACRO_CHAPTER ) ;
497489 return this . parseDefineSyntax ( group ) ;
498490 case TokenType . SYNTAX_RULES :
499- this . validateChapter ( firstElement , MACRO_CHAPTER ) ;
500- return this . parseSyntaxRules ( group ) ;
491+ // should not be called outside of define-syntax!
492+ throw new ParserError . UnexpectedFormError (
493+ this . source ,
494+ firstElement . pos ,
495+ firstElement
496+ ) ;
501497
502498 // Scm-slang misc
503499 case TokenType . IMPORT :
@@ -1293,20 +1289,18 @@ export class SchemeParser implements Parser {
12931289 const identifier = elements [ 1 ] ;
12941290 const transformer = elements [ 2 ] ;
12951291
1296- // Identifier is treated as a single identifier
1297- if ( isGroup ( identifier ) ) {
1298- throw new ParserError . ExpectedFormError (
1299- this . source ,
1300- identifier . location . start ,
1301- identifier ,
1302- "<identifier>"
1303- ) ;
1304- }
1292+ // parse the identifier using quote mode
1293+ // (to capture redefinitions of syntax)
1294+ this . quoteMode = QuoteMode . QUOTE ;
1295+ const convertedIdentifier = this . parseExpression (
1296+ identifier
1297+ ) as Atomic . Identifier ;
1298+ this . quoteMode = QuoteMode . NONE ;
13051299
1306- if ( identifier . type !== TokenType . IDENTIFIER ) {
1300+ if ( ! ( convertedIdentifier instanceof Atomic . Symbol ) ) {
13071301 throw new ParserError . ExpectedFormError (
13081302 this . source ,
1309- identifier . pos ,
1303+ convertedIdentifier . location . start ,
13101304 identifier ,
13111305 "<identifier>"
13121306 ) ;
@@ -1350,11 +1344,8 @@ export class SchemeParser implements Parser {
13501344 ) ;
13511345 }
13521346
1353- // parse both the identifier and the transformer
1354- const convertedIdentifier = this . parseExpression (
1355- identifier
1356- ) as Atomic . Identifier ;
1357- const convertedTransformer = this . parseExpression (
1347+ // parse the transformer
1348+ const convertedTransformer = this . parseSyntaxRules (
13581349 transformer
13591350 ) as Atomic . SyntaxRules ;
13601351
0 commit comments