Documentation Project is working well!!
This commit is contained in:
parent
9b217037c8
commit
d6daa8e5b3
@ -2,23 +2,34 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
/* Struct to represent a location in a file. */
|
||||||
struct Location
|
struct Location
|
||||||
{
|
{
|
||||||
int line;
|
int line;
|
||||||
int column;
|
int column;
|
||||||
std::string fname;
|
std::string fname;
|
||||||
|
|
||||||
|
/* The location at which this location was imported, for error traces in imported files. */
|
||||||
std::shared_ptr<Location> parent = nullptr;
|
std::shared_ptr<Location> parent = nullptr;
|
||||||
|
|
||||||
|
/* Creates a Location with the given parameters. */
|
||||||
Location(int ln, int col, std::string file);
|
Location(int ln, int col, std::string file);
|
||||||
|
|
||||||
~Location();
|
~Location();
|
||||||
|
|
||||||
|
/* Returns a string of the format FILE:LINE:COL. */
|
||||||
std::string to_string() const;
|
std::string to_string() const;
|
||||||
|
/* Returns a string of the format (FILE:LINE:COL). */
|
||||||
std::string to_parenthesized_string() const;
|
std::string to_parenthesized_string() const;
|
||||||
|
|
||||||
|
/* Advance to the next column in the file. */
|
||||||
void advance();
|
void advance();
|
||||||
|
|
||||||
|
/* Advance to the next line if provided a newline. */
|
||||||
void pos_from_char(const char& character);
|
void pos_from_char(const char& character);
|
||||||
|
|
||||||
void operator=(const Location& other);
|
void operator=(const Location& other);
|
||||||
|
|
||||||
|
/* Copies the other location into this one. */
|
||||||
void copy(const Location& other);
|
void copy(const Location& other);
|
||||||
};
|
};
|
||||||
|
@ -1,10 +1,14 @@
|
|||||||
// Normalizer: take token stream and remove NULL tokens + convert > and = into >= and similar
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "Token.h"
|
#include "Token.h"
|
||||||
#include "Lexer.h" // for TokenStream
|
#include "Lexer.h" // for TokenStream
|
||||||
|
|
||||||
|
/* Namespace to normalize a TokenStream. */
|
||||||
namespace Normalizer
|
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);
|
TokenStream normalize(const TokenStream& input);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
/* Simple function to replace a substring in a string. */
|
||||||
bool replace(std::string& str, const std::string& from, const std::string& to);
|
bool replace(std::string& str, const std::string& from, const std::string& to);
|
Loading…
Reference in New Issue
Block a user