<commit_before>﻿// REFERENCE: Json.Grammar.dll

using N2;
using N2.Tests;

using System;
using System.IO;

namespace Sample.Json.Cs
{
  class Program
  {
    static void Main()
    {
      Test(@"{ : 1}");
      Test(@"{ a }");
      Test(@"{ a: }");
      Test(@"{ a:, }");
    }

    static void Test(string text)
    {
      var source = new SourceSnapshot(text);
      var parserHost = new ParserHost();
      var parseResult = JsonParser.Start(source, parserHost);

      var ast = JsonParserAstWalkers.Start(parseResult);
      Console.WriteLine("Pretty print: " + ast.ToString(ToStringOptions.DebugIndent | ToStringOptions.MissingNodes));
    }
  }
}

/*
BEGIN-OUTPUT
Pretty print: {
  ### MISSING ###: 1
}
Pretty print: {
  a: ### MISSING ###
}
Pretty print: {
  a: ### MISSING ###
}
Pretty print: {
  a: ### MISSING ###,
  ### MISSING ###
}
END-OUTPUT
*/<commit_msg>Add test.<commit_after>﻿// REFERENCE: Json.Grammar.dll

using N2;
using N2.Tests;

using System;
using System.IO;

namespace Sample.Json.Cs
{
  class Program
  {
    static void Main()
    {
      Test(@"{ : 1}");
      Test(@"{ a }");
      Test(@"{ a: }");
      Test(@"{ a:, }");
      Test(@"{ 'a':, a:1}")
    }

    static void Test(string text)
    {
      var source = new SourceSnapshot(text);
      var parserHost = new ParserHost();
      var parseResult = JsonParser.Start(source, parserHost);

      var ast = JsonParserAstWalkers.Start(parseResult);
      Console.WriteLine("Pretty print: " + ast.ToString(ToStringOptions.DebugIndent | ToStringOptions.MissingNodes));
    }
  }
}

/*
BEGIN-OUTPUT
Pretty print: {
  ### MISSING ###: 1
}
Pretty print: {
  a: ### MISSING ###
}
Pretty print: {
  a: ### MISSING ###
}
Pretty print: {
  a: ### MISSING ###,
  ### MISSING ###
}
Pretty print: {
  'a': ### MISSING ###,
  a: 1
}
END-OUTPUT
*/
{'fraction_non_alphanumeric': 0.1804717498628634, 'fraction_numerical': 0.005485463521667581, 'mean_word_length': 2.848101265822785, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2940453', 'n_tokens_mistral': 671, 'n_tokens_neox': 652, 'n_words': 146}