-
Notifications
You must be signed in to change notification settings - Fork 2
Conversation
|
||
return NodePtr(new TagStatement(tag_name, id_name, class_names, body, attributes)); | ||
return NodePtr( | ||
new TagStatement(tag_name, id_name, class_names, body, attributes, nested)); |
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.
Just curious - why did you put this on a new line?
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.
It was getting a little long
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.
I also added another parameter to the list, btw, which is what made me think to bump it down a line
@@ -37,7 +35,7 @@ il_lit_str_content <- !'"' . | |||
|
|||
escaped <- '\\' . | |||
|
|||
tag_statement <- tag $identifier< id_name? > $classes< class_name* > ~space* $body< text_content? > $attributes< attributes? > | |||
tag_statement <- tag id_name? class_name* ~space* text_content? attr_list? (~nl ~lbrace ~nl ROOT ~rbrace ~nl)? |
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.
👍 💯
bool truthy(Json &context) const override; | ||
|
||
private: | ||
|
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.
can you remove this blank newline please?
|
||
BooleanPtr lhs; | ||
BooleanPtr rhs; | ||
Operator op; |
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.
And add a blank newline after line 23?
key_name(key_name) | ||
{} | ||
|
||
std::string Each::to_html(NodePtr body, Json &context) const { |
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.
This method is kinda big, and hard to read - do you think we could break this up into a few smaller private methods belonging to the Each
class?
|
||
std::string Scope::to_html(Json &context) { | ||
return scope_fn.to_html(body); | ||
return scope_fn->to_html(body, context); |
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.
Good catch 👍
private: | ||
std::string collection_name; | ||
std::string val_name; | ||
std::string key_name; |
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.
Could we add a blank newline after this statement?
@@ -6,13 +6,15 @@ TagStatement::TagStatement( | |||
std::string id, | |||
std::vector<std::string> classes, | |||
NodePtr body, | |||
NodePtr attributes | |||
NodePtr attributes, |
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.
|
||
private: | ||
bool negated; | ||
BooleanPtr expr; |
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.
Could we add a newline after here?
|
||
unary_expr <- $negated< ('not' space+)? > ($val< variable_name > / '(' space* $val< boolean_expr > space* ')') | ||
unary_expr <- ('not' space+)? (variable_name / ~'(' ~space* boolean_expr ~space* ~')') |
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.
👍
|
||
boolean_expr <- binary_expr / unary_expr | ||
|
||
binary_expr <- $lhs< unary_expr > space+ $op< 'and' / 'or' > space+ $rhs< boolean_expr > | ||
binary_expr <- unary_expr ~space+ ('and' / 'or') ~space+ boolean_expr |
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.
👍
|
||
each <- 'each' space* $collection< variable_name > space* 'as' space* $val_name< variable_name > $indexed< (',' space* $key_name< variable_name >)? > | ||
each <- ~'each' ~space* variable_name ~space* ~'as' ~space* ~variable_name (~',' ~space* ~variable_name)? > |
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.
👍
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.
Fantastic work 🙌 - just a few minor things, which I commented above.
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.
We'll start using an autoformatter for C++ once we get the grammar working.
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.
💯
This makes two new base classes:
Boolean
, for things in the condition of aScopeFn
ScopeFn
, which takes aNodePtr
in addition to aJson
in itsto_html
method. It transforms the context and passes it to theNodePtr
.Some refactors done in the process:
TagStatement
andNested
into one classconst
out of theJson
typedef so that we can use it mutably to build up a new context in aScopeFn
. After we're good with all the nodes, we should change theto_html
signature to take in aconst Json
(we were going to refactor it anyway to addconst
to the method.) Added this to Clean up grammar #78Things left to do after this:
make
the whole thing because there are some other build errors right now, so probably when we fix the existing ones, we'll discover new build errors in this code.