summaryrefslogtreecommitdiffstats
path: root/feed/sse_lex_c.l
diff options
context:
space:
mode:
Diffstat (limited to 'feed/sse_lex_c.l')
-rw-r--r--feed/sse_lex_c.l78
1 files changed, 44 insertions, 34 deletions
diff --git a/feed/sse_lex_c.l b/feed/sse_lex_c.l
index 52f46a7..4674b73 100644
--- a/feed/sse_lex_c.l
+++ b/feed/sse_lex_c.l
@@ -4,6 +4,48 @@
#include <stdio.h>
+static void print_with_subwords(const char *w) {
+ const char *e;
+
+ printf("%s\n", w);
+
+ if ((e = strchr(w, '_'))) {
+
+ /* Split at dashes.*/
+
+ do {
+ for (; *e == '_'; e++);
+
+ if (strlen(e) < 3)
+ break;
+
+ printf("S:%s\n", e);
+
+ e = strchr(e, '_');
+ } while (e);
+
+ } else {
+
+ /* Split a place where an uppercase letter follows a lowercase
+ * letter */
+
+ e = w;
+ for (;;) {
+ for (; *e && !(islower(*e) && isupper(*(e+1))); e++);
+
+ if (!*e)
+ break;
+
+ e++;
+
+ if (strlen(e) < 3)
+ break;
+
+ printf("S:%s\n", e);
+ }
+ }
+
+}
%}
@@ -46,40 +88,7 @@ NIDCHAR [^_a-zA-Z0-9]
<CHAR>. ;
<CHARESC>. { BEGIN CHAR; }
-<DEF>auto{NIDCHAR} |
-<DEF>break{NIDCHAR} |
-<DEF>case{NIDCHAR} |
-<DEF>char{NIDCHAR} |
-<DEF>const{NIDCHAR} |
-<DEF>continue{NIDCHAR} |
-<DEF>default{NIDCHAR} |
-<DEF>do{NIDCHAR} |
-<DEF>double{NIDCHAR} |
-<DEF>else{NIDCHAR} |
-<DEF>enum{NIDCHAR} |
-<DEF>extern{NIDCHAR} |
-<DEF>float{NIDCHAR} |
-<DEF>for{NIDCHAR} |
-<DEF>goto{NIDCHAR} |
-<DEF>if{NIDCHAR} |
-<DEF>int{NIDCHAR} |
-<DEF>long{NIDCHAR} |
-<DEF>register{NIDCHAR} |
-<DEF>return{NIDCHAR} |
-<DEF>short{NIDCHAR} |
-<DEF>signed{NIDCHAR} |
-<DEF>sizeof{NIDCHAR} |
-<DEF>static{NIDCHAR} |
-<DEF>struct{NIDCHAR} |
-<DEF>switch{NIDCHAR} |
-<DEF>typedef{NIDCHAR} |
-<DEF>union{NIDCHAR} |
-<DEF>unsigned{NIDCHAR} |
-<DEF>void{NIDCHAR} |
-<DEF>volatile{NIDCHAR} |
-<DEF>while{NIDCHAR} { yyless(yyleng-1); }
-
-<DEF>[a-zA-Z_][a-zA-Z_0-9]{3,} { printf("%s\n", yytext); }
+<DEF>[a-zA-Z_][a-zA-Z_0-9]{3,} { print_with_subwords(yytext); }
<DEF>[0-9]+ ;
<DEF>0x[0-9a-fA-F]+ ;
@@ -89,6 +98,7 @@ NIDCHAR [^_a-zA-Z0-9]
%%
+
int main(int argc, char *argv[]) {
if (argc <= 1)