NewLang Project
Yet another programm language
|
#include <term.h>
Public Member Functions | |
TermPtr | Clone () |
Term (TermID id, const char *text, parser::token_type lex_type, size_t len, location *loc, std::shared_ptr< std::string > source=nullptr) | |
virtual | ~Term () |
TermID | getTermID () const |
const std::string & | getName () const |
std::string & | getName () |
void | SetName (std::string &name) |
std::string & | getText () |
const std::string & | getText () const |
bool | isRef () |
bool | isCall () const |
bool | isInterrupt () const |
bool | isCreateNew () const |
bool | isCreateUse () const |
bool | isCreate () const |
bool | isPure () const |
bool | isNone () const |
bool | isMacro () const |
bool | isReturn () const |
const std::string | GetFullName () const |
bool | isFunction () const |
bool | isScalar () const |
bool | isString () const |
bool | isNamed () const |
bool | isLiteral () const |
bool | isCalculated () const |
bool | isExport () const |
bool | isBlock () const |
bool | is_variable_args () |
void | dump_items_ (std::string &str) const |
std::string | toString (bool nested=false) |
std::ostream & | Print (std::ostream &out=std::cout, const char *delimiter=nullptr) |
TermPtr | Begin () |
TermPtr | End () |
void | SetSource (std::shared_ptr< std::string > source) |
void | AppendLeft (TermPtr item) |
void | AppendRight (TermPtr item) |
void | AppendText (const std::string &s) |
void | AppendText (TermPtr txt) |
void | RightToBlock (std::vector< TermPtr > &vect, bool remove=true) |
void | SetArgs (TermPtr args) |
TermPtr | AppendBlock (TermPtr &item, TermID id, bool force=false) |
void | clear_ () override |
void | Clear (bool clear_iterator_name) |
TermPtr | First () |
TermPtr | Last () |
void | MakeRef (TermPtr ref) |
std::string | asTypeString () const |
void | SetType (TermPtr type) |
TermPtr | GetType () |
bool | TestConst () |
![]() | |
std::enable_if< std::is_integral< I >::value &&!std::is_pointer< I >::value, constPairType & >::type | operator[] (I index) |
std::enable_if< std::is_same< N, std::string >::value||std::is_pointer< N >::value, constPairType & >::type | operator[] (N name) |
PairType & | push_back (const PairType &p) |
PairType & | push_back (const Type value, const std::string &name="") |
virtual PairType & | at (const int64_t index) |
virtual const PairType & | at (const int64_t index) const |
virtual PairType & | at (const std::string name) |
ListType::iterator | find (const std::string_view name) |
virtual const std::string & | name (const int64_t index) const |
virtual int64_t | index (const std::string_view field_name) |
virtual int64_t | resize (int64_t new_size, const Type fill, const std::string &name="") |
ListType::iterator | at_index (const int64_t index) |
ListType::const_iterator | at_index_const (const int64_t index) const |
virtual void | erase (const int64_t index) |
virtual void | erase (const size_t index_from, const size_t index_to) |
virtual | ~Dict () |
Dict () | |
Dict (PairType arg) | |
Dict (PairType arg, A... rest) | |
Static Public Member Functions | |
static TermPtr | Create (TermID id, const char *text, parser::token_type lex_type=parser::token_type::END, size_t len=std::string::npos, location *loc=nullptr, std::shared_ptr< std::string > source=nullptr) |
static TermPtr | CreateSymbol (char sym) |
static TermPtr | CreateNone () |
static TermPtr | CreateNil () |
static TermPtr | CreateDict () |
static TermPtr | CreateName (std::string name, TermID id=TermID::NAME) |
static TermPtr | CreateIntName (const std::string_view name, const std::string_view int_name, TermID id=TermID::NAME) |
static bool | isExportName (const TermPtr &term) |
static bool | CheckTermEq (const TermPtr &term, const TermPtr &proto, bool type=false, RuntimePtr rt=nullptr) |
![]() | |
static PairType | pair (const Type value, const std::string name="") |
Public Attributes | |
TermID | m_id |
Term id (name, block, operator, string etc.) | |
SourceType | m_source |
Shared ptr source code. | |
int | m_line |
Line num this term in the source code. | |
int | m_col |
Col num this term in the source code. | |
TermPtr | m_left |
Left node of a linked list. | |
TermPtr | m_right |
Right node of a linked list. | |
BlockType | m_block |
A list of terms separated by semicolons with in a block. | |
TermPtr | m_type |
Term type if specified. | |
std::string | m_text |
Text of the term. | |
std::string | m_name_or_class |
The name or class of the term, if the term has a name or class. | |
TermPtr | m_namespace |
The current namespace in the source file when this term is used. | |
TermPtr | m_dims |
Dimension of a tensor. | |
BlockType | m_docs |
Inline documentation for a term or block. | |
size_t | m_level |
Dict nesting level (if applicable) | |
bool | m_is_owner |
The flag of the object's owner (if applicable) | |
bool | m_is_take |
Object data capture flag. | |
bool | m_is_const |
Immutability (non changeability) feature. | |
bool | m_is_call |
Call as function flag (brackets used ) | |
TermPtr | m_ref |
Type of reference before the variable (valid references or its creation operator) | |
BlockType | m_attr |
List of term attributes. | |
TermPtr | m_sys_prop |
System parameters are not included in the argument list when called and are stored separately. | |
InternalName | m_normalized |
Internal name of the object. Must be filled in after AST parsing. | |
int | m_bracket_depth |
Internal data of the depth of brackets when processed in the lexer. | |
parser::token_type | m_lexer_type |
Internal data for macroprocessor. | |
parser::location_type | m_lexer_loc |
Internal data for macroprocessor. | |
BlockType | m_macro_id |
Internal data for macroprocessor. | |
BlockType | m_macro_seq |
Internal data for macroprocessor. | |
Additional Inherited Members | |
![]() | |
typedef std::shared_ptr< Term > | Type |
typedef std::pair< std::string, Type > | PairType |
typedef std::list< PairType > | ListType |
|
inline |
Definition at line 356 of file term.h.
References m_bracket_depth, m_col, m_id, m_is_call, m_is_const, m_is_owner, m_is_take, m_level, m_lexer_type, m_line, m_ref, m_source, and m_text.
|
inlinevirtual |
|
inlinestatic |
Definition at line 335 of file term.h.
Referenced by AppendBlock(), newlang::Parser::AstAddTerm(), newlang::AstAnalysis::CkeckRange_(), newlang::NameLookupStack::clear(), Clone(), CreateDict(), CreateIntName(), CreateName(), CreateNil(), CreateNone(), CreateSymbol(), newlang::Macro::ExtractArgs(), newlang::Parser::GetNextToken(), newlang::Parser::Parse(), newlang::Parser::Parser(), newlang::Parser::PragmaEval(), newlang::RunTime::RegisterBuildinType(), newlang::JIT::Run(), and SetArgs().
|
inlinestatic |
Definition at line 339 of file term.h.
References Create(), and newlang::SYMBOL.
Referenced by newlang::Macro::ExtractArgs().
|
static |
Definition at line 23 of file term.cpp.
References Create(), newlang::NONE, and result.
|
static |
Definition at line 28 of file term.cpp.
References Create(), newlang::NONE, and result.
Referenced by newlang::AstAnalysis::CreateOp_().
|
static |
Definition at line 33 of file term.cpp.
References Create(), newlang::DICT, and result.
Referenced by newlang::AstAnalysis::CreateOp_(), and newlang::JIT::MainArgs().
|
static |
Definition at line 44 of file term.cpp.
References Create(), newlang::Dict< Term >::name(), and result.
Referenced by newlang::RunTime::CreateFunction(), newlang::AstAnalysis::CreateOp_(), newlang::JIT::MainArgs(), newlang::JIT::MakeCodeModule(), and newlang::NameLookupStack::PushScope().
|
static |
Definition at line 38 of file term.cpp.
References Create(), newlang::Dict< Term >::name(), and result.
Referenced by newlang::Context::Call().
|
inline |
|
inline |
|
inline |
Definition at line 395 of file term.h.
References m_name_or_class.
|
inline |
Definition at line 399 of file term.h.
References m_name_or_class.
|
inline |
Definition at line 403 of file term.h.
References m_name_or_class, and newlang::Dict< Term >::name().
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 423 of file term.h.
References newlang::INT_MINUS, newlang::INT_PLUS, newlang::INT_REPEAT, and m_id.
|
inline |
Definition at line 434 of file term.h.
References newlang::CREATE_NEW, m_id, and newlang::PURE_NEW.
|
inline |
Definition at line 443 of file term.h.
References newlang::CREATE_USE, m_id, and newlang::PURE_USE.
|
inline |
Definition at line 452 of file term.h.
References newlang::APPEND, newlang::ASSIGN, newlang::CREATE_NEW, newlang::CREATE_USE, m_id, newlang::PURE_NEW, newlang::PURE_USE, and newlang::SWAP.
Referenced by isExport(), and isMacro().
|
inline |
Definition at line 466 of file term.h.
References m_id, newlang::PURE_NEW, and newlang::PURE_USE.
|
inline |
Definition at line 475 of file term.h.
References m_id, m_text, and newlang::NAME.
|
inline |
Definition at line 479 of file term.h.
References isCreate(), m_id, m_left, newlang::MACRO_DEL, and newlang::MACRO_SEQ.
|
inline |
Definition at line 483 of file term.h.
References newlang::INT_MINUS, newlang::INT_PLUS, and m_id.
|
inline |
|
inline |
Definition at line 493 of file term.h.
References newlang::FUNCTION, and m_id.
|
inline |
Definition at line 497 of file term.h.
References newlang::INTEGER, m_id, and newlang::NUMBER.
|
inline |
Definition at line 506 of file term.h.
References m_id, newlang::STRCHAR, and newlang::STRWIDE.
|
inline |
Definition at line 515 of file term.h.
References newlang::ARGS, newlang::ARGUMENT, newlang::LOCAL, m_id, newlang::MODULE, newlang::NAME, newlang::STATIC, and newlang::TYPE.
|
inline |
Definition at line 529 of file term.h.
References newlang::DICT, newlang::END, newlang::INTEGER, m_id, newlang::NUMBER, newlang::RANGE, newlang::RATIONAL, newlang::STRCHAR, newlang::STRWIDE, and newlang::TENSOR.
Referenced by isCalculated().
|
inline |
Definition at line 545 of file term.h.
References newlang::ARGS, newlang::ARGUMENT, newlang::ASSIGN, newlang::CREATE_NEW, newlang::CREATE_USE, newlang::DICT, newlang::EVAL, isCall(), isLiteral(), m_id, newlang::NAME, newlang::OP_LOGICAL, newlang::OP_MATH, newlang::RANGE, and newlang::TENSOR.
|
inlinestatic |
Definition at line 565 of file term.h.
References newlang::isLocalName().
Referenced by isExport(), and newlang::AstAnalysis::MakeInclude().
|
inline |
Definition at line 569 of file term.h.
References isCreate(), isExportName(), m_id, m_left, newlang::MACRO_DEL, and newlang::MACRO_SEQ.
|
inline |
Definition at line 573 of file term.h.
References newlang::BLOCK, newlang::BLOCK_MINUS, newlang::BLOCK_PLUS, newlang::BLOCK_TRY, m_id, and newlang::SEQUENCE.
Referenced by AppendBlock(), and toString().
|
inline |
Definition at line 585 of file term.h.
References newlang::Dict< Term >::at(), and newlang::ELLIPSIS.
|
inline |
Definition at line 589 of file term.h.
References newlang::isDefaultType().
Referenced by asTypeString(), and toString().
|
inline |
Definition at line 611 of file term.h.
References newlang::APPEND, newlang::ARGS, newlang::ARGUMENT, ASSERT, newlang::ASSIGN, newlang::Dict< Term >::at(), newlang::BLOCK, newlang::BLOCK_MINUS, newlang::BLOCK_PLUS, newlang::BLOCK_TRY, newlang::CLASS, newlang::COMMENT, newlang::COMPLEX, newlang::CREATE_NEW, newlang::CREATE_USE, newlang::CRLF, newlang::DICT, newlang::DOWHILE, dump_items_(), newlang::ELLIPSIS, newlang::EMBED, newlang::EMPTY, newlang::END, newlang::ESCAPE, newlang::EVAL, newlang::FIELD, newlang::FILLING, newlang::FOLLOW, newlang::FUNCTION, getTermID(), GetType(), newlang::INDENT, newlang::INDEX, newlang::INT_MINUS, newlang::INT_PLUS, newlang::INTEGER, isBlock(), newlang::isDefaultType(), newlang::ITERATOR, newlang::LOCAL, LOG_ABORT, LOG_RUNTIME, m_block, m_dims, m_id, m_is_call, m_is_const, m_left, m_macro_seq, m_name_or_class, m_namespace, m_normalized, m_ref, m_right, m_text, newlang::MACRO, newlang::MACRO_ARGCOUNT, newlang::MACRO_ARGNAME, newlang::MACRO_ARGPOS, newlang::MACRO_ARGUMENT, newlang::MACRO_DEL, newlang::MACRO_SEQ, newlang::MACRO_STR, newlang::MACRO_TOSTR, newlang::MANGLED, newlang::MODULE, newlang::NAME, newlang::NAMESPACE, newlang::NATIVE, newlang::NEWLANG, newlang::NONE, newlang::NUMBER, newlang::OP_BITWISE, newlang::OP_COMPARE, newlang::OP_LOGICAL, newlang::OP_MATH, newlang::PARENT, newlang::PURE_NEW, newlang::PURE_USE, newlang::RANGE, newlang::RATIONAL, result, newlang::SEQUENCE, newlang::SPACE, newlang::STATIC, newlang::STRCHAR, newlang::STRWIDE, newlang::SYMBOL, newlang::TAKE, newlang::TENSOR, newlang::toString(), newlang::TYPE, newlang::TYPECAST, newlang::TYPEDUCK, newlang::UNKNOWN, newlang::WHILE, and newlang::WITH.
|
inline |
Definition at line 1156 of file term.h.
References toString().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 1242 of file term.h.
References newlang::END.
|
inline |
Definition at line 1259 of file term.h.
References Create(), newlang::DICT, newlang::isSystemName(), m_is_call, m_sys_prop, NL_PARSER, and newlang::Dict< Term >::push_back().
|
inlineoverridevirtual |
Reimplemented from newlang::Dict< Term >.
Definition at line 1315 of file term.h.
References Clear().
Referenced by ~Term().
|
inline |
Definition at line 1319 of file term.h.
References newlang::END, m_block, m_col, m_docs, m_id, m_left, m_line, m_macro_id, m_macro_seq, m_name_or_class, m_namespace, m_right, m_source, and m_text.
Referenced by clear_().
|
inline |
Definition at line 1364 of file term.h.
References LOG_RUNTIME, m_id, m_left, m_ref, m_right, newlang::MACRO, newlang::NAME, newlang::STATIC, toString(), and newlang::TYPE.
|
inline |
void Term::SetType | ( | TermPtr | type | ) |
Definition at line 49 of file term.cpp.
References newlang::Bool, newlang::canCastLimit(), newlang::COMPLEX, newlang::DICT, newlang::Dictionary, newlang::Float64, newlang::getDefaultType(), newlang::INTEGER, newlang::ITERATOR, newlang::Iterator, m_id, m_text, m_type, NL_PARSER, newlang::NUMBER, newlang::parseDouble(), newlang::parseInteger(), newlang::RANGE, newlang::Range, newlang::RATIONAL, newlang::Rational, newlang::STRCHAR, newlang::StrChar, newlang::STRWIDE, newlang::StrWide, newlang::typeFromLimit(), and newlang::typeFromString().
|
inline |
|
inline |
Definition at line 1402 of file term.h.
References newlang::isConstName(), newlang::isReservedName(), m_is_const, and m_text.
|
static |
Проверяет аргументы термина на корректность, обрабатывает системные аргументы, проверяет наличие внешних функций
Definition at line 112 of file term.cpp.
References CheckTermEq().
Referenced by newlang::NameLookupStack::AddName(), CheckTermEq(), and newlang::GlobalObjects::RegisterObject().
TermID newlang::Term::m_id |
Term id (name, block, operator, string etc.)
Definition at line 1419 of file term.h.
Referenced by AppendBlock(), Clear(), Clone(), getTermID(), isBlock(), isCalculated(), isCreate(), isCreateNew(), isCreateUse(), isExport(), isFunction(), isInterrupt(), isLiteral(), isMacro(), isNamed(), isNone(), isPure(), isReturn(), isScalar(), isString(), MakeRef(), SetType(), Term(), toString(), and ~Term().
SourceType newlang::Term::m_source |
Shared ptr source code.
Definition at line 1420 of file term.h.
Referenced by AppendLeft(), AppendRight(), Clear(), SetSource(), and Term().
int newlang::Term::m_line |
int newlang::Term::m_col |
TermPtr newlang::Term::m_left |
Left node of a linked list.
Definition at line 1424 of file term.h.
Referenced by Begin(), Clear(), First(), isExport(), isMacro(), MakeRef(), and toString().
TermPtr newlang::Term::m_right |
BlockType newlang::Term::m_block |
A list of terms separated by semicolons with in a block.
Definition at line 1427 of file term.h.
Referenced by AppendBlock(), Clear(), and toString().
TermPtr newlang::Term::m_type |
std::string newlang::Term::m_text |
Text of the term.
Definition at line 1430 of file term.h.
Referenced by AppendText(), AppendText(), asTypeString(), Clear(), Clone(), GetFullName(), getText(), getText(), isNone(), SetType(), Term(), TestConst(), toString(), and ~Term().
std::string newlang::Term::m_name_or_class |
TermPtr newlang::Term::m_namespace |
The current namespace in the source file when this term is used.
Definition at line 1432 of file term.h.
Referenced by Clear(), and toString().
TermPtr newlang::Term::m_dims |
Dimension of a tensor.
Definition at line 1433 of file term.h.
Referenced by asTypeString(), and toString().
BlockType newlang::Term::m_docs |
size_t newlang::Term::m_level |
bool newlang::Term::m_is_owner |
bool newlang::Term::m_is_take |
bool newlang::Term::m_is_const |
Immutability (non changeability) feature.
Definition at line 1439 of file term.h.
Referenced by Term(), TestConst(), and toString().
bool newlang::Term::m_is_call |
TermPtr newlang::Term::m_ref |
Type of reference before the variable (valid references or its creation operator)
Definition at line 1441 of file term.h.
Referenced by asTypeString(), isRef(), MakeRef(), Term(), and toString().
TermPtr newlang::Term::m_sys_prop |
InternalName newlang::Term::m_normalized |
Internal name of the object. Must be filled in after AST parsing.
Definition at line 1448 of file term.h.
Referenced by toString().
int newlang::Term::m_bracket_depth |
parser::token_type newlang::Term::m_lexer_type |
parser::location_type newlang::Term::m_lexer_loc |
BlockType newlang::Term::m_macro_id |
BlockType newlang::Term::m_macro_seq |
Internal data for macroprocessor.
Definition at line 1455 of file term.h.
Referenced by Clear(), and toString().