Esempio n. 1
0
		public virtual literal create_string_const(GPBParser parser)
		{
			literal lt;
            string text = parser.LRParser.TokenString;
			if (text.Length==3 && text[0]=='\'' && text[2]=='\'')
			{
				lt=new char_const(text[1]);
                lt.source_context = GetTokenSourceContext(parser.LRParser);//create_source_context(token);
				return lt;
			}
            text = ReplaceSpecialSymbols(text.Substring(1, text.Length - 2));
			lt=new string_const(text);
            lt.source_context = GetTokenSourceContext(parser.LRParser);//create_source_context(token);
			return lt;
			
		}
Esempio n. 2
0
        public GoldParser.Parser parser; // Ужас - два разных парсера! SSM 19.01.12

        public virtual void check_comment_text(GPBParser parser)
        {

        }
Esempio n. 3
0
        public virtual const_node create_int_const(GPBParser parser, System.Globalization.NumberStyles NumberStyles)
		{
            //таблица целых констант на уровне синтаксиса
            //      не может быть - 0 +
            // 32--------16----8----|----8----16--------32----------------64(bits)
            // [  int64  )[       int32       ](  int64 ](      uint64     ]
            string text = parser.LRParser.TokenString;
            if (NumberStyles == System.Globalization.NumberStyles.HexNumber)
                text = text.Substring(1);
            const_node cn=new int32_const();
            SourceContext sc = GetTokenSourceContext(parser.LRParser);//create_source_context(token);
            if (text.Length < 8)
                (cn as int32_const).val = Int32.Parse(text, NumberStyles);
            else
            {
                try
                {
                    UInt64 uint64 = UInt64.Parse(text, NumberStyles);
                    if (uint64 <= Int32.MaxValue)
                        (cn as int32_const).val = (Int32)uint64;
                    else
                        if (uint64 <= Int64.MaxValue)
                            cn = new int64_const((Int64)uint64);
                        else
                            cn = new uint64_const(uint64);
                }
                catch (Exception)
                {
                    if(NumberStyles == System.Globalization.NumberStyles.HexNumber)
                        parser.errors.Add(new BadHex(parser.current_file_name, sc, (syntax_tree_node)parser.prev_node));
                    else
                        parser.errors.Add(new BadInt(parser.current_file_name, sc, (syntax_tree_node)parser.prev_node));
                }
            }
            cn.source_context = sc;
			return cn;
		}
Esempio n. 4
0
 public virtual ident create_ident(GPBParser parser)
 {
     string text = parser.LRParser.TokenString;
     if (text.IndexOf('&') == 0)
         text = text.Substring(1);
     ident id = new ident(text);
     id.source_context = GetTokenSourceContext(parser.LRParser);
     return id;
 }
Esempio n. 5
0
 public virtual const_node create_hex_const(GPBParser parser)
 {
     return create_int_const(parser, System.Globalization.NumberStyles.HexNumber);
 }
Esempio n. 6
0
        public virtual const_node create_double_const(GPBParser parser)
		{
			const_node cn=null;
            SourceContext sc = GetTokenSourceContext(parser.LRParser);
			try
			{
				System.Globalization.NumberFormatInfo sgnfi=new System.Globalization.NumberFormatInfo();
				sgnfi.NumberDecimalSeparator=".";
				double val=double.Parse(parser.LRParser.TokenString,sgnfi);
				cn=new double_const(val);
				cn.source_context=sc;
			}
			catch(Exception)
			{
				parser.errors.Add(new BadFloat(parser.current_file_name,sc,(syntax_tree_node)parser.prev_node));
			}
			return cn;
		}
Esempio n. 7
0
 public virtual sharp_char_const create_sharp_char_const(GPBParser parser)
 {
     string text = parser.LRParser.TokenString;
     string int_text = new string(text.ToCharArray(1, text.Length - 1));
     SourceContext sc = GetTokenSourceContext(parser.LRParser);//create_source_context(token);
     sharp_char_const scc = null;
     int val = 0;
     if (int.TryParse(int_text, out val))
     {
         if (val > max_char_const)
         {
             scc = new sharp_char_const(0);
             parser.errors.Add(new TooBigCharNumberInSharpCharConstant(parser.current_file_name, sc, scc));
         }
         else
             scc = new sharp_char_const(val);
         scc.source_context = sc;
     }
     else
     {
         parser.errors.Add(new TooBigCharNumberInSharpCharConstant(parser.current_file_name, sc, scc));
     }
     return scc;
 }
Esempio n. 8
0
 public virtual char_const create_char_const(GPBParser parser)
 {
     return create_char_const(parser.LRParser.TokenString,GetTokenSourceContext(parser.LRParser));
 }
Esempio n. 9
0
 public virtual ident create_directive_name(GPBParser parser)
 {
     return create_directive_name(parser.LRParser.TokenString, GetTokenSourceContext(parser.LRParser));
 }