Make parser nodes json serializable
This commit is contained in:
parent
41ab249353
commit
d1b855144e
44
Parser.cs
44
Parser.cs
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace luaaaaah;
|
namespace luaaaaah;
|
||||||
|
|
||||||
@ -16,6 +17,21 @@ class Parser
|
|||||||
public RetstatNode? retstat;
|
public RetstatNode? retstat;
|
||||||
public CodeRegion startRegion = startRegion, endRegion = endRegion;
|
public CodeRegion startRegion = startRegion, endRegion = endRegion;
|
||||||
}
|
}
|
||||||
|
[JsonDerivedType(typeof(Semicolon), typeDiscriminator: "st Semicolon")]
|
||||||
|
[JsonDerivedType(typeof(Assignment), typeDiscriminator: "st Assignment")]
|
||||||
|
[JsonDerivedType(typeof(Functioncall), typeDiscriminator: "st Functioncall")]
|
||||||
|
[JsonDerivedType(typeof(Label), typeDiscriminator: "st Label")]
|
||||||
|
[JsonDerivedType(typeof(Break), typeDiscriminator: "st Break")]
|
||||||
|
[JsonDerivedType(typeof(Goto), typeDiscriminator: "st Goto")]
|
||||||
|
[JsonDerivedType(typeof(Do), typeDiscriminator: "st Do")]
|
||||||
|
[JsonDerivedType(typeof(While), typeDiscriminator: "st While")]
|
||||||
|
[JsonDerivedType(typeof(Repeat), typeDiscriminator: "st Repeat")]
|
||||||
|
[JsonDerivedType(typeof(If), typeDiscriminator: "st If")]
|
||||||
|
[JsonDerivedType(typeof(ForNumerical), typeDiscriminator: "st ForNum")]
|
||||||
|
[JsonDerivedType(typeof(ForGeneric), typeDiscriminator: "st ForGen")]
|
||||||
|
[JsonDerivedType(typeof(Function), typeDiscriminator: "st Function")]
|
||||||
|
[JsonDerivedType(typeof(LocalFunction), typeDiscriminator: "st LocalFunction")]
|
||||||
|
[JsonDerivedType(typeof(Local), typeDiscriminator: "st Local")]
|
||||||
public abstract class StatNode(CodeRegion startRegion, CodeRegion endRegion)
|
public abstract class StatNode(CodeRegion startRegion, CodeRegion endRegion)
|
||||||
{
|
{
|
||||||
public CodeRegion startRegion = startRegion, endRegion = endRegion;
|
public CodeRegion startRegion = startRegion, endRegion = endRegion;
|
||||||
@ -156,6 +172,8 @@ class Parser
|
|||||||
public List<VarNode> vars = vars;
|
public List<VarNode> vars = vars;
|
||||||
public CodeRegion startRegion = startRegion, endRegion = endRegion;
|
public CodeRegion startRegion = startRegion, endRegion = endRegion;
|
||||||
}
|
}
|
||||||
|
[JsonDerivedType(typeof(Normal), typeDiscriminator: "s Normal")]
|
||||||
|
[JsonDerivedType(typeof(Functioncall), typeDiscriminator: "s Functioncall")]
|
||||||
public abstract class SuffixexpNode(CodeRegion startRegion, CodeRegion endRegion)
|
public abstract class SuffixexpNode(CodeRegion startRegion, CodeRegion endRegion)
|
||||||
{
|
{
|
||||||
public CodeRegion startRegion = startRegion, endRegion = endRegion;
|
public CodeRegion startRegion = startRegion, endRegion = endRegion;
|
||||||
@ -168,6 +186,9 @@ class Parser
|
|||||||
public FunctioncallNode node = node;
|
public FunctioncallNode node = node;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
[JsonDerivedType(typeof(Bracketed), typeDiscriminator: "a Bracketed")]
|
||||||
|
[JsonDerivedType(typeof(Tableconstructor), typeDiscriminator: "a Tableconstructor")]
|
||||||
|
[JsonDerivedType(typeof(Literal), typeDiscriminator: "a Literal")]
|
||||||
public abstract class ArgsNode(CodeRegion startRegion, CodeRegion endRegion)
|
public abstract class ArgsNode(CodeRegion startRegion, CodeRegion endRegion)
|
||||||
{
|
{
|
||||||
public CodeRegion startRegion = startRegion, endRegion = endRegion;
|
public CodeRegion startRegion = startRegion, endRegion = endRegion;
|
||||||
@ -184,6 +205,17 @@ class Parser
|
|||||||
public string name = name;
|
public string name = name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
[JsonDerivedType(typeof(Nil), typeDiscriminator: "e Nil")]
|
||||||
|
[JsonDerivedType(typeof(False), typeDiscriminator: "e True")]
|
||||||
|
[JsonDerivedType(typeof(True), typeDiscriminator: "e False")]
|
||||||
|
[JsonDerivedType(typeof(Numeral), typeDiscriminator: "e Numeral")]
|
||||||
|
[JsonDerivedType(typeof(LiteralString), typeDiscriminator: "e Literal")]
|
||||||
|
[JsonDerivedType(typeof(Varargs), typeDiscriminator: "e Varargs")]
|
||||||
|
[JsonDerivedType(typeof(Functiondef), typeDiscriminator: "e Functiondef")]
|
||||||
|
[JsonDerivedType(typeof(Suffixexp), typeDiscriminator: "e Suffixexp")]
|
||||||
|
[JsonDerivedType(typeof(Tableconstructor), typeDiscriminator: "e Tableconstructor")]
|
||||||
|
[JsonDerivedType(typeof(Unop), typeDiscriminator: "e Unop")]
|
||||||
|
[JsonDerivedType(typeof(Binop), typeDiscriminator: "e Binop")]
|
||||||
public abstract class ExpNode(CodeRegion startRegion, CodeRegion endRegion)
|
public abstract class ExpNode(CodeRegion startRegion, CodeRegion endRegion)
|
||||||
{
|
{
|
||||||
public CodeRegion startRegion = startRegion, endRegion = endRegion;
|
public CodeRegion startRegion = startRegion, endRegion = endRegion;
|
||||||
@ -244,6 +276,9 @@ class Parser
|
|||||||
public List<AttnameNode> attnames = attnames;
|
public List<AttnameNode> attnames = attnames;
|
||||||
public CodeRegion startRegion = startRegion, endRegion = endRegion;
|
public CodeRegion startRegion = startRegion, endRegion = endRegion;
|
||||||
}
|
}
|
||||||
|
[JsonDerivedType(typeof(Name), typeDiscriminator: "v Name")]
|
||||||
|
[JsonDerivedType(typeof(Indexed), typeDiscriminator: "v Indexed")]
|
||||||
|
[JsonDerivedType(typeof(Member), typeDiscriminator: "v Member")]
|
||||||
public abstract class VarNode(CodeRegion startRegion, CodeRegion endRegion)
|
public abstract class VarNode(CodeRegion startRegion, CodeRegion endRegion)
|
||||||
{
|
{
|
||||||
public CodeRegion startRegion = startRegion, endRegion = endRegion;
|
public CodeRegion startRegion = startRegion, endRegion = endRegion;
|
||||||
@ -326,6 +361,8 @@ class Parser
|
|||||||
public string name = name;
|
public string name = name;
|
||||||
public CodeRegion startRegion = startRegion, endRegion = endRegion;
|
public CodeRegion startRegion = startRegion, endRegion = endRegion;
|
||||||
}
|
}
|
||||||
|
[JsonDerivedType(typeof(Name), typeDiscriminator: "sfp Name")]
|
||||||
|
[JsonDerivedType(typeof(BracketedExp), typeDiscriminator: "sfp BracketedExp")]
|
||||||
public abstract class SuffixexpFirstPart(CodeRegion startRegion, CodeRegion endRegion)
|
public abstract class SuffixexpFirstPart(CodeRegion startRegion, CodeRegion endRegion)
|
||||||
{
|
{
|
||||||
public CodeRegion startRegion = startRegion, endRegion = endRegion;
|
public CodeRegion startRegion = startRegion, endRegion = endRegion;
|
||||||
@ -338,6 +375,10 @@ class Parser
|
|||||||
public ExpNode node = node;
|
public ExpNode node = node;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
[JsonDerivedType(typeof(Dot))]
|
||||||
|
[JsonDerivedType(typeof(Indexed))]
|
||||||
|
[JsonDerivedType(typeof(Args))]
|
||||||
|
[JsonDerivedType(typeof(ArgsFirstArg))]
|
||||||
public abstract class SuffixexpSuffix(CodeRegion startRegion, CodeRegion endRegion)
|
public abstract class SuffixexpSuffix(CodeRegion startRegion, CodeRegion endRegion)
|
||||||
{
|
{
|
||||||
public CodeRegion startRegion = startRegion, endRegion = endRegion;
|
public CodeRegion startRegion = startRegion, endRegion = endRegion;
|
||||||
@ -369,6 +410,9 @@ class Parser
|
|||||||
public ArgsNode rest = rest;
|
public ArgsNode rest = rest;
|
||||||
public CodeRegion startRegion = startRegion, endRegion = endRegion;
|
public CodeRegion startRegion = startRegion, endRegion = endRegion;
|
||||||
}
|
}
|
||||||
|
[JsonDerivedType(typeof(IndexedAssignment))]
|
||||||
|
[JsonDerivedType(typeof(Assignment))]
|
||||||
|
[JsonDerivedType(typeof(Exp))]
|
||||||
public abstract class FieldNode(CodeRegion startRegion, CodeRegion endRegion)
|
public abstract class FieldNode(CodeRegion startRegion, CodeRegion endRegion)
|
||||||
{
|
{
|
||||||
public CodeRegion startRegion = startRegion, endRegion = endRegion;
|
public CodeRegion startRegion = startRegion, endRegion = endRegion;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user