Update your app VERSION using ant

This is just a quick tip in case someone needs it. Maybe when you compile your flash application or your swc library you want to automatically update the “VERSION” number too without do it manually every time.

This is the way I do. In the “compile” task I’ve added a depends link to this ant task:
<target name="update-version">
<propertyset id="tdate"></propertyset>
<tstamp>
<format property="tdate" pattern="yyyyMMdd"/>
</tstamp>
<buildnumber file="build.number"/>
<echo>updating version to current datetime: ${tdate}</echo>
<replaceregexp byline="true">
<regexp pattern="public static const BUILD_DATE: String = \'([0-9]+)'"/>
<substitution expression="public static const BUILD_DATE: String = '${tdate}'"/>
<fileset dir="src/it/sephiroth/somestuff">
<include name="Library.as"/>
</fileset>
</replaceregexp>
<replaceregexp byline="true">
<regexp pattern="public static const BUILD_NUMBER: String = \'([0-9\.]+)'"/>
<substitution expression="public static const BUILD_NUMBER: String = '${build.number}'"/>
<fileset dir="src/it/sephiroth/somestuff">
<include name="Library.as"/>
</fileset>
</replaceregexp>
</target>
The 2 optional tasks I’ve used are: BuildNumber task and ReplaceRegExp Task. In this way every time I do an ant compile, it will update my build number and modification date.
What this task does is find this 2 lines in my Library.as file:

public static const BUILD_DATE: String = ‘20100131’;

and

public static const BUILD_NUMBER: String = ‘5’;

then replace the BUILD_DATE const with the current date and the BUILD_NUMBER with an incremental build number. After being executed the first time, ant will also create a new file in your directory called “build.number” with the latest build number int.

AsYacc – first alpha release

Before going further with discussing how to add runtime scripting support to a Flash applications, I’d like to share with you the source code of a porting of Yacc I did a while ago. I did some simple modification to make Yacc able to generate ActionScript 3.0 source code instead of C. It works quite well and supports a lot standard Yacc features. There might be some issues – report them to me and I’ll try to fix them 🙂

You can easilly find documentation about Yacc searching Google (you can start here for example).

Usually Yacc is used in conjunction with a Scanner generator (like Lex/Flex), but I didn’t to any porting of commonly used Scanner generators yet.

Here you can download the sources. The source code should be portable and compilable on all the most common platform, but I didn’t tested it on Windows yet. To compile the source code on Mac or Linux, cd to the source code directory and type use:

gcc *.c -o AsYacc

Once you have the compiled binary file, you can run the Parser generator using:

./AsYacc -Hpackage=it.sephiroth.test grammar.y

Where grammar.y is a text file that contains the grammar of a language defined using the proper syntax (see the docs online for all the detailed information you may need).

Here you can download a simple calculator example that uses the RegexLexer described previously to implement the Scanner. For the ones who might be interested, here is the grammar used:
/* Infix notation calculator. */
%{
%}
%token NUM
%left '-' '+'
%left '*' '/'
%left NEG
%right '^' /* exponentiation */
%%
input:
exp { trace( $1 ); }
;
exp:
NUM { $$ = $1; }
| exp '+' exp { $$ = $1 + $3; }
| exp '-' exp { $$ = $1 - $3; }
| exp '*' exp { $$ = $1 * $3; }
| exp '/' exp { $$ = $1 / $3; }
| '-' exp %prec NEG { $$ = -$2; }
| exp '^' exp { $$ = Math.pow( $1, $3 ); }
| '(' exp ')' { $$ = $2; }
;
%%

Scripting Flash apps: scanning the input file

Here we go. I know that probably I should have started this new topic talking about the grammar of the language we are going to implement, but as long as I see grammar strictly related to parsing, I’ve preferred to talk about scanning first.

We will go back to the grammar the next time, when talking about how to parse an input file.

I wrote about scanning (or lexing if you prefer) a while ago, when blogging about expression evalution in ActionScript. Scanning an input file is quite always the same (although some languages might require unusual features), and what I wrote about expressions works also for a general language.

The goal of the scanning process is to group some characters together, skipping the ones that have no meaning for the language like spaces. Each group of characters is usually called token. So a Scanner converts a textual input into a stream of tokens, each one rappresenting a possible valid word for our language. While scanning you don’t take care about the meaning of what you are grouping or about the fact that a sequence of tokens is meaningful. This is a task for the Parser as we will see.

When talking about expressions, I showed a manual implementation for a Lexer. Now I want to take a different approach and show you a possible implementation for a simple dynamic scanner. This scanner will be based on regular expressions: each regular expression will rappresent a given token, and we will be able to assign callbacks to the scanner that will be executed each time a given token is extracted from the input.
Writing a general and reusable scanner is usually a good practice. A common approach is to use some scanner generators, that are usually regular expression based too but are able to generate the code for a scanner at compile time. Our approach is different (and generates slower scanners) because regular expressions are evaluated at runtime; but it is fine for a test project.

You can download the source code for the regular expression based lexer (RegexLexer) here, as long as a simple usage example. Let’s see this example together so we can briefly discuss it (PBLexer.as):

Continue reading

SEPY 1.5.1

Due to various changes in latest version of SEPY, there was a major subversion change from 1.0.x to 1.5.x
Those are:

  • New left Panel rendering. The multline notebook has been replaced by a vertial custom notebook
  • Regular Expression Kit. Panel which allows you to test match/search regular expressions and create the ActionScript 3.0 code for using them.
  • Enhancement of the TODO Panel.
    Now you can define, using this panel, different words you want to be marked both in the right border panel and listed in the todo panel itself.
  • Import Classes panel. Search/Select which class to import in your document and manage a list of favourites classes.
  • Speed up improvement in the code autocompletion
  • Added “Match multiline mode” in Find&Replace in files

P.S. Installer is available for both Win32 and OSX (compiled on 10.4).
http://sourceforge.net/project/…id=114139&release_id=373747

SEPY 1.0.6.49, new feature

Here comes a new SEPY release with a major change in the interface: the Find dialog In particulary:

  1. multiline text dialog
  2. search can be now made not only in all the document text, but a filter can be used:
    • search only in comments
    • search only in strings
  3. open/save search status. This will save all the options and text currently in the dialog window (useful when using long regular expressions which we want to remember in future)
  4. Word Start: find text only if the character before is not a word char.

Added a guide for the find operations (with also a guide to the regular expression syntax which you can use in scintilla) I hope these changes are welcome, and expecially they works..

http://sourceforge.net/projects/sepy/

Make your suggestion for the next Flash!

Hi, this message is for all Flash Users.
We’re collecting feedbacks and improvements, to turn subsequently to
Macromedia Flash Team, in order to obtain a wished list from who like you
use the program.
This operation has the sole scope to improve the development flash
enviroment and to adapt the software more to the requirements of the
customers.
You can propose new functionalities and improvements on those already
existing, trying to concentrate on aspects not too much general but on
detailed features lists that in your opinion lack or that you found
low-efficient for your daily job.

All messages should be sent to: flashwishlist@riadev.com

For example, some my suggestions:
– Improvements with XPath functionallity
– Regular expression implementation
– Make components smaller!
– Make a REAL try/catch implementation, expecially for runtime env