@@ -263,6 +263,7 @@ private void AppendCodeInfo(CompilerException exc, int line, int column)
263263
264264 private void DispatchModuleBuild ( )
265265 {
266+ HandleImportDirectives ( ) ;
266267 while ( _lastExtractedLexem . Type != LexemType . EndOfText )
267268 {
268269 if ( _lastExtractedLexem . Type == LexemType . Identifier )
@@ -425,16 +426,26 @@ private static void FillVariablesFrame(ref MethodDescriptor descriptor, SymbolSc
425426 }
426427 }
427428
428- private void HandleDirective ( bool codeEntered )
429+ private void HandleDirective ( )
429430 {
430431 var directive = _lastExtractedLexem . Content ;
431-
432432 var value = _lexer . Iterator . ReadToLineEnd ( ) ;
433433
434- if ( DirectiveHandler == null || ! DirectiveHandler ( directive , value , codeEntered ) )
434+ if ( DirectiveHandler == null || ! DirectiveHandler ( directive , value , _isCodeEntered ) )
435435 throw new CompilerException ( String . Format ( "Неизвестная директива: {0}({1})" , directive , value ) ) ;
436436 }
437437
438+ private void HandleImportDirectives ( )
439+ {
440+ while ( _lastExtractedLexem . Type == LexemType . PreprocessorDirective )
441+ {
442+ HandleDirective ( ) ;
443+ UpdateCompositeContext ( ) ; // костыль для #330
444+
445+ _lastExtractedLexem = _lexer . NextLexem ( ) ;
446+ }
447+ }
448+
438449 private void BuildSingleMethod ( )
439450 {
440451 var entryPoint = _module . Code . Count ;
@@ -713,6 +724,11 @@ private void BuildCodeBatch(params Token[] endTokens)
713724 continue ;
714725 }
715726
727+ if ( _lastExtractedLexem . Type == LexemType . PreprocessorDirective )
728+ {
729+ throw new CompilerException ( String . Format ( "Недопустимая директива: {0}" , _lastExtractedLexem . Content ) ) ;
730+ }
731+
716732 if ( _lastExtractedLexem . Type != LexemType . Identifier && _lastExtractedLexem . Token != Token . EndOfText )
717733 {
718734 throw CompilerException . UnexpectedOperation ( ) ;
@@ -1973,13 +1989,6 @@ private void NextToken()
19731989 if ( _lastExtractedLexem . Token != Token . EndOfText )
19741990 {
19751991 _lastExtractedLexem = _lexer . NextLexem ( ) ;
1976- while ( _lastExtractedLexem . Type == LexemType . PreprocessorDirective )
1977- {
1978- HandleDirective ( _isCodeEntered ) ;
1979- UpdateCompositeContext ( ) ; // костыль для #330
1980-
1981- _lastExtractedLexem = _lexer . NextLexem ( ) ;
1982- }
19831992 }
19841993 else
19851994 {
0 commit comments