Skip to content

NRT Migration Phase 2 #324

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/CSTools/Tools/Tools.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<ChangelogFile>../../../CHANGELOG.md</ChangelogFile>
<DefineConstants>TRACE;GENTIME</DefineConstants>
<NoWarn>1701;1702;0162</NoWarn>
<Nullable>disable</Nullable>
</PropertyGroup>

<ItemGroup>
Expand Down
18 changes: 9 additions & 9 deletions src/CSTools/Tools/dfa.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
public string m_refToken = "";
public string m_initialisation = "";
public string m_implement = "";
public static object Serialise(object o,Serialiser s)
public static object? Serialise(object o,Serialiser s)

Check warning on line 49 in src/CSTools/Tools/dfa.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 49 in src/CSTools/Tools/dfa.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
{
if (s==null)
return new TokClassDef();
Expand All @@ -70,7 +70,7 @@
m_tokens = tks.m_tokens;
}
#endif
Tokens m_tokens = null;
Tokens? m_tokens = null;

Check warning on line 73 in src/CSTools/Tools/dfa.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
public static void SetTokens(Tokens tks, Hashtable h) // needed after deserialisation
{
foreach (Dfa v in h.Values)
Expand All @@ -88,7 +88,7 @@
public Action a_next;
public Action(int act,Action next) { a_act = act; a_next = next; }
Action() {}
public static object Serialise(object o,Serialiser s)
public static object? Serialise(object o,Serialiser s)

Check warning on line 91 in src/CSTools/Tools/dfa.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
{
if (s==null)
return new Action();
Expand Down Expand Up @@ -176,7 +176,7 @@
}
}

internal Dfa Target(char ch)
internal Dfa? Target(char ch)

