Mercurial > archived > louis > epitech > mq > rathaxes
view include_in_template_chunks.patch @ 27:7f879b938ead
Added Patch #include
author | lionel auroux <lionel.auroux@gmail.com> |
---|---|
date | Sat, 07 Jan 2012 20:46:46 +0100 |
parents | |
children |
line wrap: on
line source
# HG changeset patch # Parent 33bf887e240c8c5aa843193ac5ec24663dc7eb8b Add #include in template chunks diff --git a/rathaxes/compiler/rtxParse/rtx.cwp b/rathaxes/compiler/rtxParse/rtx.cwp --- a/rathaxes/compiler/rtxParse/rtx.cwp +++ b/rathaxes/compiler/rtxParse/rtx.cwp @@ -1,11 +1,22 @@ #include "cnorm.cwp" +#ignore["rathaxes"] ::= +[ + ["//" ->[['\r']? '\n']] + | ["/*" ->"*/"] + | ' ' + | '\t' + | '\n' + | '\r' + | '\f' // form feed, sometimes Windows kernel headers have this character. +]+:skip +; /* root of grammar */ #overload translation_unit ::= => traceLine("PARSE!"); #try - #ignore + #ignore("rathaxes") #check(cnormNodeRoot(this)) [ rtx_declaration(this) diff --git a/rathaxes/compiler/rtxParse/rtxBack.cwp b/rathaxes/compiler/rtxParse/rtxBack.cwp --- a/rathaxes/compiler/rtxParse/rtxBack.cwp +++ b/rathaxes/compiler/rtxParse/rtxBack.cwp @@ -189,7 +189,32 @@ /* The two following lines prevent artefacts (by failing previous alternative) */ =>clearVariable(theBody); #check(cnormNodeBlock(theBody)) - compound_statement(theBody) + rtx_chunk_compound_statement(theBody) +; + +rtx_chunk_compound_statement(theBlock : node) ::= +'{' +/**/ #check(cnormNodeBlock(theBlock, true)) + rtx_chunk_block_item_list(theBlock) +'}' +; + +rtx_chunk_block_item_list(theBlock : node) ::= +[ + line_of_code(theBlock) + | '#' + [// TODO: Add Define with chunks variables detections/substitutions + "include" + [ + ['"' -> '"' | '<' -> '>' ]:sFile + ] +/**/ #pushItem(theBlock.block) +/**/ => local lastNode; +/**/ #check(cnormNodeBlock_GetLastNode(theBlock, lastNode)) +/**/ => local sData = "\n#include " + sFile + " \n"; +/**/ => cnormNode_Raw(lastNode, sData); + ] +]* ; rtx_stmt<"chunk">(theBlock : node) ::= diff --git a/rathaxes/compiler/rtxTpl/rtxIntrospect.inc.cws b/rathaxes/compiler/rtxTpl/rtxIntrospect.inc.cws --- a/rathaxes/compiler/rtxTpl/rtxIntrospect.inc.cws +++ b/rathaxes/compiler/rtxTpl/rtxIntrospect.inc.cws @@ -469,6 +469,10 @@ * Expression type code introspection function * */ +function rtxIntrospect_expr<"__raw__">(local_node : node, theChunk : node, blockIds : node) +{/*nothing to do*/ +} + function rtxIntrospect_expr<"__terminal__">(local_node : node, theChunk : node, blockIds : node) { diff --git a/rathaxes/samples/helloworld/main.blt b/rathaxes/samples/helloworld/main.blt --- a/rathaxes/samples/helloworld/main.blt +++ b/rathaxes/samples/helloworld/main.blt @@ -44,7 +44,6 @@ { chunk Main::include_headers { - /* Won't be printed because # is not supported yet */ #include <stdlib.h> typedef int stdlib_include_stamp; }