as3parser :: Expression building, sneak peak

August 25th, 2010 Michael Schmalle No comments

Hi,

I have been working the last 2 days completely refactoring, actually rewriting the AS3Parser, all 2500 lines.

The old parser implementation used recursive decent but it had no idea about token stream. I have re-written the parser to use a LinkedListToken token implementation with next and previous, start and stop tokens.

This is all possible since the metaas Java DOM was so awesome, thanks David, I learned a lot! Well, I am using his DOM api to about 80%, it’s really intuitive and tight, check the example below.

Yes, we are at the lowest level, every aspect of actionscript3 will be able to be created now. Not to mention code formatters can be easily written in an AIR application.

The below three tests are just some eye candy right now, this dev is on the as3block branch, I havn’t committed this yet

[Test]
public function testAssignmentExpressionNode():void
{
	var left:IExpressionNode = factory.newExpression("myAnswer");
	var right:IExpressionNode = factory.newExpression("4");
 
	var expression:IAssignmentExpressionNode = 
		factory.newAssignmentExpression(left, right);
 
	assertPrintExpression("myAnswer = 4", expression);
 
	// change right expression
	expression.rightExpression = factory.newExpression("otherAnswer = 4");
 
	assertPrintExpression("myAnswer = otherAnswer = 4", expression);
 
	// change left expression to an array access
	var target:IExpressionNode = factory.newExpression("myObject[42]");
	var subscript:IExpressionNode = factory.newExpression("2");
 
	var arrayAccessExpression:IArrayAccessExpressionNode = 
		factory.newArrayAccessExpression(target, subscript);
 
	expression.leftExpression = arrayAccessExpression;
 
	assertPrintExpression("myObject[42][2] = otherAnswer = 4", expression);
}
 
[Test]
public function testArrayLiteralNode():void
{
	var expression:IArrayLiteralNode = factory.newArrayLiteral();
 
	expression.add(factory.newSimpleNameExpressionNode("a"));
	expression.add(factory.newSimpleNameExpressionNode("b"));
	expression.add(factory.newSimpleNameExpressionNode("c"));
 
	assertPrintExpression("[a, b, c]", expression);
 
	expression.remove(2);
 
	var expression2:IArrayLiteralNode = factory.newArrayLiteral();
 
	expression2.add(factory.newNullLiteral());
	expression2.add(factory.newSimpleNameExpressionNode("foo"));
	expression2.add(factory.newStringLiteral("Hello World"));
	expression2.add(factory.newBooleanLiteral(true));
 
	expression.add(factory.newArrayAccessExpression(
		factory.newSimpleNameExpressionNode("abc"),
		factory.newNumberLiteral(0)));
 
	expression.add(expression2);
 
	assertPrintExpression("[a, b, abc[0], [null, foo, \"Hello World\", true]]", expression);
}
 
[Test]
public function testArrayAccessExpressionNode():void
{
	var target:IExpressionNode = factory.newExpression("myObject[42]");
	var subscript:IExpressionNode = factory.newExpression("0");
 
	var expression:IArrayAccessExpressionNode = 
		factory.newArrayAccessExpression(target, subscript);
 
	assertPrintExpression("myObject[42][0]", expression);
 
	// test changing the 'target'
	target = factory.newExpression("myObject");
	expression.target = target;
 
	assertPrintExpression("myObject[0]", expression);
 
	// test changing the 'subscript'
	subscript = factory.newExpression("42");
	expression.subscript = subscript;
 
	assertPrintExpression("myObject[42]", expression);
 
	// test changing the 'subscript' to a string literal
	subscript = factory.newExpression("'myProp'");
	// or you could use
	// subscript = factory.newStringLiteral("'myProp'");
	expression.subscript = subscript;
 
	assertPrintExpression("myObject['myProp']", expression);
}

Mike

as3parser-framework :: Download first alpha SWC – parse and build!

August 23rd, 2010 Michael Schmalle No comments

Hi,

I just put together the first alpha swcs for use. You can get this zip here;

as3parser-framework_0.1_alpha.zip

