File: op.g

package info (click to toggle)
kdevelop-pg-qt 1.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 6,144 kB
  • ctags: 3,624
  • sloc: cpp: 19,239; lex: 945; ansic: 716; yacc: 615; ruby: 68; sh: 14; lisp: 10; fortran: 6; makefile: 3
file content (40 lines) | stat: -rw-r--r-- 1,141 bytes parent folder | download | duplicates (4)
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
[:
#include <QtCore/QString>
#include <kdebug.h>
:]

%parserclass (protected declaration)
[:
void expectedSymbol(Op::AstNode::AstNodeKind kind, const QString& name);
void expectedToken(int kind, enum TokenType tok, const QString& name);
:]

%token PLUS ("+"), MUL ("*"), INV ("-"), NUM ("123"), POW ("^"), BR ("BREAK"), NOT ("NOT"), L_PAREN ("("), R_PAREN (")"), QUESTION ("?"), COLON (":") ;;

   #expr=expr @ BR
-> document ;;

   NUM
-> number ;;

%< number
%bin PLUS 2 %left
%bin MUL 4 %left
%pre NOT 3
%post INV 1
%bin POW 5 %right
%paren L_PAREN R_PAREN
%tern QUESTION COLON 1 %left
%> expr ;;

[:
#include "Optokentext.h"

namespace Op
{

void Parser::expectedSymbol(Op::AstNode::AstNodeKind kind, const QString& name) { kDebug() << "In AstNode " << kind << ": Expected symbol " << name << " Token: " << tokenText(yytoken) << "(" << yytoken << ", \"" << "\"). Position: " << tokenStream->index(); abort();  }
void Parser::expectedToken(int kind, enum TokenType tok, const QString& name) { kDebug() << "Read Token: " << tokenText(kind) << "(" << kind << ", \"" << "\"). Expected token " << name << " (" << tok << ")"; abort(); }

}
:]