Changed from typedef to obj and def
This commit is contained in:
@@ -52,7 +52,8 @@ triple_quoted_string = "\"\"\"((\"\"(`|1|2|3|4|5|6|7|8|9|0|-|=| |q|w|e|r|t|y|u|i
|
||||
|z|x|c|v|b|n|m|,|.|/|~|!|@|#|$|%|^|&|\*|\(|\)|_|\+|Q|W|E|R|T|Y|U|I|O|P|{|}|\||A|S|D|F|G|H|J|K|L|:|Z|X|C|V|B|N|M|<|>|\?| )+\"\")|((`|1|2|3|4|5|6|7|8|9|0|-|=| |q|w|e|r|t|y|u|i|o|p|[|]|\\|a|s|d|f|g|h|j|k|l|;|'|
|
||||
|z|x|c|v|b|n|m|,|.|/|~|!|@|#|$|%|^|&|\*|\(|\)|_|\+|Q|W|E|R|T|Y|U|I|O|P|{|}|\||A|S|D|F|G|H|J|K|L|:|Z|X|C|V|B|N|M|<|>|\?| )+))*\"\"\"" ;
|
||||
|
||||
identifier = alpha_alphanumeric ;
|
||||
#identifier = alpha_alphanumeric ;
|
||||
identifier = augmented_alpha_alphanumeric ;
|
||||
scope_op = ":" ":" ;
|
||||
scoped_identifier = scoped_identifier WS scope_op WS identifier | identifier ;
|
||||
|
||||
@@ -70,7 +71,9 @@ opt_parameter_list = parameter_list | ;
|
||||
parameter_list = parameter_list WS "," WS parameter | parameter ;
|
||||
parameter = boolean_expression ;
|
||||
|
||||
type_def = "typedef" WS identifier WS type | "typedef" WS identifier WS template_dec WS "{" WS declaration_block WS "}" | "typedef" WS identifier WS "{" WS declaration_block WS "}" | "typedef" WS identifier WS template_dec WS traits WS "{" WS declaration_block WS "}" | "typedef" WS identifier WS traits WS "{" WS declaration_block WS "}" ;
|
||||
def_nonterm = "def" ;
|
||||
obj_nonterm = "obj" ;
|
||||
type_def = def_nonterm WS identifier WS type | obj_nonterm WS identifier WS template_dec WS "{" WS declaration_block WS "}" | obj_nonterm WS identifier WS "{" WS declaration_block WS "}" | obj_nonterm WS identifier WS template_dec WS traits WS "{" WS declaration_block WS "}" | obj_nonterm WS identifier WS traits WS "{" WS declaration_block WS "}" ;
|
||||
|
||||
declaration_block = declaration_statement line_end WS declaration_block | function WS declaration_block | declaration_statement line_end | function | ;
|
||||
traits = "\(" WS trait_list WS "\)" ;
|
||||
@@ -115,7 +118,11 @@ floating_literal = numeric "." numeric ;
|
||||
bool = "true" | "false" ;
|
||||
character = "'(`|1|2|3|4|5|6|7|8|9|0|-|=| |q|w|e|r|t|y|u|i|o|p|[|]|\\|a|s|d|f|g|h|j|k|l|;|'|
|
||||
|z|x|c|v|b|n|m|,|.|/|~|!|@|#|$|%|^|&|\*|\(|\)|_|\+|Q|W|E|R|T|Y|U|I|O|P|{|}|\||A|S|D|F|G|H|J|K|L|:|\"|Z|X|C|V|B|N|M|<|>|\?| )'" ;
|
||||
|
||||
keywords_also_identifiers = "obj" | "def" ;
|
||||
alpha_alphanumeric = "(a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z|_)(a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z|_|0|1|2|3|4|5|6|7|8|9)*" ;
|
||||
augmented_alpha_alphanumeric = alpha_alphanumeric augmented_alpha_alphanumeric | keywords_also_identifiers augmented_alpha_alphanumeric | alpha_alphanumeric | keywords_also_identifiers ;
|
||||
|
||||
numeric = "(0|1|2|3|4|5|6|7|8|9)+" ;
|
||||
string = triple_quoted_string | "\"(`|1|2|3|4|5|6|7|8|9|0|-|=| |q|w|e|r|t|y|u|i|o|p|[|]|\\|a|s|d|f|g|h|j|k|l|;|'|
|
||||
|z|x|c|v|b|n|m|,|.|/|~|!|@|#|$|%|^|&|\*|\(|\)|_|\+|Q|W|E|R|T|Y|U|I|O|P|{|}|\||A|S|D|F|G|H|J|K|L|:|Z|X|C|V|B|N|M|<|>|\?| )*\"" ;
|
||||
|
||||
@@ -35,7 +35,8 @@ Importer::Importer(Parser* parserIn, std::vector<std::string> includePaths, std:
|
||||
removeSymbols.push_back(Symbol("__if_comp__", true));
|
||||
removeSymbols.push_back(Symbol("simple_passthrough", true));
|
||||
removeSymbols.push_back(Symbol("comp_simple_passthrough", true));
|
||||
removeSymbols.push_back(Symbol("typedef", true));
|
||||
removeSymbols.push_back(Symbol("def_nonterm", false));
|
||||
removeSymbols.push_back(Symbol("obj_nonterm", false));
|
||||
removeSymbols.push_back(Symbol("template", true));
|
||||
removeSymbols.push_back(Symbol("\\|", true));
|
||||
//collapseSymbols.push_back(Symbol("scoped_identifier", false));
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import vector;
|
||||
import mem;
|
||||
|
||||
typedef string (Destructable) {
|
||||
obj string (Destructable) {
|
||||
var data: vector::vector<char>;
|
||||
fun construct(): string* {
|
||||
data.construct();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import io;
|
||||
|
||||
typedef trivialContainer<T> {
|
||||
obj trivialContainer<T> {
|
||||
var data: T;
|
||||
fun print(): void {
|
||||
io::print(data);
|
||||
|
||||
@@ -2,7 +2,7 @@ import mem:*;
|
||||
import util:*;
|
||||
import io:*;
|
||||
|
||||
typedef vector<T> (Destructable) {
|
||||
obj vector<T> (Destructable) {
|
||||
var data: T*;
|
||||
var size: int;
|
||||
var available: int;
|
||||
@@ -13,7 +13,7 @@ typedef vector<T> (Destructable) {
|
||||
data = new<T>(8);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
fun construct(newSize: int): vector<T>*{
|
||||
size = newSize;
|
||||
available = newSize;
|
||||
@@ -48,7 +48,7 @@ typedef vector<T> (Destructable) {
|
||||
print("Vector tried to access element: ");
|
||||
println(index);
|
||||
print("Max Index of vector: ");
|
||||
println(size-1);
|
||||
println(size-1);
|
||||
return data[0];
|
||||
}
|
||||
return data[index];
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
var sameVar: int;
|
||||
fun sameFun(): int { return 5; }
|
||||
typedef classTester {
|
||||
obj classTester {
|
||||
fun method(): int { return 8; }
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
var sameVar: int;
|
||||
fun sameFun(): int { return 6; }
|
||||
typedef classTester {
|
||||
obj classTester {
|
||||
fun method(): int { return 9; }
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
var qualified_variable: int = 7;
|
||||
fun qualified_func(): int { return 9; }
|
||||
|
||||
typedef qualified_class {
|
||||
obj qualified_class {
|
||||
var number: int;
|
||||
fun construct(num: int): qualified_class* {
|
||||
number = num;
|
||||
@@ -12,7 +12,7 @@ typedef qualified_class {
|
||||
}
|
||||
};
|
||||
|
||||
typedef qualified_container<T> {
|
||||
obj qualified_container<T> {
|
||||
var data: T;
|
||||
fun construct(dataIn: T): qualified_container<T>* {
|
||||
data = dataIn;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
var unqualifed_variable: int = 8;
|
||||
fun unqualified_func(): int { return 10; }
|
||||
|
||||
typedef unqualified_class {
|
||||
obj unqualified_class {
|
||||
var number: int;
|
||||
fun construct(num: int): unqualified_class* {
|
||||
number = num;
|
||||
@@ -12,7 +12,7 @@ typedef unqualified_class {
|
||||
}
|
||||
};
|
||||
|
||||
typedef unqualified_container<T> {
|
||||
obj unqualified_container<T> {
|
||||
var data: T;
|
||||
fun construct(dataIn: T): unqualified_container<T>* {
|
||||
data = dataIn;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import io:*;
|
||||
|
||||
typedef Vec2 {
|
||||
obj Vec2 {
|
||||
var x: int;
|
||||
var y: int;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import io:*;
|
||||
import mem:*;
|
||||
|
||||
typedef ClassWithConstructor {
|
||||
obj ClassWithConstructor {
|
||||
var data: int;
|
||||
fun construct(inData: int): ClassWithConstructor* {
|
||||
data = inData;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import io:*
|
||||
|
||||
typedef FuncObj {
|
||||
obj FuncObj {
|
||||
fun operator()(a:int, b:char*): void {
|
||||
println(a)
|
||||
println(b)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import mem:*;
|
||||
import io:*;
|
||||
|
||||
typedef AnObject {
|
||||
obj AnObject {
|
||||
var a: int;
|
||||
var b: int;
|
||||
var c: char*;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import io:*;
|
||||
|
||||
typedef firstObject {
|
||||
obj firstObject {
|
||||
var objectNum: int;
|
||||
var other: int;
|
||||
fun print(): void {
|
||||
@@ -11,7 +11,7 @@ typedef firstObject {
|
||||
}
|
||||
};
|
||||
|
||||
typedef Int int;
|
||||
def Int int;
|
||||
|
||||
var aliasNum: Int;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import io:*;
|
||||
import trivial_container:*;
|
||||
|
||||
typedef RegularObject {
|
||||
obj RegularObject {
|
||||
var num: int;
|
||||
var innerContainer: trivialContainer<char*>;
|
||||
fun set(message: char*, number: int): void {
|
||||
@@ -17,7 +17,7 @@ typedef RegularObject {
|
||||
}
|
||||
};
|
||||
|
||||
typedef MyIntContainer trivialContainer<int>;
|
||||
def MyIntContainer trivialContainer<int>;
|
||||
var roundabout: MyIntContainer;
|
||||
var outsideDec: RegularObject;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
|
||||
typedef Swapper<T> {
|
||||
obj Swapper<T> {
|
||||
fun doit(a: T*, b: T*) : void {
|
||||
var temp: T = *a;
|
||||
*a = *b;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import io:*;
|
||||
|
||||
typedef objectA {
|
||||
obj objectA {
|
||||
var a: int;
|
||||
};
|
||||
|
||||
typedef BigObject {
|
||||
obj BigObject {
|
||||
var a: objectA;
|
||||
var b: objectB;
|
||||
fun add(): int {
|
||||
@@ -12,7 +12,7 @@ typedef BigObject {
|
||||
}
|
||||
};
|
||||
|
||||
typedef objectB {
|
||||
obj objectB {
|
||||
var b: int;
|
||||
};
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import sameNameTwo
|
||||
var sameVar: int;
|
||||
fun sameFun(): int { return 4; }
|
||||
|
||||
typedef classTester {
|
||||
obj classTester {
|
||||
fun method(): int {
|
||||
return 7
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import io;
|
||||
|
||||
|
||||
typedef TemplateTest<T,J> {
|
||||
obj TemplateTest<T,J> {
|
||||
var a: T;
|
||||
var b: J;
|
||||
fun print(): void {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import io;
|
||||
|
||||
|
||||
typedef TemplateTest<T> {
|
||||
obj TemplateTest<T> {
|
||||
var a: int;
|
||||
var b: T;
|
||||
fun print(): void {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import io;
|
||||
|
||||
typedef FirstObject {
|
||||
obj FirstObject {
|
||||
var objectNum: int;
|
||||
fun PrintSelf(a: int): void {
|
||||
io::print(objectNum);
|
||||
|
||||
@@ -2,7 +2,7 @@ import io:*
|
||||
import mem:*
|
||||
import vector:*
|
||||
|
||||
typedef pair<T, U> {
|
||||
obj pair<T, U> {
|
||||
var first: T
|
||||
var second: U
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import io:*;
|
||||
import trivial_container:*;
|
||||
|
||||
typedef TemplateTest<T> {
|
||||
obj TemplateTest<T> {
|
||||
var a: int;
|
||||
var b: T;
|
||||
var c: trivialContainer<T>;
|
||||
@@ -17,7 +17,7 @@ typedef TemplateTest<T> {
|
||||
}
|
||||
};
|
||||
|
||||
typedef MyInt int;
|
||||
def MyInt int;
|
||||
|
||||
var c: MyInt;
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import io:*;
|
||||
|
||||
typedef NoTraits {};
|
||||
obj NoTraits {};
|
||||
|
||||
typedef Trait1 (FirstTrait) {};
|
||||
typedef Trait2 (SecondTrait) {};
|
||||
typedef TwoTrait (FirstTrait, SecondTrait) {};
|
||||
typedef AlreadySpecilized (FirstTrait, SecondTrait) {};
|
||||
obj Trait1 (FirstTrait) {};
|
||||
obj Trait2 (SecondTrait) {};
|
||||
obj TwoTrait (FirstTrait, SecondTrait) {};
|
||||
obj AlreadySpecilized (FirstTrait, SecondTrait) {};
|
||||
|
||||
fun OneTwoFunc<T>(obj: T): void {
|
||||
println("No Traits");
|
||||
@@ -30,12 +30,12 @@ template <AlreadySpecilized> |void| OneTwoFunc(|AlreadySpecilized| obj) {
|
||||
//This should work for objects too!
|
||||
//To test, we cycle the mapping of traits
|
||||
|
||||
typedef OneTwoObj<T> (FirstTrait) {};
|
||||
typedef OneTwoObj<T(FirstTrait)> (SecondTrait) {};
|
||||
typedef OneTwoObj<T(SecondTrait)> (FirstTrait, SecondTrait) {};
|
||||
typedef OneTwoObj<T(FirstTrait, SecondTrait)> {};
|
||||
obj OneTwoObj<T> (FirstTrait) {};
|
||||
obj OneTwoObj<T(FirstTrait)> (SecondTrait) {};
|
||||
obj OneTwoObj<T(SecondTrait)> (FirstTrait, SecondTrait) {};
|
||||
obj OneTwoObj<T(FirstTrait, SecondTrait)> {};
|
||||
/*
|
||||
*typedef template<AlreadySpecilized> OneTwoObj {
|
||||
*obj template<AlreadySpecilized> OneTwoObj {
|
||||
* void proveSpecilized() {
|
||||
* println("I'm specilized!");
|
||||
* }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import io;
|
||||
|
||||
typedef ClassWithConstructor {
|
||||
obj ClassWithConstructor {
|
||||
var data: int;
|
||||
fun construct(inData: int): ClassWithConstructor* {
|
||||
data = inData;
|
||||
|
||||
@@ -7,11 +7,11 @@ fun retMessage(): char* {
|
||||
}
|
||||
fun id<T>(in: T): T { return in; }
|
||||
|
||||
typedef CustomObj {
|
||||
obj CustomObj {
|
||||
var data: int;
|
||||
}
|
||||
|
||||
typedef CustomObjTmplt<T> {
|
||||
obj CustomObjTmplt<T> {
|
||||
var data: T;
|
||||
}
|
||||
fun inFun<T>(in: T):T {
|
||||
|
||||
@@ -2,7 +2,7 @@ import io:*;
|
||||
import mem:*;
|
||||
import vector:*;
|
||||
|
||||
typedef AbleToBeDestroyed (Destructable) {
|
||||
obj AbleToBeDestroyed (Destructable) {
|
||||
fun destruct(): void {
|
||||
println("Destroyed!");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user