From c27addebd43d2b1df6dbfed16219336cb7a6867f Mon Sep 17 00:00:00 2001 From: John Hodge Date: Thu, 26 Mar 2015 21:35:12 +0800 Subject: Comment headers and readme update --- src/main.cpp | 8 ++++++-- src/parse/common.hpp | 14 ++++++++++---- src/parse/expr.cpp | 10 ++++++++++ src/parse/lex.cpp | 17 +++++++++++------ src/parse/lex.hpp | 7 +++++++ src/parse/parseerror.cpp | 5 +++++ src/parse/root.cpp | 9 +++++++++ 7 files changed, 58 insertions(+), 12 deletions(-) (limited to 'src') 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 #include @@ -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 @@ -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 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 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 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" -- cgit v1.2.3