-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
init branch with slight changes to the code in gapc.cc and signature.cc #219
Closed
Closed
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
999a77e
This should be a cleaner push, i hope
f2c57c5
placeholder
7f482f0
git
1bf42f6
added config.mf again
51b1d40
changed enum_graphs to trees
2e2ab96
Generates now output file. Also distinguishes between enum and trees …
48e5cbf
added Header and Footer to tikz code. Still missing } for trees.
cd1211f
Removed separate print_value_pp function. Since we piping the outpu i…
ecdee14
found the missing {, now just need to localize start and end point fo…
4ff7c1a
Little successes
5bf2fc8
Merge branch 'master' into plot_enums_in_graphviz
Mighty0r0n f952b4c
test for test
796e330
Merge branch 'plot_enums_in_graphviz' of github.com:jlab/gapc into pl…
6a8173e
for test
d3bb3cb
hopefully first test sould lead to a success now
4e5bb31
now
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -368,6 +368,9 @@ class Main { | |
driver.ast.set_outside_nt_list(&opts.outside_nt_list); | ||
driver.parse_product(opts.product); | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please revert empty lines |
||
|
||
|
||
if (driver.is_failing()) { | ||
throw LogError("Seen parse errors."); | ||
} | ||
|
@@ -450,6 +453,7 @@ class Main { | |
*/ | ||
void back(Instance *i = 0, Instance *instance_buddy = 0) { | ||
Instance *instance = i; | ||
|
||
if (!i || instance_buddy) { | ||
if (opts.backtrack || opts.subopt || opts.kbacktrack) { | ||
instance = driver.ast.split_instance_for_backtrack(opts.instance); | ||
|
@@ -679,6 +683,8 @@ class Main { | |
+ opts.plot_grammar_file + " > foo.pdf' to generate a PDF."); | ||
} | ||
|
||
|
||
|
||
driver.ast.set_class_name(opts.class_name); | ||
|
||
|
||
|
@@ -741,7 +747,6 @@ class Main { | |
} | ||
|
||
hh.backtrack_footer(driver.ast); | ||
|
||
hh.close_class(); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -149,10 +149,14 @@ Algebra *Signature::generate(std::string *n, std::string *mode) { | |
return generate_count(n); | ||
if (*mode == "enum") | ||
return generate_enum(n); | ||
if (*mode == "trees") | ||
return generate_trees(n); | ||
return NULL; | ||
} | ||
|
||
|
||
|
||
|
||
Comment on lines
+158
to
+159
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. revert |
||
struct Generate_Stmts { | ||
virtual void apply(Fn_Def &fn) const = 0; | ||
virtual ~Generate_Stmts() {} | ||
|
@@ -413,6 +417,156 @@ Algebra *Signature::generate_enum(std::string *n) { | |
} | ||
|
||
|
||
|
||
//------------------------------------------------------------------------------------------------------------ | ||
|
||
|
||
struct Generate_Tree_Stmts : public Generate_Stmts { | ||
private: | ||
// closes nodes for simple tracks | ||
void apply(std::list<Statement::Base*> &l, Para_Decl::Simple *s, | ||
Statement::Var_Decl *&cur) const { | ||
Statement::Fn_Call *f = new Statement::Fn_Call( | ||
Statement::Fn_Call::STR_APPEND); | ||
f->add_arg(*cur); | ||
f->add_arg(s->name()); | ||
l.push_back(f); | ||
} | ||
|
||
// Generating Child Nodes for grammar operations in Multitrack | ||
void apply(std::list<Statement::Base*> &l, Para_Decl::Multi *m, | ||
Statement::Var_Decl *&cur) const { | ||
Statement::Fn_Call * f = new Statement::Fn_Call( | ||
Statement::Fn_Call::STR_APPEND); | ||
f->add_arg(*cur); | ||
f->add_arg(new Expr::Const("child {node {")); | ||
l.push_back(f); | ||
|
||
const std::list<Para_Decl::Simple*> &p = m->list(); | ||
std::list<Para_Decl::Simple*>::const_iterator j = p.begin(); | ||
if (j != p.end()) { | ||
apply(l, *j, cur); | ||
++j; | ||
} | ||
for (; j != p.end(); ++j) { | ||
f = new Statement::Fn_Call(Statement::Fn_Call::STR_APPEND); | ||
f->add_arg(*cur); | ||
f->add_arg(new Expr::Const(", ")); | ||
f->add_arg(new Expr::Const(2)); | ||
l.push_back(f); | ||
apply(l, *j, cur); | ||
} | ||
|
||
f = new Statement::Fn_Call(Statement::Fn_Call::STR_APPEND); | ||
f->add_arg(*cur); | ||
f->add_arg(new Expr::Const("}}")); | ||
f->add_arg(new Expr::Const(2)); | ||
l.push_back(f); | ||
} | ||
|
||
|
||
void apply(std::list<Statement::Base*> &l, | ||
const std::list<Para_Decl::Base*> ¶s, | ||
Statement::Var_Decl *&cur) const { | ||
std::list<Statement::Base*> apps; | ||
unsigned int a = 0; | ||
for (std::list<Para_Decl::Base*>::const_iterator i = paras.begin(); | ||
i != paras.end(); ++i) { | ||
if (a > 0 && !(a % 3)) { | ||
std::ostringstream o; | ||
o << "ret_" << a; | ||
Type::External *str = new Type::External("Rope"); | ||
Statement::Var_Decl *t = new Statement::Var_Decl(str, o.str()); | ||
l.push_back(t); | ||
Statement::Fn_Call *f = | ||
new Statement::Fn_Call(Statement::Fn_Call::STR_APPEND); | ||
f->add_arg(*cur); | ||
f->add_arg(*t); | ||
cur = t; | ||
apps.push_front(f); | ||
} | ||
Statement::Fn_Call *f = new Statement::Fn_Call( | ||
Statement::Fn_Call::STR_APPEND); | ||
f->add_arg(*cur); | ||
Para_Decl::Multi *m = dynamic_cast<Para_Decl::Multi*>(*i); | ||
if (m) { | ||
f->add_arg(new Expr::Const(' ')); | ||
l.push_back(f); | ||
apply(l, m, cur); | ||
} else { | ||
Para_Decl::Simple *s = dynamic_cast<Para_Decl::Simple*>(*i); | ||
f->add_arg(new Expr::Const("child {node {")); | ||
l.push_back(f); | ||
assert(s); | ||
apply(l, s, cur); | ||
} | ||
a++; | ||
|
||
if (!m) { | ||
Statement::Fn_Call *g = new Statement::Fn_Call( | ||
Statement::Fn_Call::STR_APPEND); | ||
g->add_arg(*cur); | ||
g->add_arg(new Expr::Const("}}")); | ||
l.push_back(g); | ||
} | ||
} | ||
|
||
l.insert(l.end(), apps.begin(), apps.end()); | ||
} | ||
|
||
public: | ||
void apply(Fn_Def &fn) const { | ||
if (fn.is_Choice_Fn()) { | ||
Statement::Return *ret = new Statement::Return(fn.names.front()); | ||
fn.stmts.push_back(ret); | ||
return; | ||
} | ||
Type::External *str = new Type::External("Rope"); | ||
Statement::Var_Decl *ret = new Statement::Var_Decl(str, "ret"); | ||
fn.stmts.push_back(ret); | ||
Statement::Fn_Call *f = new Statement::Fn_Call( | ||
Statement::Fn_Call::STR_APPEND); | ||
f->add_arg(*ret); | ||
std::string t = "child {node {" + *fn.name + "}"; | ||
f->add_arg(new Expr::Const(t)); | ||
f->add_arg(new Expr::Const(static_cast<int>(t.size()))); | ||
fn.stmts.push_back(f); | ||
|
||
Statement::Var_Decl *cur = ret; | ||
std::list<Statement::Base*> l; | ||
apply(l, fn.paras, cur); | ||
fn.stmts.insert(fn.stmts.end(), l.begin(), l.end()); | ||
|
||
if (fn.ntparas().size() > 0) { | ||
f = new Statement::Fn_Call(Statement::Fn_Call::STR_APPEND); | ||
f->add_arg(*ret); | ||
f->add_arg(new Expr::Const(';')); | ||
fn.stmts.push_back(f); | ||
std::list<Statement::Base*> lntparas; | ||
apply(lntparas, fn.ntparas(), ret); | ||
fn.stmts.insert(fn.stmts.end(), lntparas.begin(), lntparas.end()); | ||
} | ||
f = new Statement::Fn_Call(Statement::Fn_Call::STR_APPEND); | ||
f->add_arg(*ret); | ||
f->add_arg(new Expr::Const(' ')); | ||
fn.stmts.push_back(f); | ||
f = new Statement::Fn_Call(Statement::Fn_Call::STR_APPEND); | ||
f->add_arg(*ret); | ||
f->add_arg(new Expr::Const('}')); | ||
fn.stmts.push_back(f); | ||
Statement::Return *r = new Statement::Return(*ret); | ||
fn.stmts.push_back(r); | ||
} | ||
}; | ||
|
||
|
||
Algebra *Signature::generate_trees(std::string *n) { | ||
return generate_algebra(n, Mode::PRETTY, new Type::External("Rope"), | ||
Generate_Tree_Stmts()); | ||
} | ||
//------------------------------------------------------------------------------------------------------------ | ||
|
||
|
||
struct Generate_Backtrace_Stmts : public Generate_Stmts { | ||
Generate_Backtrace_Stmts() : value_type(0), pos_type(0) {} | ||
Type::Base *value_type; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this a general error? But if I look at the line below, we are closing the block via
}
. Why should we increase instead of decrease the indentation?