Commit 964b7194 by alokp@chromium.org

Fixed compile error in lexer_glue.cpp.

git-svn-id: https://angleproject.googlecode.com/svn/trunk@1089 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 99b5c0c9
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
'compiler/preprocessor/new/ExpressionParser.h', 'compiler/preprocessor/new/ExpressionParser.h',
'compiler/preprocessor/new/Input.cpp', 'compiler/preprocessor/new/Input.cpp',
'compiler/preprocessor/new/Input.h', 'compiler/preprocessor/new/Input.h',
'compiler/preprocessor/new/Lexer.cpp',
'compiler/preprocessor/new/Lexer.h', 'compiler/preprocessor/new/Lexer.h',
'compiler/preprocessor/new/MacroExpander.cpp', 'compiler/preprocessor/new/MacroExpander.cpp',
'compiler/preprocessor/new/MacroExpander.h', 'compiler/preprocessor/new/MacroExpander.h',
......
...@@ -12,12 +12,25 @@ extern "C" { ...@@ -12,12 +12,25 @@ extern "C" {
#include "compiler/preprocessor/slglobals.h" #include "compiler/preprocessor/slglobals.h"
#include "compiler/preprocessor/scanner.h" #include "compiler/preprocessor/scanner.h"
} }
#include "compiler/preprocessor/new/Lexer.h" #include "compiler/preprocessor/new/Diagnostics.h"
#include "compiler/preprocessor/new/Token.h" #include "compiler/preprocessor/new/Token.h"
#include "compiler/preprocessor/new/Tokenizer.h"
class Diagnostics : public pp::Diagnostics
{
protected:
virtual void print(ID id,
const pp::SourceLocation& loc,
const std::string& text)
{
// TODO(alokp): Implement me.
}
};
struct InputSrcLexer struct InputSrcLexer
{ {
InputSrc base; InputSrc base;
pp::Diagnostics* diagnostics;
pp::Lexer* lexer; pp::Lexer* lexer;
}; };
...@@ -36,12 +49,14 @@ static int lex(InputSrc* in, yystypepp* yylvalpp) ...@@ -36,12 +49,14 @@ static int lex(InputSrc* in, yystypepp* yylvalpp)
{ {
InputSrcLexer* src = ((InputSrcLexer *)in); InputSrcLexer* src = ((InputSrcLexer *)in);
int ret = 0;
pp::Token token; pp::Token token;
int ret = src->lexer->lex(&token); src->lexer->lex(&token);
switch (ret) switch (token.type)
{ {
case 0: // EOF case 0: // EOF
delete src->lexer; delete src->lexer;
delete src->diagnostics;
free(src); free(src);
cpp->currentInput = 0; cpp->currentInput = 0;
ret = EOF; ret = EOF;
...@@ -134,10 +149,12 @@ static int lex(InputSrc* in, yystypepp* yylvalpp) ...@@ -134,10 +149,12 @@ static int lex(InputSrc* in, yystypepp* yylvalpp)
InputSrc* LexerInputSrc(int count, const char* const string[], const int length[]) InputSrc* LexerInputSrc(int count, const char* const string[], const int length[])
{ {
pp::Lexer* lexer = new pp::Lexer; Diagnostics* diagnostics = new Diagnostics;
pp::Tokenizer* lexer = new pp::Tokenizer(diagnostics);
if (!lexer->init(count, string, length)) if (!lexer->init(count, string, length))
{ {
delete lexer; delete lexer;
delete diagnostics;
return 0; return 0;
} }
...@@ -145,6 +162,7 @@ InputSrc* LexerInputSrc(int count, const char* const string[], const int length[ ...@@ -145,6 +162,7 @@ InputSrc* LexerInputSrc(int count, const char* const string[], const int length[
memset(in, 0, sizeof(InputSrcLexer)); memset(in, 0, sizeof(InputSrcLexer));
in->base.line = 1; in->base.line = 1;
in->base.scan = lex; in->base.scan = lex;
in->diagnostics = diagnostics;
in->lexer = lexer; in->lexer = lexer;
return &in->base; return &in->base;
......
...@@ -11,6 +11,10 @@ ...@@ -11,6 +11,10 @@
namespace pp namespace pp
{ {
Diagnostics::~Diagnostics()
{
}
void Diagnostics::report(ID id, void Diagnostics::report(ID id,
const SourceLocation& loc, const SourceLocation& loc,
const std::string& text) const std::string& text)
......
...@@ -38,6 +38,8 @@ class Diagnostics ...@@ -38,6 +38,8 @@ class Diagnostics
WARNING_END WARNING_END
}; };
virtual ~Diagnostics();
void report(ID id, const SourceLocation& loc, const std::string& text); void report(ID id, const SourceLocation& loc, const std::string& text);
protected: protected:
......
//
// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
#include "Lexer.h"
namespace pp
{
Lexer::~Lexer()
{
}
} // namespace pp
...@@ -7,9 +7,6 @@ ...@@ -7,9 +7,6 @@
#ifndef COMPILER_PREPROCESSOR_LEXER_H_ #ifndef COMPILER_PREPROCESSOR_LEXER_H_
#define COMPILER_PREPROCESSOR_LEXER_H_ #define COMPILER_PREPROCESSOR_LEXER_H_
#include <cassert>
#include <vector>
namespace pp namespace pp
{ {
...@@ -18,6 +15,8 @@ struct Token; ...@@ -18,6 +15,8 @@ struct Token;
class Lexer class Lexer
{ {
public: public:
virtual ~Lexer();
virtual void lex(Token* token) = 0; virtual void lex(Token* token) = 0;
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment