summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2015-03-26 21:35:12 +0800
committerJohn Hodge <tpg@mutabah.net>2015-03-26 21:35:12 +0800
commitc27addebd43d2b1df6dbfed16219336cb7a6867f (patch)
tree79b9ba1d4fad04b18ff34ac92f5eb9d31a1efebf /src
parent9b0293091f4da82d37a5b13c2b4110c09190a451 (diff)
downloadmrust-c27addebd43d2b1df6dbfed16219336cb7a6867f.tar.gz
Comment headers and readme update
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp8
-rw-r--r--src/parse/common.hpp14
-rw-r--r--src/parse/expr.cpp10
-rw-r--r--src/parse/lex.cpp17
-rw-r--r--src/parse/lex.hpp7
-rw-r--r--src/parse/parseerror.cpp5
-rw-r--r--src/parse/root.cpp9
7 files changed, 58 insertions, 12 deletions
diff --git a/src/main.cpp b/src/main.cpp
index f7748b14..85224156 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,4 +1,9 @@
/*
+ * MRustC - Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * main.cpp
+ * - Compiler Entrypoint
*/
#include <iostream>
#include <string>
@@ -28,6 +33,7 @@ int main(int argc, char *argv[])
{
AST_InitProvidedModule();
+ // Hacky command-line parsing
const char *infile = NULL;
::std::string outfile;
const char *crate_path = ".";
@@ -88,8 +94,6 @@ int main(int argc, char *argv[])
outfile += ".o";
}
- //Serialiser_TextTree s_tt(::std::cout);
- //Serialiser& s = s_tt;
try
{
g_cur_phase = "Parse";
diff --git a/src/parse/common.hpp b/src/parse/common.hpp
index d701f45a..0ee430af 100644
--- a/src/parse/common.hpp
+++ b/src/parse/common.hpp
@@ -1,3 +1,10 @@
+/*
+ * MRustC - Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * parse/common.hpp
+ * - Common definitions used by the parser
+ */
#ifndef PARSE_COMMON_HPP_INCLUDED
#define PARSE_COMMON_HPP_INCLUDED
#include <iostream>
@@ -18,22 +25,21 @@
} \
} while(0)
+// --- path.cpp
enum eParsePathGenericMode
{
PATH_GENERIC_NONE,
PATH_GENERIC_EXPR,
PATH_GENERIC_TYPE
};
-
-extern AST::MetaItem Parse_MetaItem(TokenStream& lex);
extern AST::Path Parse_Path(TokenStream& lex, eParsePathGenericMode generic_mode); // Auto-determines
extern AST::Path Parse_Path(TokenStream& lex, bool is_abs, eParsePathGenericMode generic_mode);
extern AST::Path Parse_PathFrom(TokenStream& lex, AST::Path src, eParsePathGenericMode generic_mode);
extern ::std::vector<TypeRef> Parse_Path_GenericList(TokenStream& lex);
-extern TypeRef Parse_Type(TokenStream& lex);
-
+extern AST::MetaItem Parse_MetaItem(TokenStream& lex);
+extern TypeRef Parse_Type(TokenStream& lex);
extern AST::Pattern Parse_Pattern(TokenStream& lex, bool is_refutable);
extern void Parse_Use(TokenStream& lex, ::std::function<void(AST::Path, ::std::string)> fcn);
diff --git a/src/parse/expr.cpp b/src/parse/expr.cpp
index 61678eea..32fd171e 100644
--- a/src/parse/expr.cpp
+++ b/src/parse/expr.cpp
@@ -1,4 +1,14 @@
/*
+ * MRustC - Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * parse/expr.cpp
+ * - Expression (i.e. code) parsing
+ *
+ * Start points:
+ * - Parse_ExprBlockNode : Parses a block
+ * - Parse_Stmt : Parse a single statement
+ * - Parse_Expr0 : Parse a single expression
*/
#include "parseerror.hpp"
#include "../ast/ast.hpp"
diff --git a/src/parse/lex.cpp b/src/parse/lex.cpp
index 34a2ff58..c81c3149 100644
--- a/src/parse/lex.cpp
+++ b/src/parse/lex.cpp
@@ -1,9 +1,14 @@
/*
- * "MRustC" - Primitive rust compiler in C++
- */
-/**
- * \file parse/lex.cpp
- * \brief Low-level lexer
+ * MRustC - Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * parse/lex.cpp
+ * - Lexer (converts input file to token stream)
+ *
+ * Provides:
+ * - Lexer : The file->token lexer
+ * - TTStream : A stream of tokens from a TokenTree
+ * - TokenStream : Common interface for all token streams
*/
#include "lex.hpp"
#include "tokentree.hpp"
@@ -31,7 +36,7 @@ Lexer::Lexer(::std::string filename):
#define SINGLEQUOTE -3
#define DOUBLEQUOTE -4
-// NOTE: This array must be kept reverse sorted
+// NOTE: This array must be kept sorted, or symbols are will be skipped
#define TOKENT(str, sym) {sizeof(str)-1, str, sym}
static const struct {
unsigned char len;
diff --git a/src/parse/lex.hpp b/src/parse/lex.hpp
index aa5ed623..0dab9a24 100644
--- a/src/parse/lex.hpp
+++ b/src/parse/lex.hpp
@@ -1,3 +1,10 @@
+/*
+ * MRustC - Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * parse/lex.hpp
+ * - Lexer header
+ */
#ifndef LEX_HPP_INCLUDED
#define LEX_HPP_INCLUDED
diff --git a/src/parse/parseerror.cpp b/src/parse/parseerror.cpp
index 3905ae33..01c8cced 100644
--- a/src/parse/parseerror.cpp
+++ b/src/parse/parseerror.cpp
@@ -1,4 +1,9 @@
/*
+ * MRustC - Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * parse/parseerror.cpp
+ * - Exceptions thrown for different types of parsing errors
*/
#include "parseerror.hpp"
#include <iostream>
diff --git a/src/parse/root.cpp b/src/parse/root.cpp
index c7518422..3bf43e1f 100644
--- a/src/parse/root.cpp
+++ b/src/parse/root.cpp
@@ -1,4 +1,13 @@
/*
+ * MRustC - Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * parse/root.cpp
+ * - Parsing at the module level (highest-level parsing)
+ *
+ * Entrypoint:
+ * - Parse_Crate : Handles crate attrbutes, and passes on to Parse_ModRoot
+ * - Parse_ModRoot
*/
#include "../ast/ast.hpp"
#include "parseerror.hpp"