comparison 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
comparison
equal deleted inserted replaced
20:ecf2a0e61fff 27:7f879b938ead
1 # HG changeset patch
2 # Parent 33bf887e240c8c5aa843193ac5ec24663dc7eb8b
3 Add #include in template chunks
4
5 diff --git a/rathaxes/compiler/rtxParse/rtx.cwp b/rathaxes/compiler/rtxParse/rtx.cwp
6 --- a/rathaxes/compiler/rtxParse/rtx.cwp
7 +++ b/rathaxes/compiler/rtxParse/rtx.cwp
8 @@ -1,11 +1,22 @@
9 #include "cnorm.cwp"
10
11 +#ignore["rathaxes"] ::=
12 +[
13 + ["//" ->[['\r']? '\n']]
14 + | ["/*" ->"*/"]
15 + | ' '
16 + | '\t'
17 + | '\n'
18 + | '\r'
19 + | '\f' // form feed, sometimes Windows kernel headers have this character.
20 +]+:skip
21 +;
22 /* root of grammar */
23 #overload
24 translation_unit ::=
25 => traceLine("PARSE!");
26 #try
27 - #ignore
28 + #ignore("rathaxes")
29 #check(cnormNodeRoot(this))
30 [
31 rtx_declaration(this)
32 diff --git a/rathaxes/compiler/rtxParse/rtxBack.cwp b/rathaxes/compiler/rtxParse/rtxBack.cwp
33 --- a/rathaxes/compiler/rtxParse/rtxBack.cwp
34 +++ b/rathaxes/compiler/rtxParse/rtxBack.cwp
35 @@ -189,7 +189,32 @@
36 /* The two following lines prevent artefacts (by failing previous alternative) */
37 =>clearVariable(theBody);
38 #check(cnormNodeBlock(theBody))
39 - compound_statement(theBody)
40 + rtx_chunk_compound_statement(theBody)
41 +;
42 +
43 +rtx_chunk_compound_statement(theBlock : node) ::=
44 +'{'
45 +/**/ #check(cnormNodeBlock(theBlock, true))
46 + rtx_chunk_block_item_list(theBlock)
47 +'}'
48 +;
49 +
50 +rtx_chunk_block_item_list(theBlock : node) ::=
51 +[
52 + line_of_code(theBlock)
53 + | '#'
54 + [// TODO: Add Define with chunks variables detections/substitutions
55 + "include"
56 + [
57 + ['"' -> '"' | '<' -> '>' ]:sFile
58 + ]
59 +/**/ #pushItem(theBlock.block)
60 +/**/ => local lastNode;
61 +/**/ #check(cnormNodeBlock_GetLastNode(theBlock, lastNode))
62 +/**/ => local sData = "\n#include " + sFile + " \n";
63 +/**/ => cnormNode_Raw(lastNode, sData);
64 + ]
65 +]*
66 ;
67
68 rtx_stmt<"chunk">(theBlock : node) ::=
69 diff --git a/rathaxes/compiler/rtxTpl/rtxIntrospect.inc.cws b/rathaxes/compiler/rtxTpl/rtxIntrospect.inc.cws
70 --- a/rathaxes/compiler/rtxTpl/rtxIntrospect.inc.cws
71 +++ b/rathaxes/compiler/rtxTpl/rtxIntrospect.inc.cws
72 @@ -469,6 +469,10 @@
73 * Expression type code introspection function
74 *
75 */
76 +function rtxIntrospect_expr<"__raw__">(local_node : node, theChunk : node, blockIds : node)
77 +{/*nothing to do*/
78 +}
79 +
80 function rtxIntrospect_expr<"__terminal__">(local_node : node, theChunk : node,
81 blockIds : node)
82 {
83 diff --git a/rathaxes/samples/helloworld/main.blt b/rathaxes/samples/helloworld/main.blt
84 --- a/rathaxes/samples/helloworld/main.blt
85 +++ b/rathaxes/samples/helloworld/main.blt
86 @@ -44,7 +44,6 @@
87 {
88 chunk Main::include_headers
89 {
90 - /* Won't be printed because # is not supported yet */
91 #include <stdlib.h>
92 typedef int stdlib_include_stamp;
93 }