Skip to content

Commit

Permalink
implement code to pass M1 and M2 targets
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Jun 21, 2013
1 parent d5603ab commit 1ec5c4f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
19 changes: 11 additions & 8 deletions libycp/src/parser.yy
Expand Up @@ -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.

Copy link
@mvidner

mvidner Jun 21, 2013

Member

This completely changes the intended semantics, but I hope you know what you are doing and will wait for a more complete grammar.

This comment has been minimized.

Copy link
@jreidinger

jreidinger Jun 21, 2013

Author Member

yes, because problem of previous code is that it attach it to non parsed element


extern "C" {
int yylex (YYSTYPE *, void *);
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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);
}

Expand Down
10 changes: 8 additions & 2 deletions libycp/src/scanner.ll
Expand Up @@ -133,7 +133,10 @@ SYMBOL ([[:alpha:]_][[:alnum:]_]+|[[:alpha:]][[:alnum:]_]*)
save_comment(yytext);
BEGIN (INITIAL);
}
<comment>. {
<comment>\* {
save_comment(yytext);
}
<comment>[^*]* {
save_comment(yytext);
}

Expand All @@ -144,8 +147,11 @@ SYMBOL ([[:alpha:]_][[:alnum:]_]+|[[:alpha:]][[:alnum:]_]*)

\n { /* Ignore newlines */

This comment has been minimized.

Copy link
@mvidner

mvidner Jun 21, 2013

Member

This and the next comment are now wrong. Remove "Ignore "?

INC_LINE;
save_comment(yytext);
}
[\f\t\r\v ]+ { /* Ignore Whitespaces according to isspace(3) */ }
[\f\t\r\v ]+ { /* Ignore Whitespaces according to isspace(3) */
save_comment(yytext);
}


/* ----------------------------------- */
Expand Down

0 comments on commit 1ec5c4f

Please sign in to comment.