This commit is contained in:
Ivan Bondarev 2021-10-10 09:53:41 +02:00
parent 041847f552
commit 29a2fb4156
9 changed files with 84 additions and 8 deletions

View file

@ -1,9 +1,9 @@
//
// This CSharp output file generated by Gardens Point LEX
// Version: 1.1.3.301
// Machine: DESKTOP-G8V08V4
// DateTime: 23.09.2021 17:46:26
// UserName: ?????????
// Machine: DESKTOP-2BJCJ7I
// DateTime: 07.10.2021 20:25:46
// UserName: ibond
// GPLEX input file <ABCPascal.lex>
// GPLEX frame file <embedded resource>
//
@ -2260,6 +2260,21 @@ parsertools.DivideDirectiveOn(yytext,out directivename,out directiveparam);
IfExclude--;
if (IfExclude == 0)
BEGIN(INITIAL);
}
else if (IfExclude > 0)
{
int ind_to_remove = -1;
for (int i=0; i<parsertools.compilerDirectives.Count; i++)
{
if (parsertools.compilerDirectives[i].source_context.begin_position.line_num == CurrentLexLocation.StartLine &&
parsertools.compilerDirectives[i].source_context.begin_position.column_num - 2 == CurrentLexLocation.StartColumn + 1)
{
ind_to_remove = i;
break;
}
}
if (ind_to_remove != -1)
parsertools.compilerDirectives.RemoveAt(ind_to_remove);
}
break;
case 72:

View file

@ -154,6 +154,22 @@ UNICODEARROW \x890
if (IfExclude == 0)
BEGIN(INITIAL);
}
else if (IfExclude > 0)
{
int ind_to_remove = -1;
for (int i=0; i<parsertools.compilerDirectives.Count; i++)
{
if (parsertools.compilerDirectives[i].source_context.begin_position.line_num == CurrentLexLocation.StartLine &&
parsertools.compilerDirectives[i].source_context.begin_position.column_num - 2 == CurrentLexLocation.StartColumn + 1)
{
ind_to_remove = i;
break;
}
}
if (ind_to_remove != -1)
parsertools.compilerDirectives.RemoveAt(ind_to_remove);
}
}
<EXCLUDETEXT>.|\n {

View file

@ -46,6 +46,7 @@ namespace PascalABCSavParser
public bool build_tree_for_formatter = false;
public bool build_tree_for_format_strings = false;
public string CurrentFileName;
public List<compiler_directive> compilerDirectives;
int lambda_num = 0;
public List<function_lambda_definition> pascalABC_lambda_definitions;

View file

@ -1,9 +1,9 @@
// (see accompanying GPPGcopyright.rtf)
// GPPG version 1.3.6
// Machine: DESKTOP-G8V08V4
// DateTime: 23.09.2021 17:46:26
// UserName: ?????????
// Machine: DESKTOP-2BJCJ7I
// DateTime: 07.10.2021 20:25:47
// UserName: ibond
// Input file <ABCPascal.y>
// options: no-lines gplex

View file

@ -30,7 +30,7 @@ namespace PascalABCCompiler.PascalABCNewParser
this.FileName = FileName;
}
public syntax_tree_node Parse(string Text)
public syntax_tree_node Parse(string Text, List<compiler_directive> compilerDirectives=null)
{
#if DEBUG
#if _ERR
@ -43,6 +43,7 @@ namespace PascalABCCompiler.PascalABCNewParser
PT parsertools = new PT(); // контекст сканера и парсера
parsertools.errors = Errs;
parsertools.warnings = Warnings;
parsertools.compilerDirectives = compilerDirectives;
parsertools.CurrentFileName = Path.GetFullPath(FileName);
@ -94,6 +95,7 @@ namespace PascalABCCompiler.PascalABCNewParser
var parser = new PreprocessorParser(scanner);
parser.compilerDirectives = compilerDirectives;
parsertools.compilerDirectives = compilerDirectives;
//parser.parsertools = parsertools; // передали parsertools в объект парсера
if (!parser.Parse())
@ -200,7 +202,7 @@ namespace PascalABCCompiler.PascalABCNewParser
localparserhelper = new GPPGParserHelper(Errors, Warnings, FileName);
localparserhelper.DefinesList = DefinesList;
syntax_tree_node root = localparserhelper.Parse(Text);
syntax_tree_node root = localparserhelper.Parse(Text, preprocessor3.compilerDirectives);
if (Errors.Count > 0)
return null;

20
TestSuite/debug2.pas Normal file
View file

@ -0,0 +1,20 @@
{$ifdef asd}
{$resource 'ddddd'}
{$endif asd}
{$define asd}
{$ifdef asd}
{$ifdef asd2}
{$resource 'ddddd'}
{$endif asd2}
{$endif asd}
{$define asd3}
{$undef asd3}
{$ifdef asd3}
{$resource 'НеСуществующийФайл'}
{$endif asd3}
begin
end.

View file

@ -0,0 +1,6 @@
{$ifndef asd}
{$resource 'НеСуществующийФайл'}
{$endif asd}
begin
end.

View file

@ -0,0 +1,7 @@
{$define asd}
{$ifdef asd}
{$resource 'НеСуществующийФайл'}
{$endif asd}
begin
end.

View file

@ -0,0 +1,9 @@
{$define asd}
{$ifdef asd}
{$resource 'НеСуществующийФайл'}
{$endif asd}
{$undef asd}
begin
end.