Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Now all callbacks work, it builds, and printexceptions works as well

  • Loading branch information...
commit 0fb1d891bd710c9a41829c43d27e71e5c59a5bde 1 parent ce6ea42
nddrylliog authored
View
1  grammar/nagaqueen.leg
@@ -143,6 +143,7 @@ void nq_onCoverEnd(void *this);
void nq_onEnumStart(void *this, char *name, char *doc);
void nq_onEnumExtern(void *this, char *externName);
+void nq_onEnumFromType(void *this, void *fromType);
void nq_onEnumIncrementExpr(void *this, char oper, void *step);
void nq_onEnumElementStart(void *this, char *name, char *doc);
void nq_onEnumElementValue(void *this, void *value);
View
21 source/nagaqueen/OocListener.ooc
@@ -1,5 +1,4 @@
-
-
+import callbacks
/**
* Override and implement to be able to react to nagaqueen's parsing events.
@@ -10,6 +9,10 @@ OocListener: abstract class {
init: func {}
+ parse: func (path: String) {
+ nq_parse(this, path)
+ }
+
/* Uses, imports, includes */
onUse: func (name: CString) {
@@ -116,6 +119,10 @@ OocListener: abstract class {
UnsupportedAstElement new(class, "enum-end") throw()
}
+ onEnumFromType: func (fromType: Object) {
+ UnsupportedAstElement new(class, "enum-fromtype") throw()
+ }
+
onEnumExtern: func (externName: CString) {
UnsupportedAstElement new(class, "enum-extern") throw()
@@ -191,6 +198,10 @@ OocListener: abstract class {
UnsupportedAstElement new(class, "property-decl-type") throw()
}
+ onPropertyAttribute: func (attr: FieldAttributes, value: CString = null) {
+ UnsupportedAstElement new(class, "property-decl-attribute") throw()
+ }
+
onPropertyDeclGetterStart: func (doc: CString) {
UnsupportedAstElement new(class, "property-decl-getter-start") throw()
@@ -378,6 +389,10 @@ OocListener: abstract class {
UnsupportedAstElement new(class, "function-call") throw()
}
+ onFunctionCallExpr: func (call, expr: Object) {
+ UnsupportedAstElement new(class, "function-call-expr") throw()
+ }
+
onFunctionCallChain: func (expr, call: Object) -> Object {
UnsupportedAstElement new(class, "function-call") throw(); null
}
@@ -578,7 +593,7 @@ OocListener: abstract class {
UnsupportedAstElement new(class, "bool-literal") throw(); null
}
- onNullLiteral: func -> Object {
+ onNull: func -> Object {
UnsupportedAstElement new(class, "null-literal") throw(); null
}
View
11 source/nagaqueen/callbacks.ooc
@@ -1,6 +1,8 @@
import OocListener
-nq_setTokenPositionPointer: func (l: OocListener, tokenPosPointer: Int*) {
+nq_parse: extern func (l: OocListener, path: CString) -> Int
+
+nq_setTokenPositionPointer: unmangled func (l: OocListener, tokenPosPointer: Int*) {
l tokenPos = tokenPosPointer
}
@@ -49,6 +51,8 @@ nq_onCoverEnd: unmangled func (l: OocListener) { l onCoverEnd() }
nq_onEnumStart: unmangled func (l: OocListener, name, doc: CString) { l onEnumStart(name, doc) }
nq_onEnumEnd: unmangled func (l: OocListener) { l onEnumEnd() }
+nq_onEnumFromType: unmangled func (l: OocListener, fromType: Object) { l onEnumFromType(fromType) }
+
nq_onEnumExtern: unmangled func (l: OocListener, externName: CString) { l onEnumExtern(externName) }
nq_onEnumIncrementExpr: unmangled func (l: OocListener, oper: Char, step: Object) { l onEnumIncrementExpr(oper, step) }
@@ -81,6 +85,8 @@ nq_onPropertyDeclStart: unmangled func (l: OocListener, name, doc: CString) {
nq_onPropertyDeclEnd: unmangled func (l: OocListener) -> Object { l onPropertyDeclEnd() }
nq_onPropertyDeclType: unmangled func (l: OocListener, type: Object) { l onPropertyDeclType(type) }
+nq_onPropertyDeclStatic: unmangled func (l: OocListener) { l onPropertyAttribute(FieldAttributes _static) }
+
nq_onPropertyDeclGetterStart: unmangled func (l: OocListener, doc: CString) { l onPropertyDeclGetterStart(doc) }
nq_onPropertyDeclGetterEnd: unmangled func (l: OocListener) -> Object { l onPropertyDeclGetterEnd() }
@@ -168,6 +174,7 @@ nq_onFunctionCallEnd: unmangled func (l: OocListener) { l onFunctionCallEnd()
nq_onFunctionCallSuffix: unmangled func (l: OocListener, suffix: CString) { l onFunctionCallSuffix(suffix) }
nq_onFunctionCallArg: unmangled func (l: OocListener, arg: Object) { l onFunctionCallArg(arg) }
+nq_onFunctionCallExpr: unmangled func (l: OocListener, call: Object, expr: Object) { l onFunctionCallExpr(call, expr) }
nq_onFunctionCallChain: unmangled func (l: OocListener, expr, call: Object) -> Object { l onFunctionCallChain(expr, call) }
nq_onFunctionCallCombo: unmangled func (l: OocListener, call, expr: Object) { l onFunctionCallCombo(call, expr) }
@@ -287,7 +294,7 @@ nq_onHexLiteral: unmangled func (l: OocListener, value: CString) -> Object { l
nq_onFloatLiteral: unmangled func (l: OocListener, value: CString) -> Object { l onFloatLiteral(value) }
nq_onBoolLiteral: unmangled func (l: OocListener, value: Bool) -> Object { l onBoolLiteral(value) }
-nq_onNullLiteral: unmangled func (l: OocListener) -> Object { l onNullLiteral() }
+nq_onNull: unmangled func (l: OocListener) -> Object { l onNull() }
nq_onParenthesis: unmangled func (l: OocListener, inner: Object) -> Object { l onParenthesis(inner) }
View
4 test.sh
@@ -1,3 +1,5 @@
#!/bin/sh
mkdir -p bin
-rock -sourcepath=source nagaqueen/callbacks -o=bin/testcompile -v
+greg grammar/nagaqueen.leg > bin/nagaqueen.c
+gcc -std=c99 -D_OOC_USE_GC bin/nagaqueen.c -c -o bin/nagaqueen.o
+rock -sourcepath=source:test printexceptions bin/nagaqueen.o -o=bin/printexceptions -v
View
23 test/printexceptions.ooc
@@ -0,0 +1,23 @@
+import nagaqueen/OocListener
+
+MyListener: class extends OocListener {
+
+ parse: func (path: String) {
+ try {
+ super(path)
+ } catch (e: Exception) {
+ e print()
+ }
+ }
+
+}
+
+
+main: func (argc: Int, argv: CString*) {
+
+ if(argc > 1) {
+ "Parsing %s" printfln(argv[1])
+ MyListener new() parse(argv[1] toString())
+ }
+
+}
Please sign in to comment.
Something went wrong with that request. Please try again.