The zip file contains 2 SWC libraries;

  • as3parser-framework_0.1_alpha.swc
  • as3builder-framework_0.1_alpha.swc

This is very alpha, but now you can experiment without the source. These are right out of the Library project so they contain the unit tests as well. This won’t be the case in the future.

Have fun,
Mike

as3parser-framework :: Introducing the AS3FragmentParser

August 23rd, 2010 Michael Schmalle 1 comment

Hi,

Well the I figured the framework needed a static API to access the AS3Parsers internal parse methods. I finally got around to making this and unit testing it to the point of insanity. This was for a special purpose though, the TestAS3FragmentParser unit test is more like a guide on what you can pass each method. If you haven’t checked out that unit test, you should.

Wiki Docs;

The below link shows usage and XML AST information for every method listed below, you should check it out if your interested in the AST models.

AS3FragmentParser API

Source for the unit test;

AS3FragmentParser Unit test

Parse methods;

  • parseCompilationUnit()
  • parsePackage()
  • parsePackageContent()
  • parseClassContent()
  • parseInterfaceContent()
  • parseMetaData()
  • parseConstants()
  • parseVariables()
  • parseMethods()
  • parseStatement()
  • parsePrimaryExpression()
  • parseExpression()

An example of what you will find on the wiki page.

parseCompilationUnit()

Usage:

var ast:IParserNode = AS3FragmentParser.parseCompilationUnit(source);
// convoluted example but shows nesting
trace(ast.getChild(0).getChild(0).stringValue); // my.domain
trace(ast.getChild(0).getLastChild().getChild(0).getChild(0).stringValue); // Test
trace(ast.getChild(0).getLastChild().getChild(0).getKind("mod").stringValue); // public

Source:

package my.domain
{
	public class Test
	{
	}
}
class InternalClass
{
}

AST:

<compilation-unit>
	<package>
		<name>my.domain</name>
		<content>
			<class>
				<name>Test</name>
				<mod-list>
					<mod>public</mod>
				</mod-list>
				<content></content>
			</class>
		</content>
	</package>
	<content>
		<class>
			<name>InternalClass</name>
			<content></content>
		</class>
	</content>
</compilation-unit>

Why ?

This class was written because I’m getting into the BLOCK building, yes, you will be able to create expressions!

Mike

as3parser-framework :: support wiki online – framework vision

August 20th, 2010 Michael Schmalle No comments

Hi,

This post will run through how this project is currently setup, it’s goals and what I won’t subscribe to.

The wiki

For years I have used Dokuwiki and love it, this is what my support will be written with. It’s a sub domain on my site and thus remains close to me. Ever heard of the underground scene in techno music? This is how this project will be done, no fancy sky scrappers and white walls, just a purely enthusiastic developer that is offering some tools for his fellow developers. If the bomb tracks leak to the mainstream, then I achieved my purpose in the dark underground. :)

I live in New Hampshire for the simple reason of simplicity. Keeping your mind and focus clear has allowed me to create what you are looking at.

as3parser-framework wiki

Bugs and features

I have not decided on this, does anybody have any suggestions for an open-source project like this (that’s free)?

Support Forum

Google Groups seem to work well, so that is where I will answer questions directed at me.

as3parser-framework Group

Git Hub source code:

A note to SVN users; I was once an SVN man, didn’t think anything could be better. That was until I decided to put aside my stubbornness and try GIT on Windows. Man, I can’t go back to SVN now. If there are any SVN users that have no clue about GIT and want to check this out with their favorite SVN GUI client, let me know and I will write a blog post on how to do it.

Framework Vision

  • This will not be judged as a performance parser (AS3 IDE fine and well, my intention was to empower AIR developers).
  • There will be a very intriguing Swiz application built that will view, inspect and edit Swiz application code.
  • There will be an ASDoc AIR application built with plug-in features so any grandmother that codes actionscript3 will be able to add her apple pies to your documentation.
  • There might actually be a donation button to PayPal that could really get my motor running.

PHP

I love PHP and how it links to Flex/Flash applications. I am seriously kicking around the idea of creating a simple parser and AST for PHP like I have done with ActionScript3.

