how to build a RDP?

closed account (Dy7SLyTq)
so i was pointed to a few tutorials, and googled it myself, but every single tutorial on how to build a recursive descent parser was either about parsing mathematical expressions, or using symbols that i cant type on my keyboard with what im assuming are like college level terms. i fleshed out a header with what i think is the basis, but how would i write the actual code.
*side note*: the reason why the math parsers dont work is because it can take it character by character and i will be using terminals like println, if, for, etc...

heres my code so far (Parser.hpp)
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
#ifndef __DTSPARSER_
#define __DTSPARSER_

#include <iostream>
#include <fstream>
#include <vector>
#include <string>

using std::ifstream;
using std::vector;
using std::string;

namespace DTS
{
	class Parser
	{
		public:
			Parser(string&);

			void ParseToken();
			void ParseComment();
			void ParseStream();
			void ParseString();

			void ReadLine();
			void GetErrorCode(int);
			void PrintError()

		private:
			ifstream File;
			string Line;
			int CurrentLine, CurrentColumn;
			vector<string> ErrorList;
	};

	bool CorrectFileType(char*);
	bool FileExists(char*);
	bool GoodFile(char*);
}

#endif 
Do you want to write a general purpose parser, or have you already figured out the grammar you want?
Topic archived. No new replies allowed.