Expiriments with AvaloniaEdit and tracking document changes
This commit is contained in:
parent
29a141a971
commit
6325409d25
53 changed files with 643 additions and 627 deletions
|
|
@ -1,4 +1,5 @@
|
|||
using System.Text;
|
||||
using FluentResults;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
|
||||
namespace pgLabII.PgUtils.ConnectionStrings;
|
||||
|
|
@ -8,7 +9,7 @@ public class PqConnectionStringTokenizer : IPqConnectionStringTokenizer
|
|||
private readonly string input;
|
||||
private int position = 0;
|
||||
|
||||
public bool Eof
|
||||
public bool IsEof
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
@ -23,37 +24,38 @@ public class PqConnectionStringTokenizer : IPqConnectionStringTokenizer
|
|||
position = 0;
|
||||
}
|
||||
|
||||
public string GetKeyword()
|
||||
public Result<string> GetKeyword()
|
||||
{
|
||||
if (Eof)
|
||||
throw new PqConnectionStringParserException($"Unexpected end of file was expecting a keyword at position {position}");
|
||||
if (IsEof)
|
||||
return Result.Fail($"Unexpected end of file was expecting a keyword at position {position}");
|
||||
|
||||
return GetString(forKeyword: true);
|
||||
}
|
||||
|
||||
public void ConsumeEquals()
|
||||
public Result ConsumeEquals()
|
||||
{
|
||||
ConsumeWhitespace();
|
||||
if (position < input.Length && input[position] == '=')
|
||||
{
|
||||
position++;
|
||||
return Result.Ok();
|
||||
}
|
||||
else
|
||||
throw new PqConnectionStringParserException($"Was expecting '=' after keyword at position {position}");
|
||||
return Result.Fail($"Was expecting '=' after keyword at position {position}");
|
||||
}
|
||||
|
||||
public string GetValue()
|
||||
public Result<string> GetValue()
|
||||
{
|
||||
if (Eof)
|
||||
throw new PqConnectionStringParserException($"Unexpected end of file was expecting a keyword at position {position}");
|
||||
if (IsEof)
|
||||
return Result.Fail($"Unexpected end of file was expecting a keyword at position {position}");
|
||||
|
||||
return GetString(forKeyword: false);
|
||||
}
|
||||
|
||||
private string GetString(bool forKeyword)
|
||||
private Result<string> GetString(bool forKeyword)
|
||||
{
|
||||
if (forKeyword && input[position] == '=')
|
||||
throw new PqConnectionStringParserException($"Unexpected '=' was expecting keyword at position {position}");
|
||||
return Result.Fail($"Unexpected '=' was expecting keyword at position {position}");
|
||||
|
||||
if (input[position] == '\'')
|
||||
return ParseQuotedText();
|
||||
|
|
@ -75,7 +77,7 @@ public class PqConnectionStringTokenizer : IPqConnectionStringTokenizer
|
|||
return input.Substring(start, position - start);
|
||||
}
|
||||
|
||||
private string ParseQuotedText()
|
||||
private Result<string> ParseQuotedText()
|
||||
{
|
||||
bool escape = false;
|
||||
StringBuilder sb = new();
|
||||
|
|
@ -93,7 +95,7 @@ public class PqConnectionStringTokenizer : IPqConnectionStringTokenizer
|
|||
escape = false;
|
||||
break;
|
||||
default:
|
||||
throw new PqConnectionStringParserException($"Invalid escape sequence at position {position}");
|
||||
return Result.Fail($"Invalid escape sequence at position {position}");
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -113,6 +115,6 @@ public class PqConnectionStringTokenizer : IPqConnectionStringTokenizer
|
|||
}
|
||||
}
|
||||
}
|
||||
throw new PqConnectionStringParserException($"Missing end quote on value starting at {start}");
|
||||
return Result.Fail($"Missing end quote on value starting at {start}");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue