File: tree_bison.ll

package info (click to toggle)
foundry 0.0.20130809-2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 632 kB
  • ctags: 2,340
  • sloc: cpp: 6,376; yacc: 366; makefile: 192; lex: 184
file content (73 lines) | stat: -rw-r--r-- 1,894 bytes parent folder | download
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
%{
#include "tree_bison_context.hpp"
#include "tree_bison_cst.hpp"
#include "tree_bison_parse.hpp"
#define YY_USER_ACTION yylloc->first_line = yylloc->last_line = yylineno;
%}

%option nostdinit
/*%option nodefault*/
%option nounput
%option noyywrap
%option reentrant
%option bison-bridge
%option bison-locations
%option yylineno
%option prefix="tree_bison_"
%option header-file="tree_bison_lex.hpp"
%option extra-type="context *"

%x ccomment cfragment action rules

IDENT                   [[:alpha:]_][[:alnum:]_]*

%%

\%\{                    BEGIN(cfragment);
\%\%                    BEGIN(rules);

<INITIAL>{
  \n                    /* ignore */
  .                     /* ignore */
}

<cfragment>{
  \%\}                  BEGIN(INITIAL);
  \n                    /* ignore */
  .                     /* ignore */
}

<action>{
  \{                    ++yyextra->bracecount;
  \}                    if(!--yyextra->bracecount) { BEGIN(rules); }
  \n                    /* ignore */
  .                     /* ignore */
}

<rules>{
  \r                    /* ignore */
  \                     /* ignore */
  \t                    /* ignore */
  \n                    /* ignore */

  ;                     return SEMICOLON;
  \|                    return BAR;
  \{                    yyextra->bracecount = 1; BEGIN(action);

  \/\*-[^-]*-\*\/       yylval->string = strndup(yytext+3, yyleng-6); return NAME_HINT;
  \/\*                  BEGIN(ccomment);

  \"(\\.|[^"])*\"       yylval->string = strdup(yytext); return STRING;
  {IDENT}:              yylval->string = strdup(yytext); yylval->string[yyleng-1] = 0; return IDENTIFIER_COLON;
  {IDENT}               yylval->string = strdup(yytext); return IDENTIFIER;
}

<ccomment>{
  \*\/                  BEGIN(rules);
  \n                    /* ignore */
  .                     /* ignore */
}

%%

/*.                       return INVALID;*/