Archive

Archive for August 2nd, 2010

Announcing the as3parser-framework opensource project

August 2nd, 2010 Michael Schmalle 10 comments

The as3parser-framework is a project culminating from over 5 years of actionscript3 lexing, scanning, tokenizing and parsing observations. This framework is fully independent of the Flex framework or any other library for that matter. A brief list of inclusions;

  • AS3Scanner, AS3Tokenizer, AS3Parser (full AST including block ast)
  • MXMLScanner, MXMLParser (full AST)
  • ASDocScanner, ASDocParser (full AST)
  • A Complete As3 DOM decorator framework wrapping the abstract parser node
  • 100′s of unit tests covering all classes

Thanks to the PMD project in java, a rock solid as3 recursive decent parser was ported. All the other scanners and parser I created myself and tested0. The DOM framework comes mostly from the ASDoc documentor I created in java a couple years ago, that I still use when documenting all of my product components.

Here is the source code;

http://github.com/teotigraphix/as3parser-framework

All the code is released under the Apache 2 license.

How would you like to parse as3/mxml string data, or an .as file or an .mxml file from an AIR application or browser application? Well now you can with full AST.

The following is an example of the decorator node DOM.

var sourceFile:IAS3SourceFile = NodeFactory.instance.
	createSourceFile(source, "/home/src/my/domain/internal.as", "/home/src") as IAS3SourceFile;
 
var compilationNode:ICompilationNode = sourceFile.buildAst();
trace(sourceFile.fileName);
trace(sourceFile.compilationNode.packageNode.name);
trace(sourceFile.compilationNode.packageNode.qualifiedName);
trace(sourceFile.compilationNode.packageNode.typeNode.methods[0].name);
trace(sourceFile.compilationNode.packageNode.typeNode.methods[0].parameters[0].name);
trace(sourceFile.compilationNode.packageNode.typeNode.methods[0].comment.shortDescription);
trace(sourceFile.compilationNode.packageNode.typeNode.methods[0].comment.getDocTags("see"));

I have a large Swiz project that will be using this framework, stay tuned.

Mike

For giggles, here is a class file it digests easily and converts into AST;

/*fpkg*/package foo.bar {
	import pkg.Stuff;
	import mx.core.mx_internal;
	use namespace mx_internal;
 
	/**
	 * Class meta.
	 */
	[Event(name="myEvent",type="flash.events.Event")]
 
	/**
	 * java doc
	 */
	public class /*f*/Blat extends Bing implements Febraz, Goo {
 
		private var data:String;
		private var data:* = womble();
 
		/** asdoc for property */
		public function get property():String{return null;}
		/** @private */
		public function set property(value:String):void{}
 
		public function Blat() {
			super();
			return;
		}
 
		[Annotate]
		[Basic()]
		/**
		 * Meta doccomment.
		 */
		[String("foo")]
		[Num(1)]
		[Bool(false)]
		[Arg(foo="bar")]
		[List(foo="bar", that=2)]
		[Event("alpha")]
		[Event("beta")]
		private var x:String = 1;
		/** javadoc? */
		public static function func(arg:Number, foo=null, ...rest):Boolean {
			default xml namespace = "http://example.com/";
			for (var b=1;b<=10;b++) { bar(); }
			for (;;) { break; }
			for (var g in blah) { r(); }
			for each (var g in blah) { r(); }
			if (h==undefined) { throw new Error(); } else { /* bar */ }
			if (a) b();
			while (false) v();
			do { continue; } while (m);
			switch (blah) {
				case 3: x(); y();
				case 4: next;
				default: x(); y();
			}
			try {
				with (scope) foo();
			} catch (e) {
				var a=b?(x+y):new Foo();
			} catch (f:Error) {
				const X=new Thing();
			}
			try {
				foo();
			} finally {
				ff = function(y, z) { };
			}
			l=[1,'2'];
			xx = doc.ns::name;
			m={a:null};
// TODO:			hex = 0x3;
			d = <foo bar="{blat}"/>;
			d = <foo>
					<bar/>
				</foo>;
			r = /regexp/;
			a = b.(@c);
			zz = a..b;
			zzz = a..@*;
			zzzz = a..@["foo"+b];
			/* unary expressions */
			--a; ++a; a--; a++; a = -a;
			return a.call(i.j*k, l[m]);
		}
	}
} // trailing comment
/**
 * internal class.
 */
class InternalClass {
	private var foo:int = {};
	public function InternalClass()
	{
	}
}
// trailing comment
 
/**
 * internal function.
 */
function myFunc(arg:int=0):Vector.<int> {
	return null;
}
Categories: announcements Tags:

Git, Swiz :: what a new experience

August 2nd, 2010 Michael Schmalle No comments

The last 2-3 months have been full of new development for me, thus no blog posts in about 2 months (I’ve also been around a lot of new construction at my house). On the new construction tip, Swiz needs more exposure. I have spent the last two months putting together projects for this “micro framework” and something else that really has been in the works for me since 2006(more on that later, blog post).

So how does GIT fall into this category? Well as most of you know, more and more projects are switching to github.com rather than google.com for their source code control. The past 6 months I remained naive since I was putting together component products. Now that I have been working open source projects again I decided to see what GIT was about. Being a hardcore SVN user since 2004, this was no easy task. It’s not the learning, it’s the re-learning of style. GIT has a different way of thinking.

Bottom line, if you havn’t looked at git source code control, you should. Just for the fact you can commit changes locally to your hearts content and then push those changes to a server whenever you want is huge. Branching is so much easier since it takes place locally as well.

All of these benefits together add up to a leaner and meaner way to sling the source code.

Mike

Categories: Uncategorized Tags: