* Extract base classes from ParserTools (local) and GPPGParserHelper * Fix string resources error * Extract base class for unexpected token error * Update ParserTools project file * Add comments for compiler directives usages in compiler * Add directives checks * Move string constants to new project * Implement scalable directives checks * Remove known directives from compiler * Fix PABCSystem namespace error * Allow region and endregion with no params * Allow parameters to endif directive * Delete directive parameters extension checks * Replace error with warning for uknown directive case * Fix generate native code (semantic rule) assigning * Improve error messages for directives * Rename RunParseThread to SwitchOnIntellisence Для отладки может требоваться отключение Intellisence на уровне кода. Для понятности метод назван SwitchOnIntellisence. * Resolve merge conflicts * Add new compiler errors for unsupported target framework and output file type * Add documentation to directives checks * Fix directives check loop
92 lines
2.5 KiB
C#
92 lines
2.5 KiB
C#
// Copyright (c) Ivan Bondarev, Stanislav Mikhalkovich (for details please see \doc\copyright.txt)
|
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
|
|
namespace PascalABCCompiler
|
|
{
|
|
public class TextPosition
|
|
{
|
|
private int column;
|
|
private int line;
|
|
public int Column
|
|
{
|
|
get
|
|
{
|
|
return column;
|
|
}
|
|
set
|
|
{
|
|
column = value;
|
|
}
|
|
}
|
|
public int Line
|
|
{
|
|
get
|
|
{
|
|
return line;
|
|
}
|
|
set
|
|
{
|
|
line = value;
|
|
}
|
|
}
|
|
public TextPosition(int Line, int Column)
|
|
{
|
|
column = Column;
|
|
line = Line;
|
|
}
|
|
}
|
|
public class SourceLocation
|
|
{
|
|
private TextPosition beginPosition;
|
|
public TextPosition BeginPosition
|
|
{
|
|
get
|
|
{
|
|
return beginPosition;
|
|
}
|
|
}
|
|
private TextPosition endPosition;
|
|
public TextPosition EndPosition
|
|
{
|
|
get
|
|
{
|
|
return endPosition;
|
|
}
|
|
}
|
|
private string fileName;
|
|
public string FileName
|
|
{
|
|
get
|
|
{
|
|
return fileName;
|
|
}
|
|
}
|
|
public SourceLocation(string FileName, int BeginLine, int BeginColumn, int EndLine, int EndColumn)
|
|
{
|
|
fileName = FileName;
|
|
beginPosition = new TextPosition(BeginLine, BeginColumn);
|
|
endPosition = new TextPosition(EndLine, EndColumn);
|
|
}
|
|
public SourceLocation(SourceLocation Begin,SourceLocation End)
|
|
{
|
|
fileName = Begin.FileName;
|
|
beginPosition = Begin.beginPosition;
|
|
endPosition = End.EndPosition;
|
|
}
|
|
public static bool operator<(SourceLocation left, SourceLocation right)
|
|
{
|
|
if (left.beginPosition.Line != right.beginPosition.Line)
|
|
return left.beginPosition.Line < right.beginPosition.Line;
|
|
else
|
|
return left.beginPosition.Column < right.beginPosition.Column;
|
|
}
|
|
public static bool operator>(SourceLocation left, SourceLocation right)
|
|
{
|
|
if (left.beginPosition.Line != right.beginPosition.Line)
|
|
return left.beginPosition.Line > right.beginPosition.Line;
|
|
else
|
|
return left.beginPosition.Column > right.beginPosition.Column;
|
|
}
|
|
}
|
|
}
|