Skip to content
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

Pragmas #115

Closed
wants to merge 8 commits into from
Closed

Pragmas #115

wants to merge 8 commits into from

Conversation

sebasguts
Copy link

I put this on top if the syntax tree PR #114 to see if you can code/decode the pragmas

Copy link
Owner

@fingolfin fingolfin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some remarks

@@ -1806,6 +1806,17 @@ void CodeStringExpr (
PushExpr( string );
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commit messsage: "Function can contain pragmas ..." -> Functions

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Int ix = PushValue(pragma);
WRITE_EXPR(pragmaexpr, 0, ix);
PushStat( pragmaexpr );
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is completely new code, so you are free to clang-format it :-)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

CodePragma( pragma );
} else {
// Push a void when interpreting
PushVoidObj();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't do it, you run into the assertion assert( LEN_PLIST(STATE(StackObj)) == 1 ); in IntrEnd if you enter a pragma in plain interactive mode, i.e., in a GAP session like

gap> #@ foo

src/read.c Outdated Show resolved Hide resolved
}
else {
Match(S_PRAGMA, "", 0L );
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason for this change?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While a pragma is a statement, you have to Match the statement end to get the next symbol. However, a pragma does not end with a semicolon, so we cannot get the next symbol by matching semicolon.

src/stats.c Outdated Show resolved Hide resolved
@@ -2854,6 +2861,7 @@ rec(
stats := rec(
statements := [ rec(
obj := rec(
string := "1.0",
type := "T_FLOAT_EXPR_EAGER",
value := 1 ),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am confused as to why value is 1 here... I'd expect 1. or 1.0... huh

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is part of the other PR #114 and should maybe be discussed there.

@@ -1944,7 +1942,7 @@ void CodeFloatExpr(Obj s)
CodeEagerFloatExpr(s, mark);
}
else {
CodeLazyFloatExpr(s);
CodeLazyFloatExpr(s,1);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
CodeLazyFloatExpr(s,1);
CodeLazyFloatExpr(s, 1);

@@ -1909,7 +1904,10 @@ static void CodeLazyFloatExpr(Obj str)
WRITE_EXPR(fl, 1, PushValue(str));

/* push the expression */
PushExpr(fl);
if(pushExpr){
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(pushExpr){
if(pushExpr) {

Obj value = GET_VALUE_FROM_CURRENT_BODY(READ_EXPR(expr, 0));
Obj string = GET_VALUE_FROM_CURRENT_BODY(READ_EXPR(expr, 1));
AssPRec(result, RNamName("value"), value);
AssPRec(result, RNamName("string"), string);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "mark" character is not decoded here, as returned by (Char)READ_EXPR(expr, 2)...

}


Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

@codecov
Copy link

codecov bot commented Mar 21, 2019

Codecov Report

Merging #115 into master will decrease coverage by 27.41%.
The diff coverage is 25.94%.

@@             Coverage Diff             @@
##           master     #115       +/-   ##
===========================================
- Coverage   69.17%   41.76%   -27.42%     
===========================================
  Files         633       99      -534     
  Lines      305868    40201   -265667     
===========================================
- Hits       211593    16789   -194804     
+ Misses      94275    23412    -70863
Impacted Files Coverage Δ
src/code.h 86.11% <ø> (ø) ⬆️
src/scanner.h 33.33% <ø> (ø) ⬆️
src/io.c 41.58% <100%> (-5.03%) ⬇️
src/code.c 90.73% <100%> (+0.1%) ⬆️
src/syntaxtree.c 6.36% <2.61%> (-5.11%) ⬇️
src/stats.c 63.09% <28.57%> (-1.03%) ⬇️
src/intrprtr.c 69.64% <87.5%> (-1.09%) ⬇️
src/read.c 82.56% <88.88%> (+0.02%) ⬆️
src/scanner.c 66.51% <93.33%> (+0.84%) ⬆️
src/system.c 44.9% <0%> (-10.19%) ⬇️
... and 547 more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants