* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FLEX_BISON_SCANNER_H
#define FLEX_BISON_SCANNER_H
#include <cstring>
#include "script_utils.h"
#if !defined(yyFlexLexerOnce)
#undef yyFlexLexer
#define yyFlexLexer script_FlexLexer
#include "FlexLexer.h"
#endif
#include "parser.hpp"
#undef YY_DECL
#define YY_DECL Uscript::Parser::symbol_type Uscript::Scanner::nextToken()
namespace Uscript {
class ScriptInterpreter;
class Scanner : public yyFlexLexer {
public:
explicit Scanner(ScriptInterpreter* interpreter)
{
loc = location();
}
~Scanner() override {}
virtual Uscript::Parser::symbol_type nextToken();
int yywrap() override
{
return 1;
}
int LexerInput(char* buf, int maxSize) override;
void SetPkgStream(Hpackage::PkgManager::StreamPtr pkgStream)
{
pkgStream_ = pkgStream;
}
private:
Hpackage::PkgManager::StreamPtr pkgStream_ = nullptr;
size_t currPos = 0;
location loc {};
};
}
#endif