diff Implab/JSON/JSONGrammar.cs @ 72:d67b95eddaf4 v2

promises refactoring
author cin
date Thu, 04 Sep 2014 18:47:12 +0400
parents c0bf853aa04f
children 97fbbf816844
line wrap: on
line diff
--- a/Implab/JSON/JSONGrammar.cs	Wed Sep 03 18:34:02 2014 +0400
+++ b/Implab/JSON/JSONGrammar.cs	Thu Sep 04 18:47:12 2014 +0400
@@ -7,7 +7,7 @@
 
 namespace Implab.JSON {
     internal class JSONGrammar : Grammar<JSONGrammar> {
-        public enum TokenType : int{
+        public enum TokenType : int {
             None,
             BeginObject,
             EndObject,
@@ -53,7 +53,6 @@
             var backSlash = SymbolToken('\\');
             var specialEscapeChars = SymbolSetToken('\\', '"', '/', 'b', 'f', 't', 'n', 'r');
             var unicodeEspace = SymbolToken('u').Cat(hexDigit.Repeat(4));
-            var escape = backSlash.Cat(specialEscapeChars.Or(unicodeEspace));
             var whitespace = SymbolSetToken('\n', '\r', '\t', ' ').EClosure();
             var beginObject = whitespace.Cat(SymbolToken('{')).Cat(whitespace);
             var endObject = whitespace.Cat(SymbolToken('}')).Cat(whitespace);
@@ -65,9 +64,6 @@
             var number = minus.Optional().Cat(integer).Cat(frac.Optional()).Cat(exp.Optional());
             var literal = letters.Closure();
             var unescaped = SymbolTokenExcept(Enumerable.Range(0, 0x20).Union(new int[] { '\\', '"' }).Select(x => (char)x));
-            var character = unescaped.Or(escape);
-            var str = quote.Cat(character.EClosure()).Cat(quote);
-            
 
             var jsonExpression =
                 number.Tag(TokenType.Number)
@@ -86,13 +82,7 @@
                 .Or(backSlash.Cat(specialEscapeChars).Tag(TokenType.EscapedChar))
                 .Or(backSlash.Cat(unicodeEspace).Tag(TokenType.EscapedUnicode))
                 .Or(unescaped.Closure().Tag(TokenType.UnescapedChar));
-
-            var jsonNumberExpression =
-                minus.Tag(TokenType.Minus)
-                .Or(SymbolToken('+').Tag(TokenType.Plus))
-                .Or(digit.Closure().Tag(TokenType.Integer))
-                .Or(dot.Tag(TokenType.Dot))
-                .Or(expSign.Tag(TokenType.Exp));
+                    
 
             m_jsonDFA = BuildDFA(jsonExpression);
             m_stringDFA = BuildDFA(jsonStringExpression);