Skip to content
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 TokClassDef(GenBase gbs,string name,string bas)
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)
{
if (s==null)
return new TokClassDef();
Expand All @@ -70,7 +70,7 @@ public Dfa(TokensGen tks) : base(tks)
m_tokens = tks.m_tokens;
}
#endif
Tokens m_tokens = null;
Tokens? m_tokens = null;
public static void SetTokens(Tokens tks, Hashtable h) // needed after deserialisation
{
foreach (Dfa v in h.Values)
Expand All @@ -88,7 +88,7 @@ public class Action
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)
{
if (s==null)
return new Action();
Expand Down Expand Up @@ -176,7 +176,7 @@ internal void AddActions()
}
}

internal Dfa Target(char ch)
internal Dfa? Target(char ch)
{ // construct or lookup the target for a new arc
Dfa n = new Dfa(m_tks);

Expand Down Expand Up @@ -223,7 +223,7 @@ internal bool SameAs(Dfa dfa)
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 @@ public void Print()
}
}
#endif
public static object Serialise(object o,Serialiser s)
public static object? Serialise(object o,Serialiser s)
{
if (s==null)
return new Dfa();
Expand Down Expand Up @@ -542,7 +542,7 @@ public Regex(TokensGen tks,int p,string str)
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;
public virtual void Print(TextWriter s)
{
if (m_sub!=null)
Expand Down Expand Up @@ -1068,8 +1068,8 @@ public Nfa(TokensGen tks,Regex re) : base(tks)
// 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
public NList? m_next;
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 @@ public bool NonWhite(string buf, ref int offset,int max)
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)
{
bool defconseen = false;
name = "";
Expand Down Expand Up @@ -170,7 +170,7 @@ public void EmitClassDefin(string b,ref int p,int max,CsReader inf,string defbas
}
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 @@ internal ChTest GetTest(string name)
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)
{
return null;
}
Expand All @@ -247,7 +247,7 @@ public IEnumerator GetEnumerator()
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 @@ public static Encoding GetEncoding(string enc, ref bool toupper,ErrorHandler erh
}
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 static object Serialise(object o,Serialiser s)

public class Tfactory
{
public static object create(string cls_name,Lexer yyl)
public static object? create(string cls_name,Lexer yyl)
{
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 Tfactory(Tokens tks,string cls_name,TCreator cr)
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 int getpos(int pos)
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 @@ protected SYMBOL() {}
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; }}
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 @@ public void Start(string buf)
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 void Reset()
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 @@ void Add0(Link a) {
else
last = last.next = a;
}
object Get0(Link a,int x) {
object? Get0(Link a,int x) {
if (a==null || x<0) // safety
return null;
if (x==0)
Expand All @@ -39,7 +39,7 @@ public ObjectList() {}
public class OListEnumerator : IEnumerator
{
ObjectList list;
Link cur = null;
Link? cur = null;
public object Current { get { return cur.it; }}
public OListEnumerator(ObjectList o)
{
Expand Down
Loading