From d6daa8e5b30f918766fa75f3540ca8cf9e5bbab5 Mon Sep 17 00:00:00 2001 From: apio Date: Wed, 8 Jun 2022 19:59:14 +0200 Subject: [PATCH] Documentation Project is working well!! --- src/Location.h | 11 +++++++++++ src/Normalizer.h | 8 ++++++-- src/replace.h | 1 + 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Location.h b/src/Location.h index fae8df0..62d3df9 100644 --- a/src/Location.h +++ b/src/Location.h @@ -2,23 +2,34 @@ #include #include +/* Struct to represent a location in a file. */ struct Location { int line; int column; std::string fname; + /* The location at which this location was imported, for error traces in imported files. */ std::shared_ptr parent = nullptr; + /* Creates a Location with the given parameters. */ Location(int ln, int col, std::string file); + ~Location(); + /* Returns a string of the format FILE:LINE:COL. */ std::string to_string() const; + /* Returns a string of the format (FILE:LINE:COL). */ std::string to_parenthesized_string() const; + + /* Advance to the next column in the file. */ void advance(); + + /* Advance to the next line if provided a newline. */ void pos_from_char(const char& character); void operator=(const Location& other); + /* Copies the other location into this one. */ void copy(const Location& other); }; diff --git a/src/Normalizer.h b/src/Normalizer.h index 49daec6..3db55b0 100644 --- a/src/Normalizer.h +++ b/src/Normalizer.h @@ -1,10 +1,14 @@ -// Normalizer: take token stream and remove NULL tokens + convert > and = into >= and similar #pragma once #include "Token.h" #include "Lexer.h" // for TokenStream - +/* Namespace to normalize a TokenStream. */ namespace Normalizer { + /* Some tokens are difficult for the Lexer to parse right, or maybe I'm just lazy. + Anyways, this function transforms > and = tokens next to each other into a single >=, which has a different meaning, etc... + For example: = + = : ==, < + = : <=... + + It also takes blank tokens and removes them. */ TokenStream normalize(const TokenStream& input); } diff --git a/src/replace.h b/src/replace.h index 0cd845b..bac4d40 100644 --- a/src/replace.h +++ b/src/replace.h @@ -1,4 +1,5 @@ #pragma once #include +/* Simple function to replace a substring in a string. */ bool replace(std::string& str, const std::string& from, const std::string& to); \ No newline at end of file