The future

I love developing Flex components, take a look at my products, may buy one. :) The code quality is second to none, help support this developer’s children! ;-)

Teoti Graphix, LLC Products

Until next time,
Mike

as3parser-framework :: lazy as3 code creation

August 19th, 2010 Michael Schmalle No comments

Hi,

I just thought I would run this past all the people that got scared at the last post knowing you can now create actionscript3 code with actionscript3 code. :)

Now you can create actionscript3 code with a String of actionscript3 code, then print out the actionscript3 code again.

Lets see, how many times did I say actionscript3, 6, OK that’s good.

Git Hub source code:

Input:

var code:String =
	"package my.domain {" +
	"public class UnitTest {" +
	"protected const MY_CONSTANT:int = 42;" +
	"[Test]public function testMethod1():void{}" +
	"[Test]public function testMethod2():void{}" +
	"[Test]public function testMethod3():void{}" +
	"}}"
 
var file:AS3SourceFile = new AS3SourceFile(null, new SourceCode(code, "", ""));
file.buildAst();
var typeNode:ITypeNode = file.compilationNode.typeNode;
var method:IMethodNode = typeNode.getMethod("testMethod2");
method.description = "See, this editing a string with code is fun!";
method.newDocTag("author", "Yeah me");
var meta:IMetaDataNode = method.getMetaData("Test");
meta.description = "Just in case you didn't know, I unit test.";
 
typeNode.removeMethod(typeNode.getMethod("testMethod1"));
typeNode.newMetaData("TestSuite");
 
typeNode.description = "Class documentation is good also, but I am lazy!"
 
var result:String = BuilderFactory.instance.buildFile(file);

Output:

package my.domain {
    [TestSuite]
    /**
     * Class documentation is good also, but I am lazy!
     */
    public class UnitTest {
        protected const MY_CONSTANT:int = 42;
        /**
         * Just in case you didn't know, I unit test.
         */
        [Test]
        /**
         * See, this editing a string with code is fun!
         * 
         * @author Yeah me
         */
        public function testMethod2():void {
        }
        [Test]
        public function testMethod3():void {
        }
    }
}

Notice this uses the parser and builder! :)

Mike

as3parser-framework :: Code generation api rockin

August 19th, 2010 Michael Schmalle 2 comments

Hi,

Just a quick update, I have been working hard to get the builder framework to create all API, almost there. Check out what you can do now. Look at the metadata… does it spring to mind any applications that could be built with AIR that enhance framework familiarity? :)

I also created a Google Group as3parser-framework if anybody had features, bugs or questions;

Google Group as3parser-framework

Git Hub source code:

There might be a couple errors in the below code, I hit the wordpress 404 when publishing. It took me 30 minutes to fix this post, grr

Input:

// create the file
var file:ISourceFile = project.newClass("my.domain.MyClass");
var packageNode:IPackageNode = file.compilationNode.packageNode;
var typeNode:IClassTypeNode = packageNode.typeNode as IClassTypeNode;
// add a package block comment
packageNode.newBlockComment("A package block comment.", false);
// add imports
packageNode.newImport("my.api.IInterfaceA");
packageNode.newImport("my.api.IInterfaceB");
packageNode.newImport("my.domain.sub.SubTest");
packageNode.newImport("mx.core.mx_internal");
// add and include
packageNode.newInclude("../som/folder/includeFile.as");
// addd a use namepsace
packageNode.newUse("mx_internal");
// make class dynamic
typeNode.isDynamic = true;
// add a superclass
typeNode.superClass = IdentifierNode.createType("ClassA");
// add implementors
typeNode.addImplementation(IdentifierNode.createType("IInterfaceA"));
typeNode.addImplementation(IdentifierNode.createType("IInterfaceB"));
// add a [Bindable] meta to class
typeNode.newMetaData("Bindable");
// add a style
var style:IMetaDataNode = typeNode.newMetaData("Style");
style.addNamedStringParameter("name", "myStyle");
style.addNamedStringParameter("type", "Number");
style.addNamedStringParameter("inherit", "no");
// add a comment to the style
style.description = "A new style.";
style.newDocTag("see", "#style:theOtherStyle");
// add a class description
typeNode.description = "A groovy class generated by as3builder-framework!";
typeNode.newDocTag("author", "Michael Schmalle");
typeNode.newDocTag("date", "08-19-2010");
 
