Skip to content
Snippets Groups Projects
Commit 49bd32cc authored by Anton Bagliy's avatar Anton Bagliy
Browse files

ADD: AST to json serialization in task 6

parent 7cdeee29
Branches
No related merge requests found
......@@ -3,6 +3,8 @@ using System.IO;
using System.Collections.Generic;
using SimpleScanner;
using SimpleParser;
using System.Text;
using Newtonsoft.Json;
namespace SimpleCompiler
{
......@@ -11,6 +13,7 @@ namespace SimpleCompiler
public static void Main()
{
string FileName = @"..\..\a.txt";
string OutputFileName = @"..\..\a.json";
try
{
string Text = File.ReadAllText(FileName);
......@@ -26,8 +29,11 @@ namespace SimpleCompiler
else
{
Console.WriteLine("Синтаксическое дерево построено");
//foreach (var st in parser.root.StList)
//Console.WriteLine(st);
JsonSerializerSettings jsonSettings = new JsonSerializerSettings();
jsonSettings.Formatting = Newtonsoft.Json.Formatting.Indented;
jsonSettings.TypeNameHandling = TypeNameHandling.All;
string output = JsonConvert.SerializeObject(parser.root, jsonSettings);
File.WriteAllText(OutputFileName, output);
}
}
catch (FileNotFoundException)
......
File added
......@@ -34,6 +34,9 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json">
<HintPath>..\..\..\..\Students\МирзоевДенис\Task6\SimpleLanguage1\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment