-
Notifications
You must be signed in to change notification settings - Fork 35
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
Bug in nested loops or matching a list with trailing delimiter? #30
Comments
Hi! 1 - Your first case is actually behaving right. You designed a macro that matches a single annotation before a class, so only the green part below is being matched: - @Any(a = 66)
+ @Some(a = 23, b = 42)
+ class TestClass 2 - There seems to be a huge confusion on how // so the following parser:
chain(
token('{'),
ls(token(T_STRING)->as('letters'), token(',')) ,
token('}')
)
// will match
{A, B, C}
// but won't match
{A, B, C,}
^ fails on the last ',' and backtracks to '{' This means that the parser API needs more care. We certainly need a version of @Some(foo = bar) T_WHITESPACE
@Any(b = 1) T_WHITESPACE // it's a trailing delimiter!
class Foo {} I've just added a 3 - There are future optimiaztions being planned that could result in whitespace being elided. So in general, @Any(a = 66);
@Some(a = 23, b = 42);
class MyClass {...} 4 - On your latest attempt, indeed it's a bug. You marked the macro as After fixing the macro hygiene bug, I did this test macro as an example: annotations. |
Thanks for reporting this! |
@marcioAlmada Thank you for such a detailed review! Lack of complete documentation required study examples (thanks to them) , so I do not quite understand correctly the "entire device" as a whole =) ...not yet. P.S. More lacks record syntax at the end or beginning of the file, or... inside methods, as example:
I dont know how implement this with yay =( |
I don't know exactly what you're trying to achieve now, it seems t be some form of design by contract using annotations. Something like this would work for the specific case of macro {
/* DBC macro to check for a condition before a method/function */
@Verify\Before(···expression);
·optional(·repeat(·either(·token(T_PUBLIC), ·token(T_PROTECTED), ·token(T_PRIVATE), ·token(T_STATIC))))·modifiers
function ·optional(·label())·name (···args) ·optional(·chain(·token(':'), ·ns()·type))·ret_type {
···body
}
} >> {
·modifiers function ·name (···args) ·ret_type {
// @Verify\Before
assert(··unsafe(···expression), 'Verify "' . ··stringify(···expression) . '" failed for function ' . __FUNCTION__);
···body
}
} Making a more general purpose DBC framework would be a bit trickier but it's possible. For a more complex example of YAY being used you can refer to yay-enums. |
A little experiment for simple annotations implementation:
input:
macro:
output:
Try to fix bug on line 1:
New ouput:
wtf? o______________0 Its probably #20 issue?
The text was updated successfully, but these errors were encountered: