Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Lang] Keeps comments and prints them out when possible #349

Merged
merged 3 commits into from
May 31, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[Lint] Splits token into its own file like expr and statement
  • Loading branch information
dmed256 committed May 31, 2020
commit b4dcd3a0380fad8a30de70f76862ab790fd1ccf5
426 changes: 16 additions & 410 deletions include/occa/lang/token.hpp

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions include/occa/lang/token/charToken.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#ifndef OCCA_LANG_TOKEN_CHARTOKEN_HEADER
#define OCCA_LANG_TOKEN_CHARTOKEN_HEADER

#include <occa/lang/token/token.hpp>

namespace occa {
namespace lang {
class charToken : public token_t {
public:
int encoding;
std::string value;
std::string udf;

charToken(const fileOrigin &origin_,
int encoding_,
const std::string &value_,
const std::string &udf_);

virtual ~charToken();

virtual int type() const;

virtual token_t* clone() const;

virtual void print(io::output &out) const;
};
}
}

#endif
26 changes: 26 additions & 0 deletions include/occa/lang/token/commentToken.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#ifndef OCCA_LANG_TOKEN_COMMENTTOKEN_HEADER
#define OCCA_LANG_TOKEN_COMMENTTOKEN_HEADER

#include <occa/lang/token/token.hpp>

namespace occa {
namespace lang {
class commentToken : public token_t {
public:
std::string value;

commentToken(const fileOrigin &origin_,
const std::string &value_);

virtual ~commentToken();

virtual int type() const;

virtual token_t* clone() const;

virtual void print(io::output &out) const;
};
}
}

#endif
26 changes: 26 additions & 0 deletions include/occa/lang/token/directiveToken.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#ifndef OCCA_LANG_TOKEN_DIRECTIVETOKEN_HEADER
#define OCCA_LANG_TOKEN_DIRECTIVETOKEN_HEADER

#include <occa/lang/token/token.hpp>

namespace occa {
namespace lang {
class directiveToken : public token_t {
public:
std::string value;

directiveToken(const fileOrigin &origin_,
const std::string &value_);

virtual ~directiveToken();

virtual int type() const;

virtual token_t* clone() const;

virtual void print(io::output &out) const;
};
}
}

#endif
26 changes: 26 additions & 0 deletions include/occa/lang/token/functionToken.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#ifndef OCCA_LANG_TOKEN_FUNCTIONTOKEN_HEADER
#define OCCA_LANG_TOKEN_FUNCTIONTOKEN_HEADER

#include <occa/lang/token/token.hpp>

namespace occa {
namespace lang {
class functionToken : public token_t {
public:
function_t &value;

functionToken(const fileOrigin &origin_,
function_t &function);

virtual ~functionToken();

virtual int type() const;

virtual token_t* clone() const;

virtual void print(io::output &out) const;
};
}
}

#endif
26 changes: 26 additions & 0 deletions include/occa/lang/token/identifierToken.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#ifndef OCCA_LANG_TOKEN_IDENTIFIERTOKEN_HEADER
#define OCCA_LANG_TOKEN_IDENTIFIERTOKEN_HEADER

#include <occa/lang/token/token.hpp>

namespace occa {
namespace lang {
class identifierToken : public token_t {
public:
std::string value;

identifierToken(const fileOrigin &origin_,
const std::string &value_);

virtual ~identifierToken();

virtual int type() const;

virtual token_t* clone() const;

virtual void print(io::output &out) const;
};
}
}

#endif
23 changes: 23 additions & 0 deletions include/occa/lang/token/newlineToken.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#ifndef OCCA_LANG_TOKEN_NEWLINETOKEN_HEADER
#define OCCA_LANG_TOKEN_NEWLINETOKEN_HEADER

#include <occa/lang/token/token.hpp>

namespace occa {
namespace lang {
class newlineToken : public token_t {
public:
newlineToken(const fileOrigin &origin_);

virtual ~newlineToken();

virtual int type() const;

virtual token_t* clone() const;

virtual void print(io::output &out) const;
};
}
}

#endif
28 changes: 28 additions & 0 deletions include/occa/lang/token/operatorToken.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#ifndef OCCA_LANG_TOKEN_OPERATORTOKEN_HEADER
#define OCCA_LANG_TOKEN_OPERATORTOKEN_HEADER

#include <occa/lang/token/token.hpp>

namespace occa {
namespace lang {
class operatorToken : public token_t {
public:
const operator_t *op;

operatorToken(const fileOrigin &origin_,
const operator_t &op_);

virtual ~operatorToken();

virtual int type() const;

virtual const opType_t& opType() const;

virtual token_t* clone() const;

virtual void print(io::output &out) const;
};
}
}

#endif
26 changes: 26 additions & 0 deletions include/occa/lang/token/pragmaToken.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#ifndef OCCA_LANG_TOKEN_PRAGMATOKEN_HEADER
#define OCCA_LANG_TOKEN_PRAGMATOKEN_HEADER

#include <occa/lang/token/token.hpp>

namespace occa {
namespace lang {
class pragmaToken : public token_t {
public:
std::string value;

pragmaToken(const fileOrigin &origin_,
const std::string &value_);

virtual ~pragmaToken();

virtual int type() const;

virtual token_t* clone() const;

virtual void print(io::output &out) const;
};
}
}

#endif
28 changes: 28 additions & 0 deletions include/occa/lang/token/primitiveToken.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#ifndef OCCA_LANG_TOKEN_PRIMITIVETOKEN_HEADER
#define OCCA_LANG_TOKEN_PRIMITIVETOKEN_HEADER

#include <occa/lang/token/token.hpp>

namespace occa {
namespace lang {
class primitiveToken : public token_t {
public:
primitive value;
std::string strValue;

primitiveToken(const fileOrigin &origin_,
const primitive &value_,
const std::string &strValue_);

virtual ~primitiveToken();

virtual int type() const;

virtual token_t* clone() const;

virtual void print(io::output &out) const;
};
}
}

#endif
26 changes: 26 additions & 0 deletions include/occa/lang/token/qualifierToken.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#ifndef OCCA_LANG_TOKEN_QUALIFIERTOKEN_HEADER
#define OCCA_LANG_TOKEN_QUALIFIERTOKEN_HEADER

#include <occa/lang/token/token.hpp>

namespace occa {
namespace lang {
class qualifierToken : public token_t {
public:
const qualifier_t &qualifier;

qualifierToken(const fileOrigin &origin_,
const qualifier_t &qualifier_);

virtual ~qualifierToken();

virtual int type() const;

virtual token_t* clone() const;

virtual void print(io::output &out) const;
};
}
}

#endif
35 changes: 35 additions & 0 deletions include/occa/lang/token/stringToken.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#ifndef OCCA_LANG_TOKEN_STRINGTOKEN_HEADER
#define OCCA_LANG_TOKEN_STRINGTOKEN_HEADER

#include <occa/lang/token/token.hpp>

namespace occa {
namespace lang {
class stringToken : public token_t {
public:
int encoding;
std::string value;
std::string udf;

stringToken(const fileOrigin &origin_,
const std::string &value_);

stringToken(const fileOrigin &origin_,
int encoding_,
const std::string &value_,
const std::string &udf_);

virtual ~stringToken();

virtual int type() const;

virtual token_t* clone() const;

void append(const stringToken &token);

virtual void print(io::output &out) const;
};
}
}

#endif
Loading