// add a constant
var constant:IConstantNode = typeNode.newConstant("MY_CONSTANT", Modifier.PUBLIC, 
	IdentifierNode.createType("String"), "\"value\"");
constant.description = "My constant.";
 
// add an attribute
var attribute:IAttributeNode = typeNode.newAttribute("myAttribute", Modifier.PROTECTED, 
	IdentifierNode.createType("IModel"), "null");
attribute.description = "My attribute.";
attribute.newDocTag("private");
attribute.newMetaData("Inject");
 
// add an accessor
var vo:IIdentifierNode = IdentifierNode.createType("ValueObject");
 
var getter:IAccessorNode = typeNode.newAccessor(
	"myProperty", Modifier.PUBLIC, Access.READ, vo);
 
getter.description = "A property.";
getter.newMetaData("Bindable");
var inject:IMetaDataNode = getter.newMetaData("Inject");
inject.addNamedStringParameter("source", "model.property");
 
 
// add constructor
var constructor:IMethodNode = typeNode.newMethod("MyClass", Modifier.PUBLIC, null);
constructor.description = "Constructor.";
 
// add a method
var method:IMethodNode = typeNode.newMethod(
	"myMethod", Modifier.PUBLIC, IdentifierNode.createType("void"));
method.description = "Mediates a Swiz framework [Mediate] tag.";
var param:IParameterNode = method.newParameter(
	"data", IdentifierNode.createType("Object"), "null");
method.newDocTag("param", "data A mediated data object");
var mediate:IMetaDataNode = method.newMetaData("Mediate");
mediate.addNamedStringParameter("event", "MyEvent.DATA_CHANGE");
method.addReturnDescription("Returns nothing.");
 
BuilderFactory.newlinesBeforeMembers = 1;
BuilderFactory.breakPackageBracket = true;
BuilderFactory.breakTypeBracket = true;
BuilderFactory.breakBlockBracket = true;
 
var result:String = BuilderFactory.instance.buildTest(compilationNode.node);

Output:

/**
 * A package block comment.
 */
