Mercurial > archived > louis > epitech > mq > rathaxes
view PointcutTyping @ 66:901af221334b
Adding implementation poinctuts parameters to e1000 sample
author | David Pineau <dav.pineau@gmail.com> |
---|---|
date | Sat, 18 Feb 2012 15:51:06 +0100 |
parents | |
children |
line wrap: on
line source
# HG changeset patch # Parent 48c3aacc384cde5a9678d51eeacf6e97262296ff rathaxe: compiler: Add pointcut typing * rename rtx_seq_param -> rtx_param and and rtx_seq_parameter -> rtx_parameter_list * Use the renamed parsing rule to parse the argument list of a chunk (factorizing the prototype parsing of a template and a pointcut/chunk) diff --git a/rathaxes/compiler/parse/rtxBack.cwp b/rathaxes/compiler/parse/rtxBack.cwp --- a/rathaxes/compiler/parse/rtxBack.cwp +++ b/rathaxes/compiler/parse/rtxBack.cwp @@ -184,25 +184,38 @@ /**/ => local lastNode; /**/ #check(cnormNodeBlock_GetLastNode(theBlock, lastNode)) - // Optional Joinpoint (argument of the pointcut) + // Optional Joinpoint (argument of the pointcut: if none, parenthesis not required) // Build the chunk node, and retrieve the references to it's internals // (body and parameters) -/**/ => local parameters; +/**/ => local param_types; +/**/ => local param_identifiers; /**/ => local body; -/**/ => local pointcut; -/**/ #check(rtxNodeChunk(lastNode, pointcut, parameters, body)) - rtx_scoped_identifier(pointcut) -/**/ #check(rtxNodeVarList(parameters)) - [ rtx_stmt_chunk_params(parameters) ]? +/**/ => local pointcutRtype; +/**/ => local pointcutId; +/**/ #check(rtxNodeChunk(lastNode, pointcutRtype, param_identifiers, body)) + rtx_scoped_identifier(pointcutId) + #check(rtxNodeRType(pointcutRtype, pointcutId, param_types)) + [ rtx_parameter_list(param_types, param_identifiers) ]? /**/ #continue(sError, "Expected block after chunk declaration.") rtx_chunk_body(body) ; +rtx_stmt_chunk_param(theParam : node) ::= +/**/=> local rtype; +/**/=> local typeId; + rtx_scoped_identifier(typeId) // for the type + #check(rtxNodeRType(rtype, typeId, )) + identifier:sName // for the identifier's value +; + // If there is any parameters to the chunk, we push it into a param list rtx_stmt_chunk_params(theParams : node) ::= '(' - [ rtx_var_list(theParams) ]? -/**/ #continue(sError, "Expected ')' to end parameter list.") + [ + #pushItem(theParams) + rtx_stmt_chunk_param(theParams#back) + ]? +/**/ #continue(sError, "Expected ')' to end parameter list.") ')' ; diff --git a/rathaxes/compiler/parse/rtxCommon.cwp b/rathaxes/compiler/parse/rtxCommon.cwp --- a/rathaxes/compiler/parse/rtxCommon.cwp +++ b/rathaxes/compiler/parse/rtxCommon.cwp @@ -131,18 +131,18 @@ * */ -rtx_seq_param(theParams : node, theIdentifiers : node) ::= +rtx_param(theParams : node, theIdentifiers : node) ::= #pushItem(theIdentifiers) #pushItem(theParams) rtx_scoped_identifier(theParams#back) [ #readIdentifier:theIdentifiers#back ]? ; -rtx_seq_parameter(theParams : node, theIdentifiers : node) ::= +rtx_parameter_list(theParams : node, theIdentifiers : node) ::= '(' [ - rtx_seq_param(theParams, theIdentifiers) - [ ',' rtx_seq_param(theParams, theIdentifiers) ]* + rtx_param(theParams, theIdentifiers) + [ ',' rtx_param(theParams, theIdentifiers) ]* ]? ')' ; @@ -152,5 +152,5 @@ /**/=> local params; rtx_scoped_identifier(nameNode) #check(rtxNodeRType(theRtype, nameNode, params)) - rtx_seq_parameter(params, theIdentifiers) + rtx_parameter_list(params, theIdentifiers) ; diff --git a/rathaxes/compiler/parse/rtxMiddle.cwp b/rathaxes/compiler/parse/rtxMiddle.cwp --- a/rathaxes/compiler/parse/rtxMiddle.cwp +++ b/rathaxes/compiler/parse/rtxMiddle.cwp @@ -68,8 +68,8 @@ #continue(sError, "Expected pointcut name after declaration type.") rtx_scoped_identifier(nameNode) #check(rtxNodeItfPointcutDeclaration(theDecl, theQualif, nameNode, params)) - #continue(sError, "Expected parameters to pointcut '"+nameNode.name+"'") - [rtx_pointcut_parameter(params)]? + #continue(sError, "Expected parameters to pointcut '"+rtxRtypeName<nameNode.type>(nameNode)+"'") + [rtx_pointcut_parameters(params)] #continue(sError, "Missing ';' ending pointcut declaration.") ';' ; @@ -165,9 +165,12 @@ rtx_scoped_identifier(theParams#back) ; -rtx_pointcut_parameter(theParams : node) ::= +rtx_pointcut_parameters(theParams : node) ::= '(' - [ rtx_pointcut_param(theParams) [ ',' rtx_pointcut_param(theParams) ]* ]? + [ + rtx_pointcut_param(theParams) + [ ',' rtx_pointcut_param(theParams) ]* + ]? ')' ; diff --git a/rathaxes/compiler/passes/back/rtxMeta.inc.cws b/rathaxes/compiler/passes/back/rtxMeta.inc.cws --- a/rathaxes/compiler/passes/back/rtxMeta.inc.cws +++ b/rathaxes/compiler/passes/back/rtxMeta.inc.cws @@ -278,7 +278,7 @@ tpl_pointcut(thePointcut : node) ::= "pointcut" -/**/ =>local pointcutId; +/**/ => local pointcutId; /**/ => local theParams; /**/ => local theDefault; /**/ #check(rtxNodePointcut(thePointcut, pointcutId, theParams, theDefault))