private Field CreateRegexFieldFor(RELiteralExpression node)
 {
     var field = CodeBuilder.CreateField(Context.GetUniqueName("re"), TypeSystemServices.RegexType);
     field.Modifiers = TypeMemberModifiers.Internal | TypeMemberModifiers.Static;
     field.LexicalInfo = node.LexicalInfo;
     _currentType.Members.Add(field);
     return field;
 }
        public override void OnRELiteralExpression(RELiteralExpression node)
        {
            if (AstUtil.IsRhsOfAssignment(node))
                return;

            var field = CreateRegexFieldFor(node);
            AddFieldInitializerToStaticConstructor(field, node);

            ReplaceCurrentNode(CodeBuilder.CreateReference(field));
        }
        override public object Clone()
        {
            RELiteralExpression clone = new RELiteralExpression();

            clone._lexicalInfo       = _lexicalInfo;
            clone._endSourceLocation = _endSourceLocation;
            clone._documentation     = _documentation;
            clone._isSynthetic       = _isSynthetic;
            clone._entity            = _entity;
            if (_annotations != null)
            {
                clone._annotations = (Hashtable)_annotations.Clone();
            }
            clone._expressionType = _expressionType;
            clone._value          = _value;
            return(clone);
        }
        override public object Clone()
        {
            RELiteralExpression clone = (RELiteralExpression)FormatterServices.GetUninitializedObject(typeof(RELiteralExpression));

            clone._lexicalInfo       = _lexicalInfo;
            clone._endSourceLocation = _endSourceLocation;
            clone._documentation     = _documentation;
            clone._entity            = _entity;
            if (_annotations != null)
            {
                clone._annotations = (Hashtable)_annotations.Clone();
            }

            clone._expressionType = _expressionType;
            clone._value          = _value;
            return(clone);
        }
Esempio n. 5
0
        public override void OnRELiteralExpression(RELiteralExpression node)
        {
            RegexOptions options = AstUtil.GetRegexOptions(node);

            _il.Emit(OpCodes.Ldstr, node.Pattern);
            if (options == RegexOptions.None)
            {
                _il.Emit(OpCodes.Newobj, Regex_Constructor);
            }
            else
            {
                EmitLoadLiteral((int) options);
                _il.Emit(OpCodes.Newobj, Regex_Constructor_Options);
            }

            PushType(node.ExpressionType);
        }
Esempio n. 6
0
        public override void OnRELiteralExpression(RELiteralExpression node)
        {
            if (null != node.Entity)
            {
                return;
            }

            IType type = TypeSystemServices.RegexType;
            BindExpressionType(node, type);

            if (NodeType.Field != node.ParentNode.NodeType)
            {
                ReplaceByStaticFieldReference(node, Context.GetUniqueName("re"), type);
            }
        }
Esempio n. 7
0
 public static CompilerError InvalidRegexOption(RELiteralExpression node, char option)
 {
     return Instantiate("BCE0173", node, option);
 }
Esempio n. 8
0
		public override void OnRELiteralExpression(RELiteralExpression node)
		{
			MakeLiteralResult("System.Text.RegularExpressions.Regex");
		}
Esempio n. 9
0
        public override void OnRELiteralExpression(RELiteralExpression node)
        {
            if (null != node.Entity)
            {
                return;
            }

            IType type = TypeSystemServices.RegexType;
            BindExpressionType(node, type);

            if (NodeType.Field != node.ParentNode.NodeType)
            {
                ReplaceByStaticFieldReference(node, "$re$" + _context.AllocIndex(), type);
            }
        }
Esempio n. 10
0
 public override void OnRELiteralExpression(RELiteralExpression node)
 {
     int options = (int) AstUtil.GetRegexOptions(node);
 }
Esempio n. 11
0
        internal static RegexOptions GetRegexOptions(RELiteralExpression re)
        {
            RegexOptions ro = RegexOptions.None;

            if (String.IsNullOrEmpty(re.Options))
            {
                return(ro);
            }

            foreach (char opt in re.Options)
            {
                switch (opt)
                {
                /* common flags */
                case 'g':
                    break;                             //no-op on .NET, global by default

                case 'i':
                    ro |= RegexOptions.IgnoreCase;
                    break;

                case 'm':
                    ro |= RegexOptions.Multiline;
                    break;

                /* perl|python flags */
                case 's':
                    ro |= RegexOptions.Singleline;
                    break;

                case 'x':
                    //TODO: parser support, no-op for now
                    //ro |= RegexOptions.IgnorePatternWhitespace;
                    break;

                case 'l':                         //no-op on .NET, (l)ocale-aware by default
                    break;

                /* boo-specific flags */
                case 'n':                         //culture-(n)eutral
                    ro |= RegexOptions.CultureInvariant;
                    break;

                case 'c':
                                                #if !MONOTOUCH
                    ro |= RegexOptions.Compiled;
                                                #endif
                    break;

                case 'e':
                    ro |= RegexOptions.ExplicitCapture;
                    break;

                default:
                    My <CompilerErrorCollection> .Instance.Add(
                        CompilerErrorFactory.InvalidRegexOption(re, opt));

                    break;
                }
            }
            return(ro);
        }
Esempio n. 12
0
		override public object Clone()
		{
		
			RELiteralExpression clone = new RELiteralExpression();
			clone._lexicalInfo = _lexicalInfo;
			clone._endSourceLocation = _endSourceLocation;
			clone._documentation = _documentation;
			clone._isSynthetic = _isSynthetic;
			clone._entity = _entity;
			if (_annotations != null) clone._annotations = (Hashtable)_annotations.Clone();
			clone._expressionType = _expressionType;
			clone._value = _value;
			return clone;


		}
Esempio n. 13
0
 public override void OnRELiteralExpression(RELiteralExpression e)
 {
     if (IsExtendedRE(e.Value))
     {
         Write("@");
     }
     Write(e.Value);
 }
 public RELiteralExpression re_literal()
 {
     RELiteralExpression expression = null;
     IToken token = null;
     try
     {
         token = this.LT(1);
         this.match(0x69);
         if (base.inputState.guessing == 0)
         {
             expression = new RELiteralExpression(ToLexicalInfo(token), token.getText());
         }
     }
     catch (RecognitionException exception)
     {
         if (base.inputState.guessing != 0)
         {
             throw;
         }
         this.reportError(exception);
         this.recover(exception, tokenSet_20_);
         return expression;
     }
     return expression;
 }
Esempio n. 15
0
	protected RELiteralExpression  re_literal() //throws RecognitionException, TokenStreamException
{
		RELiteralExpression re;
		
		IToken  value = null;
		re = null;
		
		try {      // for error handling
			value = LT(1);
			match(RE_LITERAL);
			if (0==inputState.guessing)
			{
				re = new RELiteralExpression(ToLexicalInfo(value), value.getText());
			}
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex, "re_literal");
				recover(ex,tokenSet_44_);
			}
			else
			{
				throw ex;
			}
		}
		return re;
	}
Esempio n. 16
0
        public override void OnRELiteralExpression(RELiteralExpression node)
        {
            if (null != node.Entity)
                return;

            IType type = TypeSystemServices.RegexType;
            BindExpressionType(node, type);
        }
Esempio n. 17
0
 public override void OnRELiteralExpression(RELiteralExpression node)
 {
     _il.Emit(OpCodes.Ldstr, RuntimeServices.Mid(node.Value, 1, -1));
     _il.Emit(OpCodes.Newobj, Regex_Constructor);
     PushType(node.ExpressionType);
 }