Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement code to pass M1 and M2 targets
- Loading branch information
1 parent
d5603ab
commit 1ec5c4f
Showing
2 changed files
with
19 additions
and
10 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -207,11 +207,11 @@ static void attach_comment_after(YCodePtr code, const std::string& comment); | |
#define TREE_RULE_COMMENT(source_dollar) \ | ||
attach_comment((yyval).c , "" /*source_dollar.c->commentBefore()*/ ) // FIXME commentAfter too | ||
|
||
// attach comment from a terminal to the PRECEDING YCode | ||
// attach comment from a terminal to the last YCode | ||
// (because the terminal is the last symbol in its rule, | ||
// usually some kind of closing brace) | ||
#define LAST_TOKEN_COMMENT(source_dollar) \ | ||
attach_comment_after((&(source_dollar) + 1)->c , source_dollar.com) | ||
attach_comment_after(last_code, source_dollar.com) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
jreidinger
Author
Member
|
||
|
||
extern "C" { | ||
int yylex (YYSTYPE *, void *); | ||
|
@@ -3713,6 +3713,7 @@ function_call: | |
} | ||
|
||
attach_comment($$.c, $1.com + $2.com + $3.com + $4.com + $5.com); | ||
last_code = $$.c; | ||
$$.l = $1.l; | ||
#if DO_DEBUG | ||
y2debug ("fcall (%s:%s)", $$.t->toString().c_str(), $$.c->toString().c_str()); | ||
|
@@ -4727,19 +4728,21 @@ attach_comment(YCodePtr code, const std::string& comment) | |
return; // FIXME probably attach it somewhere else | ||
if (comment.empty()) | ||
return; | ||
string comment_before; | ||
if (last_code) | ||
{ | ||
size_t first_endl = comment.find_first_of('\n'); | ||
size_t first_endl = comment.find('\n'); | ||
if (first_endl != string::npos) | ||
{ | ||
attach_comment_after(last_code, comment.substr(0, first_endl -1)); | ||
comment = comment.substr(first_endl+1); | ||
attach_comment_after(last_code, comment.substr(0, first_endl)); | ||
comment_before = comment.substr(first_endl+1); | ||
} | ||
} | ||
} else | ||
comment_before = comment; | ||
// YCode::setCommentBefore takes ownership of its param | ||
// which should be new char[] | ||
char * newstr = new char[comment.size() + 1]; | ||
strcpy(newstr, comment.c_str()); | ||
char * newstr = new char[comment_before.size() + 1]; | ||
strcpy(newstr, comment_before.c_str()); | ||
code->setCommentBefore(newstr); | ||
} | ||
|
||
|
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 completely changes the intended semantics, but I hope you know what you are doing and will wait for a more complete grammar.