package my.domain 
{
    import my.api.IInterfaceA;
    import my.api.IInterfaceB;
    import my.domain.sub.SubTest;
    import mx.core.mx_internal;
    include '../some/folder/includeFile.as'
    use namespace mx_internal;
    [Bindable]
    /**
     * A new style.
     * 
     * @see #style:theOtherStyle
     */
    [Style(name="myStyle",type="Number",inherit="no")]
    /**
     * A groovy class generated by as3builder-framework!
     * 
     * @author Michael Schmalle
     * @date 08-19-2010
     */
    public dynamic class MyClass extends ClassA implements IInterfaceA, IInterfaceB 
    {
 
        /**
         * My constant.
         */
        public static const MY_CONSTANT:String = "value";
 
        [Inject]
        /**
         * My attribute.
         * 
         * @private 
         */
        protected var myAttribute:IModel = null;
 
        [Bindable]
        [Inject(source="model.property")]
        /**
         * A property.
         */
        public function get myProperty():ValueObject 
        {
            return null;
        }
 
        /**
         * @private 
         */
        public function set myProperty(value:ValueObject):void 
        {
        }
 
        /**
         * Constructor.
         */
        public function MyClass() 
        {
        }
 
        [Mediate(event&#99;"MyEvent.DATA_CHANGE")]
        /**
         * Mediates a Swiz framework [Mediate] tag.
         * 
         * @param data A mediated data object
         * @return Returns nothing.
         */
        public function myMethod(data:Object &#99; null):void 
        {
        }
    }
}

Mike

as3parser-framework :: AST creation now possible (as3 code creation)

August 10th, 2010 Michael Schmalle 5 comments

Hi,

Well I have been hard at work getting this framework going to the point where I could show an example of AST creation; AKA ActionScript3 code creation in an ActionScript3 class/application. :)

I designed this framework to be used with applications that enhance the development of ActionScript. Mainly targeting AIR applications but, since I have made sure to put zero dependencies on AIR libraries in the core framework, browser application can also make use of the parser AST.

Since last week I have divided this project into 2 repositories;

as3parser-framework

This framework is the core parsers and AST goodies. Any as3 SWF (Flash, Flex, etc.) application can utilize this library.

as3builder-framework

This framework is dependent on AIR libraries for now. I might shave the builder classes back into the parser library sooner than later so there is no requirement on AIR when wanting to create what is displayed below.

So, if you want to create code you need to checkout both repositories and put them in your source paths.

This library also houses to as3book package that contains the processor and accessor for an as3 book. This is the API where after a full project parse you can find subclasses, superclasses, inherting members, superinterfaces etc.

AST Code creation

NOTE: This is very alpha, so all creation implementation is not set, but I am well on the way of getting major parts done soon.

With the following code, it is possible to create the following source code;

// where the project will be output
var output:File = File.desktopDirectory.resolvePath("project/src");
 
// create a factory that will create AST
var factory:AS3Factory = new AS3Factory();
// create a new project to hold .as files
var project:IAS3Project = factory.newASProject(output.nativePath);
 
// create a public class with package 'com.acme.core'
var file:ISourceFile = project.newClass("com.acme.core.HelloWorld");
var typeNode:IClassTypeNode = file.compilationNode.typeNode as IClassTypeNode;
// mark he class final (can do the same for IsDynamic)
typeNode.isFinal = true;
//add metadata to the class
var event:IMetaDataNode = typeNode.newMetaData("Event");
event.addNamedStringParameter("name", "myEvent");
event.addNamedStringParameter("type", "flash.events.Event");
 
var style:IMetaDataNode = typeNode.newMetaData("Style");
style.addNamedStringParameter("name", "myStyle");
style.addNamedStringParameter("type", "Number");
style.addNamedStringParameter("inherit", "no");
 
var bindable:IMetaDataNode = typeNode.newMetaData("Bindable");
 
// add class comment
typeNode.description = "A class comment.\n " +
	"<p>Long description documentation.</p>";
 
typeNode.addDocTag("author", "Michael Schmalle");
typeNode.addDocTag("copyright", "Teoti Graphix, LLC");
typeNode.addDocTag("productversion", "1.0");
typeNode.addDocTag("see", "MyOtherClass More details here.");
 
// add a method
var method:IMethodNode = typeNode.newMethod(
	"helloTest", Modifier.PUBLIC, IdentifierNode.createType("String"));
// add a parameter
var param:IParameterNode = method.addParameter(
	"arg0", IdentifierNode.createType("String"), "''");
// add a comment to the method
method.description = "A hello test method.\n <p>Long description.</p>";
method.addDocTag("since", "1.0");
// add a description to the parameter
param.description = "The String argument at 0";
// add a return tag to the method
method.addReturnDescription("A String indicating the result.");
 
// add a method with rest
// add a method
var methodRest:IMethodNode = typeNode.newMethod(
	"helloRestTest", Modifier.create("mx_internal"), 
	IdentifierNode.createType("my.domain.ITest"));
 
// add a parameter
var arg0:IParameterNode = methodRest.addParameter(
	"arg0", IdentifierNode.createType("int"));
var rest:IParameterNode = methodRest.addRestParameter("theRest");
 
var result:String = BuilderFactory.instance.buildFile(file);
 
trace(result);

converts to;

package com.acme.core {
    [Event(name="myEvent",type="flash.events.Event")]
    [Style(name="myStyle",type="Number",inherit="no")]
    [Bindable]
    /**
     * A class comment.
     * 
     * <p>Long description documentation.</p> 
     * 
     * @author Michael Schmalle
     * @copyright Teoti Graphix, LLC
     * @productversion 1.0
     * @see MyOtherClass More details here.
     */
    public final class HelloWorld {
        /**
         * A hello test method.
         * 
         * <p>Long description.</p> 
         * 
         * @since 1.0
         * @param arg0 The String argument at 0
         * @return A String indicating the result.
         */
        public function helloTest(arg0:String = ''):String {
        }
        mx_internal function helloRestTest(arg0:int, ...theRest):ITest {
        }
    }
}

That’s all for now,
Mike

Please feel free to contact me if you are at all interested in this project or contributing!

mschmalle at teotigraphix.com

as3parser-framework :: IAS3Book API access examples

August 3rd, 2010 Michael Schmalle No comments

Hello,

Well much progress on this end. The IAS3Book API is getting implemented. Using the as3book branch of the source code the following is code possible.

The class and interface member access is next on the list (it’s already written in java, just porting it over) :) .

Note: There is no SWC for this framework yet as it is in alpha and much API is going to be added before I am finished. As some have wondered, there is going to be a write API into the AST to create .as, .mxml and asdoc comments from actionscript code.

More to come later.

public function loadBook():void
{
	var book:IAS3Book = BookFactory.instance.createBook();
 
	var mySourcePath:String = "C:\\dev\\workspace\\opensource\\as3parser-framework\\src";
	// create a source directory
	var srcDir:File = new File(mySourcePath);
 
	var sources:Array = [];
	// get all File instances in source path recursivly
	var files:Array = readFiles(srcDir);
	for each (var file:File in files)
	{
		var sourceFile:ISourceFile = 
			NodeFactory.instance.createSourceFile(
				FileUtil.readFile(file.nativePath),
				file.nativePath,
				mySourcePath);
		try
		{
			// build the source file's AST
			sourceFile.buildAst();
 
			// add the source file to the book
			book.addSourceFile(sourceFile);
		}
		catch (e:Error)
		{
			trace(e.message);
			trace("Error parsing " + sourceFile.fileName);
		}
	}
 
	// proccess all SourceFile trees
	book.process();
 
	// now you have access to all the book's accessor API
 
	// Vector.<IClassTypeNode>
	book.access.classTypes;
	// Vector.<IFunctionTypeNode>
	book.access.functionTypes;
	// Vector.<IInterfaceTypeNode>
	book.access.interfaceTypes;
	// Vector.<ISourceFileCollection>
	book.access.sourceFileCollections;
	// Vector.<ITypeNode> of class|interface|function
	book.access.types;
 
	// returns the IClassTypeNode or null
	book.access.findClassType("my.domain.Class");
	// returns the IFunctionTypeNode or null
	book.access.findFunctionType("my.domain.globalFunction");
	// returns the IInterfaceTypeNode or null
	book.access.findInterfaceType("my.domain.IInterface");
	// returns the ITypeNode or null
	book.access.findType("my.domain.Class");
	// Vector.<ITypeNode>
	book.access.getImplementedInterfaces(classAType);
	// Vector.<ITypeNode>
	book.access.getInterfaceImplementors(classAType);
	// Vector.<ISourceFileCollection>
	book.access.getSourceFileCollection("my.domain");
	// Vector.<ITypeNode>
	book.access.getSubClasses(classAType);
	// Vector.<ITypeNode>
	book.access.getSubInterfaces(iInterfaceAType);
	// Vector.<ITypeNode>
	book.access.getSuperClasses(classAType);
	// Vector.<ITypeNode>
	book.access.getSuperInterfaces(iInterfaceAType);
	// returns ITypeNode
	book.access.getType("my.domain.Class");
	// Vector.<ITypeNode> all types in package
	book.access.getTypes("my.domain");
	// Boolean
	book.access.hasType("my.domain.Class");
}
 
protected function readFiles(directory:File, result:Array = null):Array
{
	if (result == null)
		result = [];
 
	var directories:Array = directory.getDirectoryListing();
	for each (var file:File in directories)
	{
		if (file.isDirectory)
		{
			result = readFiles(file, result);
		}
		else if (file.extension == "as" || file.extension == "mxml")
		{
			result.push(file);
		}
	}
 
	return result;
}

Mike

Announcing the as3parser-framework opensource project

August 2nd, 2010 Michael Schmalle 8 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;
}

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: git Tags: