File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed
src/ScriptEngine/Compiler Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -294,6 +294,10 @@ private void DispatchModuleBuild()
294294 {
295295 BuildAnnotations ( ) ;
296296 }
297+ else if ( _lastExtractedLexem . Type == LexemType . PreprocessorDirective )
298+ {
299+ throw CompilerException . IllegalDirective ( _lastExtractedLexem . Content ) ;
300+ }
297301 else
298302 {
299303 throw CompilerException . UnexpectedOperation ( ) ;
@@ -432,7 +436,7 @@ private void HandleDirective()
432436 var value = _lexer . Iterator . ReadToLineEnd ( ) ;
433437
434438 if ( DirectiveHandler == null || ! DirectiveHandler ( directive , value , _isCodeEntered ) )
435- throw new CompilerException ( String . Format ( "Неизвестная директива: {0}({1})" , directive , value ) ) ;
439+ throw CompilerException . UnknownDirective ( directive , value ) ;
436440 }
437441
438442 private void HandleImportDirectives ( )
@@ -726,7 +730,7 @@ private void BuildCodeBatch(params Token[] endTokens)
726730
727731 if ( _lastExtractedLexem . Type == LexemType . PreprocessorDirective )
728732 {
729- throw new CompilerException ( String . Format ( "Недопустимая директива: {0}" , _lastExtractedLexem . Content ) ) ;
733+ throw CompilerException . IllegalDirective ( _lastExtractedLexem . Content ) ;
730734 }
731735
732736 if ( _lastExtractedLexem . Type != LexemType . Identifier && _lastExtractedLexem . Token != Token . EndOfText )
Original file line number Diff line number Diff line change @@ -137,6 +137,16 @@ public static CompilerException NumberExpected()
137137 return new CompilerException ( Locale . NStr ( "ru='Ожидается числовая константа';en='Numeric constant expected'" ) ) ;
138138 }
139139
140+ public static CompilerException IllegalDirective ( string name )
141+ {
142+ return new CompilerException ( Locale . NStr ( "ru='Недопустимая директива:';en='Illegal directive'" ) + name ) ;
143+ }
144+
145+ public static CompilerException UnknownDirective ( string name , string arg )
146+ {
147+ return new CompilerException ( Locale . NStr ( "ru='Неизвестная директива:';en='Unknown directive'" ) + $ "{ name } ({ arg } )") ;
148+ }
149+
140150 }
141151
142152 public class ExtraClosedParenthesis : CompilerException
You can’t perform that action at this time.
0 commit comments