您当前的位置: 首页 > 

Jave.Lin

暂无认证

  • 5浏览

    0关注

    704博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

小探正则

Jave.Lin 发布时间:2016-08-16 12:00:02 ,浏览量:5

转载注:http://blog.csdn.net/linjf520/article/details/52219516

SubLime Text 2中的正则测试:

获取包信息 \bpackage\s+([\w+\.?]+)

获取取import信息 import\s+([\w+\.?]+)\;$

获取private/protected/public合并写法 但目前这里有个问题,就是无法区别:是local还是global的变量,因为as3的global的变量也是可以不写访问级别,默认为:internal的后面再考虑 \b(?:(public|private|protected)\s+)?(static)?(const)?var\s+(?:(\w+)\s*:\s*(\w+))\s*(?:,\s*(\w+)\s*:\s*(\w+))*\s*(?:\s*=\s*(\w+))?;$

获取方法信息 \b((public|private|protected)\s+)?function\s+(\w+)\s*\(\s*((\w+)\s*(:\s*(\w+))?)\s*(,\s*((\w+)\s*(:\s*(\w+))?))*\s*\)\s*:\s*void\s*((\{[.\w\W]*?\})+?)

获取类信息 \bpublic\s*class\s+(\w+)(?:(\s*(?:(extends\s+(\w+))?)\s*(?:(?:implements\s+(\w+(,\s*\w+)*))?)\s*)?)\s*\{

获取嵌入类信息 ^\s*class\s+(\w+?)((\s*((extends\s+(\w+))?)\s*((implements\s+(\w+))?)\s*)?)\s*\{([.\w\W]*)\}

测试采样数据:

package nParticleSys.sadfas.asdasdf.fdas.asdf
{
    import flash.display.Bitmap;
    import flash.geom.Matrix;

    import starling.utils.Util;

    /**
     * [description]
     * @author Jave.Lin
     * @date 2016-7-20
     * */
    public class Particle extends ExtCls implements IT1, IT2, IT3
    {
        private static var _pool:Array = [];

        public static function getPs():Particle
        {
            var result:Particle;
            if (_pool.length > 0)
            {
                result = _pool.pop();
            }
            else
            {
                result = new Particle();
            }
            return result;
        }

        public static function recyclePs(ps:Particle):void
        {
            _pool.push(ps);
        }

        public static function init(ps:Particle):void
        {
            ps.x = ps.y = 0;
            ps.angle = 0;
            ps.scale = 1;
            ps.alpha = 1;

            ps.vx = ps.vy = 0;
            ps.angleV = 0;
            ps.scaleV = 0;
            ps.alphaV = 0;

            ps.elapsedTime = 0;
            ps.totalTime = 1;

            ps.transform = new Matrix();
            ps.enabled = true;
        }

        public var x:Number, y:Number;
        public var angle:Number;
        public var scale:Number;
        public var alpha:Number;

        public var vx:Number, vy:Number;
        public var angleV:Number;
        public var scaleV:Number;
        public var alphaV:Number;

        public var elapsedTime:Number;
        public var totalTime:Number;

        public var texture:Bitmap;

        public var transform:Matrix;

        public var enabled:Boolean;

        public function applyTransform():void
        {
            transform.identity();
            if (texture)
            {
                if (texture.bitmapData)
                {
                    transform.translate(texture.bitmapData.width * -0.5, texture.bitmapData.height * -0.5);
                }
                transform.scale(scale, scale);
                transform.rotate(angle);
                transform.translate(x, y);

                texture.transform.matrix = transform;

                texture.alpha = Util.clamp(alpha, 0, 1);
            }
        }

        public function recycle():void
        {
            elapsedTime = 0;
            totalTime = 0;
            enabled = false;
            transform = null;

            if (texture)
            {
                if (texture.parent)
                {
                    texture.parent.removeChild(texture);
                }
                texture.bitmapData = null;
                texture = null;
            }
        }
    }
}

   class Name
{

}

距离写语法分析还有很长距离; 不同的语言中,正则的一些用法还是不一样的; 如:组引用,在py中

            
关注
打赏
1664331872
查看更多评论
0.1472s