Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.vscode
lib
docs/javadoc/
lib/
src/c/libwaxeye.a
Expand Down
4 changes: 4 additions & 0 deletions src/haxe/build.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-cp src
-main org.waxeye.Main
-neko neko/Main.n
-cmd neko neko/Main
43 changes: 43 additions & 0 deletions src/haxe/org/waxeye/parser/AST.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package org.waxeye.parser;

/**
* Waxeye Parser Generator
* www.waxeye.org
* Copyright (C) 2008-2010 Orlando Hill
* Copyright (c) 2015 Joshua Gross
* @author Damilare Akinlaja, 2017
* Licensed under the MIT license. See 'LICENSE' for details.
*
* An abstract syntax tree has one of three forms.
* AST_EMPTY represents a successful parse from a voided non-terminal.
* 'x' just holds a character.
* AST_TREE represents a successful parse from a non-terminal. It holds:
* - the non-terminal's name
* - a list of child asts
*
*/
class AST
{

public var form:String;
public var type:Any;
public var children:Array<Any>;

public function new(form:String, ?type:Any, ?children:Any)
{
this.form = form;
this.type = type;
this.children = children;
}

public static function EMPTY():AST
{
return new AST("EMPTY");
}

public static function TREE(str:Any, asts:Any):AST
{
return new AST("TREE", str, asts);
}

}
82 changes: 82 additions & 0 deletions src/haxe/org/waxeye/parser/Continuations.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package org.waxeye.parser;
import org.waxeye.parser.Modes.Modes;
import org.waxeye.parser.Util.Assert;
/*
* Waxeye Parser Generator
* www.waxeye.org
* Copyright (C) 2008-2010 Orlando Hill
* Copyright (c) 2015 Joshua Gross
* @author Damilare Akinlaja, 2017
* Licensed under the MIT license. See 'LICENSE' for details.
*/
class Continuations
{
public var type:String;
public var pos:Int;
public var expressions:Array<Exp>;
public var expression:Exp;
public var asts:Array<AST>;
public var err:Any;
public var mode:Modes;
public var name:String;
public var nt:Dynamic;

public function new(type:String, pos:Int, expressions:Array<Exp>, expression:Exp, asts:Array<AST>, err:Any, mode:Modes, name:String, nt:Dynamic)
{
this.type = type;
this.pos = pos;
this.expressions = expressions;
this.expression = expression;
this.asts = asts;
this.err = err;
this.mode = mode;
this.name = name;
this.nt = nt;
}

public static function CONT_SEQ(expressions:Array<Exp>):Continuations
{
return new Continuations("CONT_SEQ", 0, expressions, null, null, null, null, null, null);
}

public static function CONT_ALT(expressions: Array<Exp>, pos:Int, asts:Array<AST>):Continuations
{
return new Continuations("CONT_ALT", pos, expressions, null, asts, null, null, null, null);
}

public static function CONT_AND(pos:Int, asts:Array<AST>, err:Any):Continuations
{
return new Continuations("CONT_AND", pos, null, null, asts, err, null, null, null);
}

public static function CONT_NOT( pos:Int, asts:Array<AST>, err:Any):Continuations
{
return new Continuations("CONT_NOT", pos, null, null, asts, err, null, null, null);
}

public static function CONT_OPT(pos:Int, asts:Array<AST>):Continuations
{
return new Continuations("CONT_OPT", pos, null, null, asts, null, null, null, null);
}

public static function CONT_STAR(exp: Dynamic, pos:Int, asts:Array<AST>):Continuations
{
return new Continuations("CONT_STAR", pos, null, exp, asts, null, null, null, null);
}

public static function CONT_PLUS(exp: Dynamic):Continuations
{
return new Continuations("CONT_PLUS", 0, null, exp, null, null, null, null, null);
}

public static function CONT_VOID(asts:Array<AST>):Continuations
{
return new Continuations("CONT_VOID", 0, null, null, asts, null, null, null, null);
}

public static function CONT_NT(mode:Modes, name:String, asts:Array<AST>, nt:Dynamic):Continuations
{
return new Continuations("CONT_NT", 0, null, null, asts, null, mode, name, nt);
}

}
18 changes: 18 additions & 0 deletions src/haxe/org/waxeye/parser/ErrAny.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.waxeye.parser;
/*
* Waxeye Parser Generator
* www.waxeye.org
* Copyright (C) 2008-2010 Orlando Hill
* Copyright (c) 2015 Joshua Gross
* @author Damilare Akinlaja, 2017
* Licensed under the MIT license. See 'LICENSE' for details.
*/
class ErrAny
{

public function new()
{

}

}
20 changes: 20 additions & 0 deletions src/haxe/org/waxeye/parser/ErrCC.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.waxeye.parser;

/*
* Waxeye Parser Generator
* www.waxeye.org
* Copyright (C) 2008-2010 Orlando Hill
* Copyright (c) 2015 Joshua Gross
* @author Damilare Akinlaja, 2017
* Licensed under the MIT license. See 'LICENSE' for details.
*/
class ErrCC
{
public var charClasses:Dynamic;

public function new(charClasses:Dynamic)
{
this.charClasses = charClasses;
}

}
22 changes: 22 additions & 0 deletions src/haxe/org/waxeye/parser/ErrChar.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.waxeye.parser;

