File: foolisptest.cpp

package info (click to toggle)
kdevelop-pg-qt 2.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,284 kB
  • sloc: cpp: 22,743; lex: 928; ansic: 716; yacc: 615; ruby: 68; sh: 14; lisp: 10; fortran: 6; makefile: 2
file content (36 lines) | stat: -rw-r--r-- 898 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
#include "foolispparser.h"
#include "foolisplexer.h"
#include "foolispdebugvisitor.h"
#include "foolisptokentext.h"

using namespace FooLisp;
using namespace KDevPG;

#include <iostream>
using namespace std;

int main()
{
  string str;
  getline(cin, str);
  QByteArray qcode(str.c_str(), str.size());
  QUtf8ToUcs4Iterator iter(qcode);
  qDebug() << qcode.size() << iter.hasNext();
  FooLisp::Lexer lex(iter);
  qDebug() << iter.hasNext();
  FooLisp::Parser parser;
  KDevPG::MemoryPool pool;
  parser.setMemoryPool(&pool);
  parser.setTokenStream(&lex);
  int kind;
  qDebug() << iter.hasNext();
  while((kind = lex.read().kind) != Parser::Token_EOF)
    qDebug() << "hi" << tokenText(kind);
  parser.rewind(0);
  StartAst *ast;
  parser.parseStart(&ast);
  DebugVisitor vis(&lex, QString::fromUtf8(qcode));
  vis.visitNode(ast);
  qDebug() << ast->sexp;
  qDebug() << ast->sexp->sexpSequence;
}