Exemple #1
0
        static void Main(string[] args)
        {
            var jsonSerializerSettings = new JsonSerializerSettings
            {
                PreserveReferencesHandling = PreserveReferencesHandling.None,
                // ignore loops
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
                // controls how individual fields are converted
                ContractResolver = new ASTContractResolver(),
            };

            string line;

            while ((line = Console.ReadLine()) != null)
            {
                // TODO(dennwc): handle exceptions and syntax errors
                ParseRequest req = JsonConvert.DeserializeObject <ParseRequest>(line);

                Object ast = Parse(req.content);

                ParseResponse resp = new ParseResponse
                {
                    status = "ok",
                    ast    = ast,
                };
                string json = JsonConvert.SerializeObject(resp, jsonSerializerSettings);
                Console.WriteLine(json);
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            var jsonSerializerSettings = new JsonSerializerSettings
            {
                PreserveReferencesHandling = PreserveReferencesHandling.None,
                ReferenceLoopHandling      = ReferenceLoopHandling.Ignore,
                DefaultValueHandling       = DefaultValueHandling.Ignore,
                ContractResolver           = new ASTContractResolver(),
            };

            string line;

            while ((line = Console.ReadLine()) != null)
            {
                ParseRequest req = JsonConvert.DeserializeObject <ParseRequest>(line);

                Object ast = Parse(req.content);

                ParseResponse resp = new ParseResponse
                {
                    status = "ok",
                    ast    = ast,
                };
                string json = JsonConvert.SerializeObject(resp, jsonSerializerSettings);
                Console.WriteLine(json);
            }
        }