File: Reader.h

package info (click to toggle)
storm-lang 0.7.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 52,004 kB
  • sloc: ansic: 261,462; cpp: 140,405; sh: 14,891; perl: 9,846; python: 2,525; lisp: 2,504; asm: 860; makefile: 678; pascal: 70; java: 52; xml: 37; awk: 12
file content (73 lines) | stat: -rw-r--r-- 1,758 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
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();
		};

	}
}