Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package {
- import flash.events.*;
- import flash.display.*;
- public class Test extends MovieClip
- {
- var filecontents;
- var tokens = [];
- var Data;
- var toks;
- var parse;
- var State
- public function Test()
- {
- init();
- }
- function init():void
- {
- compileCode_Btn.addEventListener(MouseEvent.MOUSE_DOWN, compiler);
- }
- function compiler(e:MouseEvent):void
- {
- var tok = "";
- State = 0;
- var string = "";
- Data = String(code_Area.text);
- var filecontents:Array = Data.split("");
- for (var i:Number = 0; i < filecontents.length; i++)
- {
- var char = filecontents[i];
- //trace(State);
- tok += char;
- trace(tok);
- if (tok == "\r")
- {
- trace("new line found");
- tok = "";
- }
- else if(tok == "print")
- {
- //trace("Found a print");
- tokens.push("Print");
- tok = "";
- }
- else if(tok == '"')
- {
- if(State == 0){
- State = 1;
- tok = "";
- }
- else if(State == 1)
- {
- //trace("Found string: " + string);
- tokens.push("String:" + string);
- tok = ""
- string = "";
- State = 0;
- //trace(tokens);
- }
- }
- else if(State == 1)
- {
- string += tok;
- tok = ""
- }
- else if(tok == " ")
- {
- if(State == 0)
- {
- tok = "";
- }
- else
- tok = " ";
- }
- trace(tokens);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement