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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
#pragma once
#include "Compiler/Reader.h"
#include "Compiler/FileReader.h"
#include "Core/Str.h"
#include "Lookup.h"
#include "Content.h"
namespace storm {
namespace bs {
STORM_PKG(lang.bs);
// Entry point for the syntax language.
PkgReader *STORM_FN reader(Array<Url *> *files, Package *pkg) ON(Compiler);
/**
* First stage reader for Basic Storm. At this stage we read the use statements to figure
* out which syntax to include in the rest of the file.
*/
class UseReader : public FileReader {
STORM_CLASS;
public:
// Create.
STORM_CTOR UseReader(FileInfo *info);
// Create parser.
virtual syntax::InfoParser *STORM_FN createParser();
// No types or anything in here.
protected:
// Create the next part.
virtual MAYBE(FileReader *) STORM_FN createNext(ReaderQuery q);
};
/**
* Second stage reader for Basic Storm. Here, we receive all includes from the previous
* state and read the rest of the file.
*/
class CodeReader : public FileReader {
STORM_CLASS;
public:
// Create. If the flag 'qParser' is set in 'query', then we will not complain about
// non-existing packages in order to provide a better interactive experience.
STORM_CTOR CodeReader(FileInfo *info, Array<SrcName *> *includes, ReaderQuery query);
// Create parser.
virtual syntax::InfoParser *STORM_FN createParser();
// Get types.
void STORM_FN readTypes();
// Update inheritance.
void STORM_FN resolveTypes();
// Get functions.
void STORM_FN readFunctions();
// Resolve functions.
void STORM_FN resolveFunctions();
// Current scope.
Scope scope;
private:
// Content.
Content *content;
// Read content from the file.
void readContent();
};
}
}
|