Warning, /frameworks/syntax-highlighting/autotests/input/highlight.y is written in an unsupported language. File is not indexed.
0001 /* Yacc / Bison hl test file.
0002 * It won't compile :-) Sure !
0003 */
0004
0005 %{
0006
0007 #include <iostream>
0008 using namespace std;
0009
0010 extern KateParser *parser;
0011
0012 %}
0013
0014 %locations
0015
0016 %union {
0017 int int_val;
0018 double double_val;
0019 bool bool_val;
0020 char *string_val;
0021 char *ident_val;
0022 struct var *v;
0023 void *ptr;
0024 }
0025
0026 %token <int_val> TOK_NOT_EQUAL "!="
0027 %token <int_val> TOK_LESSER_E "<="
0028 %token <int_val> TOK_GREATER_E ">="
0029 %token <int_val> TOK_EQUAL_2 "==" //comment
0030 %token
0031 PERCENT_DEBUG "%debug"
0032 PERCENT_DEFAULT_PREC "%default-prec"
0033 PERCENT_DEFINE "%define"
0034 ;
0035
0036 %type <int_val> type type_proc
0037
0038 %code top {
0039 #define _GNU_SOURCE
0040 #include <stdio.h>
0041 int val;
0042 }
0043
0044 %destructor { free ($$); printf ("%d", @$.first_line); } <*>
0045 %lex-param {scanner_mode *mode};
0046 %parse-param {int *nastiness} {int *randomness}
0047 %initial-action {
0048 @$.initialize (file_name);
0049 };
0050
0051 %%
0052
0053 prog: KW_PROGRAM ident { parser->start($2); } prog_beg_glob_decl instructions { parser->endproc(0); } dev_procedures KW_ENDP ;
0054
0055 number: integer_number
0056 | TOK_DOUBLE
0057 {
0058 $$ = new var;
0059 $$->type = KW_REEL;
0060 $$->cl = var::LITTERAL;
0061 $$->real = $<int_val>1;
0062 };
0063 words:
0064 %empty
0065 | words word
0066 ;
0067
0068 %type <type> word;
0069 %printer { fprintf (yyo, "%s", word_string ($$)); } <type>;
0070 word:
0071 %?{ boom(1); }
0072 | "hello" { $$ = hello; }
0073 | "bye" { $$ = bye; }
0074 ;
0075
0076 foo: { $$ = 0 }
0077 | number { $$ = $1 | $2; }
0078 | hello { $$ = $1 | $3; } // without a comma
0079
0080 hello:
0081 gram1 { $$ = "hi" };
0082 | gram2
0083 ;;
0084
0085 %%
0086
0087 #include <stdio.h>
0088
0089 int main(void)
0090 {
0091 puts("Hello, World!");
0092 return 0;
0093 }
0094
0095 // ALERT NOTE