Check warning on line 179 in src/CSTools/Tools/dfa.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 179 in src/CSTools/Tools/dfa.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
{ // construct or lookup the target for a new arc
Dfa n = new Dfa(m_tks);

Expand Down Expand Up @@ -223,7 +223,7 @@
public int Match(string str,int ix,ref int action)
{ // return number of chars matched
int r=0;
Dfa dfa=null;
Dfa? dfa =null;
// if there is no arc or the string is exhausted, this is okay at a terminal
if (ix>=str.Length ||
(dfa=((Dfa)m_map[m_tokens.Filter(str[ix])]))==null ||
Expand Down Expand Up @@ -295,7 +295,7 @@
}
}
#endif
public static object Serialise(object o,Serialiser s)
public static object? Serialise(object o,Serialiser s)

Check warning on line 298 in src/CSTools/Tools/dfa.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 298 in src/CSTools/Tools/dfa.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
{
if (s==null)
return new Dfa();
Expand Down Expand Up @@ -542,7 +542,7 @@
tks.erh.Error(new CSToolsFatalException(1,tks.line(p),tks.position(p),str,String.Format("ill-formed regular expression <{0}>\n", str)));
}
protected Regex() {} // private
public Regex m_sub;
public Regex? m_sub;

Check warning on line 545 in src/CSTools/Tools/dfa.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
public virtual void Print(TextWriter s)
{
if (m_sub!=null)
Expand Down Expand Up @@ -1068,8 +1068,8 @@
// shame we have to do this ourselves, but SortedList doesn't allow incremental building of Dfas
internal class NList
{ // sorted List of NfaNode
public NfaNode m_node; // null for the sentinel
public NList m_next;
public NfaNode? m_node; // null for the sentinel

Check warning on line 1071 in src/CSTools/Tools/dfa.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
public NList? m_next;

Check warning on line 1072 in src/CSTools/Tools/dfa.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
public NList() { m_node=null; m_next=null; } // sentinel only
NList(NfaNode nd,NList nx) { m_node=nd; m_next=nx; }
public bool Add(NfaNode n)
Expand Down
4 changes: 2 additions & 2 deletions src/CSTools/Tools/genbase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
return offset<max; // false if nothing left
}
/// <summary/>
public void EmitClassDefin(string b,ref int p,int max,CsReader inf,string defbas,out string bas, out string name,bool lx)
public void EmitClassDefin(string b,ref int p,int max,CsReader? inf,string defbas,out string bas, out string name,bool lx)

Check warning on line 88 in src/CSTools/Tools/genbase.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
{
bool defconseen = false;
name = "";
Expand Down Expand Up @@ -170,7 +170,7 @@
}
m_outFile.WriteLine("}");
}

[DoesNotReturn]
public void Error(int n,int p,string str)
{
Expand Down
34 changes: 17 additions & 17 deletions src/CSTools/Tools/lexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@
return new ChTest(Char.IsControl); // not reached
}
#endif
public virtual TOKEN OldAction(Lexer yyl,string yytext,int action,ref bool reject)
public virtual TOKEN? OldAction(Lexer yyl,string yytext,int action,ref bool reject)

Check warning on line 237 in src/CSTools/Tools/lexer.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
{
return null;
}
Expand All @@ -247,7 +247,7 @@
public class LineManager
{
public int lines = 1; // for error messages etc
public LineList list = null;
public LineList? list = null;
public LineManager() {}
public void newline(int pos)
{
Expand Down Expand Up @@ -353,7 +353,7 @@
}
return Encoding.ASCII;
}
public static object Serialise(object o,Serialiser s)
public static object? Serialise(object o,Serialiser s)
{
if (s==null)
return new Charset();
Expand All @@ -378,7 +378,7 @@

public class Tfactory
{
public static object create(string cls_name,Lexer yyl)
public static object? create(string cls_name,Lexer yyl)

Check warning on line 381 in src/CSTools/Tools/lexer.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
{
TCreator cr = (TCreator) yyl.tokens.types[cls_name];
// Console.WriteLine("TCreating {0} <{1}>",cls_name,yyl.yytext);
Expand Down Expand Up @@ -414,13 +414,13 @@
public class LineList
{ // based on Appel's ErrorMsg class
public int head;
public CommentList comments = null;
public LineList tail;
public LineList(int h, LineList t)
public CommentList? comments = null;
public LineList? tail;
public LineList(int h, LineList? t)
{
head=h;
comments = null;
tail=t;
head = h;
comments = null;
tail = t;
}
public int getpos(int pos)
{
Expand All @@ -434,7 +434,7 @@
public class CommentList
{ // similar for comments on a line
public int spos,len;
public CommentList tail = null;
public CommentList? tail = null;
public CommentList(int st,int ln, CommentList t)
{
spos = st; len = ln;
Expand Down Expand Up @@ -629,8 +629,8 @@
public virtual bool IsAction() { return false; }
public virtual bool IsCSymbol() { return false; }
//[NonSerialized]
public Parser yyps = null;
public Symbols yyact { get { return (yyps!=null)?yyps.m_symbols:null; }}
public Parser? yyps = null;
public Symbols? yyact { get { return (yyps!=null)?yyps.m_symbols:null; }}

Check warning on line 633 in src/CSTools/Tools/lexer.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
public SYMBOL(Parser yyp) { yyps=yyp; yylx=yyp.m_lexer; }
public virtual bool Pass(Symbols syms,int snum,out ParserEntry entry)
{
Expand Down Expand Up @@ -823,9 +823,9 @@
m_buf = m_buf.ToUpper();
m_pch = 0;
}
public TOKEN Next()
public TOKEN? Next()
{
TOKEN rv = null;
TOKEN? rv = null;
while (PeekChar()!=0)
{
Matching(true);
Expand Down Expand Up @@ -919,14 +919,14 @@
public class _Enumerator
{
Lexer lxr;
TOKEN t;
TOKEN? t;
public _Enumerator(Lexer x) { lxr = x; t = null; }
public bool MoveNext()
{
t = lxr.Next();
return t!=null;
}
public TOKEN Current { get { return t; } }
public TOKEN? Current { get { return t; } }
public void Reset() { lxr.Reset(); }
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/CSTools/Tools/olist.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
else
last = last.next = a;
}
object Get0(Link a,int x) {
object? Get0(Link a,int x) {

Check warning on line 23 in src/CSTools/Tools/olist.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
if (a==null || x<0) // safety
return null;
if (x==0)
Expand All @@ -39,7 +39,7 @@
public class OListEnumerator : IEnumerator
{
ObjectList list;
Link cur = null;
Link? cur = null;

Check warning on line 42 in src/CSTools/Tools/olist.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
public object Current { get { return cur.it; }}
public OListEnumerator(ObjectList o)
{
Expand Down
Loading
Loading