forked from gentoo/gentoo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cccc-c_dialect.patch
79 lines (73 loc) · 2 KB
/
cccc-c_dialect.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
diff --git a/cccc/cccc.g b/cccc/cccc.g
index bdb6805..fd7b504 100644
--- a/cccc/cccc.g
+++ b/cccc/cccc.g
@@ -84,6 +84,30 @@ inline void endOfLine(CLexer &lexer)
#token MAC_NL "\r" << endOfLine(*this); >>
#token UNIX_NL "\n" << endOfLine(*this); >>
+/* augment dialect policies -- M.H added */
+#lexclass SKIP_STMT
+#token SKCOLON ";" << skip();mode(START); >>
+#token SKANYTHING "~[; \t\n]" << skip();more();>>
+#token SKNL "\n" << skip();endOfLine(*this);>>
+#token SKBLANK "[ \t]+" << skip(); >>
+#lexclass START
+
+#lexclass SKIP_BLOCK
+#token SK_ANY "[a-zA-Z0-9_]*"
+<<
+std::string treatment =
+ CCCC_Options::dialectKeywordPolicy(parse_language,lextext());
+
+if ( treatment != "stop_skipping" )
+{
+ skip();
+}
+else
+{
+ mode(COMMENT_LINE);skip();
+}
+>>
+#lexclass START
/* preprocessor constructs - comments, #defines etc */
@@ -343,17 +367,29 @@ inline void endOfLine(CLexer &lexer)
if( treatment == "ignore" )
{
skip();
+ //std::cout << toktext << std::endl <<" :ignore" << std::endl;
}
// Ultimately, the next two cases will need to be handled
// using a #lexclass or something similar, for the moment
// we just try to skip the tokens themselves.
else if ( treatment == "start_skipping" )
{
- skip();
+ mode(SKIP_BLOCK);skip();
}
else if ( treatment == "stop_skipping" )
{
- skip();
+ skip(); mode(COMMENT_LINE);
+ //gobble end of line M.H.
+ }
+ else if ( treatment == "skip_line" )//M.H added
+ {
+ mode(COMMENT_LINE);skip();
+ //std::cout << "skip_line" << std::endl;
+ }
+ else if ( treatment == "skip_stmt" )//M.H added
+ {
+ mode(SKIP_STMT);skip();
+ //std::cout << "skip_stmt" << std::endl;
}
>>
@@ -426,8 +462,10 @@ void init(const string& filename, const string& language)
pu=ParseUtility::currentInstance();
ps=ParseStore::currentInstance();
- ANTLRParser::init();
parse_language=language;
+ ANTLRParser::init();
+ //parse_language=language;
+ //move above, M.H.1st otherwise time init not to language
}
>>