/*
* Waxeye Parser Generator
* www.waxeye.org
* Copyright (C) 2008-2010 Orlando Hill
* Copyright (c) 2015 Joshua Gross
* @author Damilare Akinlaja, 2017
* Licensed under the MIT license. See 'LICENSE' for details.
*/
class ErrChar
{
public var char:Dynamic;

public function new(char:Dynamic)
{
this.char = char;
}



}
100 changes: 100 additions & 0 deletions src/haxe/org/waxeye/parser/Exp.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
package org.waxeye.parser;

/*
* Waxeye Parser Generator
* www.waxeye.org
* Copyright (C) 2008-2010 Orlando Hill
* Copyright (c) 2015 Joshua Gross
* @author Damilare Akinlaja, 2017
* Licensed under the MIT license. See 'LICENSE' for details.
*/

@:enum
abstract ExpType(String){
var ANY = "ANY";
var NT = "NT";
var VOID = "VOID";
var CHAR = "CHAR";
var CHAR_CLASS = "CHAR_CLASS";
var AND = "AND";
var NOT = "NOT";
var OPT = "OPT";
var ALT = "ALT";
var SEQ = "SEQ";
var STAR = "STAR";
var PLUS = "PLUS";
}

class Exp
{
public var type:ExpType;
public var args:Array<Dynamic>;

public function new(type:ExpType, args:Array<Dynamic>)
{
this.args = args;
this.type = type;
}


public static function ANY(args:Array<Any>):Exp
{
return new Exp(ExpType.ANY, args);
}

public static function NT(args:Array<Any>):Exp
{
return new Exp(ExpType.NT, args);
}

public static function VOID(args:Array<Any>):Exp
{
return new Exp(ExpType.VOID, args);
}

public static function CHAR(args:Array<Any>):Exp
{
return new Exp(ExpType.CHAR, args);
}

public static function CHAR_CLASS(args:Array<Any>):Exp
{
return new Exp(ExpType.CHAR_CLASS, args);
}

public static function AND(args:Array<Any>):Exp
{
return new Exp(ExpType.AND, args);
}

public static function NOT(args:Array<Any>):Exp
{
return new Exp(ExpType.NOT, args);
}

public static function OPT(args:Array<Any>):Exp
{
return new Exp(ExpType.OPT, args);
}

public static function ALT(args:Array<Any>):Exp
{
return new Exp(ExpType.ALT, args);
}

public static function SEQ(args:Array<Any>):Exp
{
return new Exp(ExpType.SEQ, args);
}

public static function STAR(args:Array<Any>):Exp
{
return new Exp(ExpType.STAR, args);
}

public static function PLUS(args:Array<Any>):Exp
{
return new Exp(ExpType.PLUS, args);
}

}
44 changes: 44 additions & 0 deletions src/haxe/org/waxeye/parser/MachineConfiguration.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package org.waxeye.parser;
import org.waxeye.parser.Util.Assert;

/*
* Waxeye Parser Generator
* www.waxeye.org
* Copyright (C) 2008-2010 Orlando Hill
* Copyright (c) 2015 Joshua Gross
* @author Damilare Akinlaja, 2017
* Licensed under the MIT license. See 'LICENSE' for details.
*/
class MachineConfiguration
{
public var type:String;
public var exp:Exp;
public var pos:Int;
public var asts:Array<AST>;
public var err:Dynamic;
public var continuations:Array<Continuations>;
public var value:Value;

public function new(type:String, exp:Exp, pos:Int, asts:Array<AST>, err:Dynamic, continuations:Array<Continuations>, value:Value)
{
this.type = type;
this.exp = exp;
this.pos = pos;
this.asts = asts;
this.err = err;
this.continuations = continuations;
this.value = value;
}


public static function EVAL(exp:Exp, pos:Int, asts:Array<AST>, err:Dynamic, continuations:Array<Continuations>):MachineConfiguration
{
return new MachineConfiguration("EVAL", exp, pos, asts, err, continuations, null);
}


public static function APPLY(continuations:Array<Continuations>, value:Value):MachineConfiguration
{
return new MachineConfiguration("APPLY", null, 0, null, null, continuations, value);
}
}
36 changes: 36 additions & 0 deletions src/haxe/org/waxeye/parser/MachineState.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.waxeye.parser;
import haxe.DynamicAccess;

/*
* Waxeye Parser Generator
* www.waxeye.org
* Copyright (C) 2008-2010 Orlando Hill
* Copyright (c) 2015 Joshua Gross
* @author Damilare Akinlaja, 2017
* Licensed under the MIT license. See 'LICENSE' for details.
*/
class MachineState
{
public var type:String;
public var result:Dynamic;
public var configuration:MachineConfiguration;

public function new(type:String = "", result:Dynamic, configuration:MachineConfiguration)
{

this.type = type;
this.result = result;
this.configuration = configuration;
}

public static function FINAL(result:Dynamic):MachineState
{
return new MachineState("FINAL", result, null);
}

public static function INTER(configuration:MachineConfiguration):MachineState
{
return new MachineState("INTER", null, configuration);
}

}
Loading