NewLang Project
Yet another programm language
Loading...
Searching...
No Matches
newlang::Term Class Reference

#include <term.h>

Inheritance diagram for newlang::Term:

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 ()
 
- Public Member Functions inherited from newlang::Dict< Term >
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)
 
PairTypepush_back (const PairType &p)
 
PairTypepush_back (const Type value, const std::string &name="")
 
virtual PairTypeat (const int64_t index)
 
virtual const PairTypeat (const int64_t index) const
 
virtual PairTypeat (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 Public Member Functions inherited from newlang::Dict< Term >
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

- Public Types inherited from newlang::Dict< Term >
typedef std::shared_ptr< TermType
 
typedef std::pair< std::string, TypePairType
 
typedef std::list< PairTypeListType
 

Detailed Description

Definition at line 332 of file term.h.

Constructor & Destructor Documentation

◆ Term()

newlang::Term::Term ( TermID id,
const char * text,
parser::token_type lex_type,
size_t len,
location * loc,
std::shared_ptr< std::string > source = nullptr )
inline

◆ ~Term()

virtual newlang::Term::~Term ( )
inlinevirtual

Definition at line 384 of file term.h.

References clear_(), LOG_DUMP, m_id, and m_text.

Member Function Documentation

◆ Create()

static TermPtr newlang::Term::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 )
inlinestatic

◆ CreateSymbol()

static TermPtr newlang::Term::CreateSymbol ( char sym)
inlinestatic

Definition at line 339 of file term.h.

References Create(), and newlang::SYMBOL.

Referenced by newlang::Macro::ExtractArgs().

◆ CreateNone()

TermPtr Term::CreateNone ( )
static

Definition at line 23 of file term.cpp.

References Create(), newlang::NONE, and result.

◆ CreateNil()

TermPtr Term::CreateNil ( )
static

Definition at line 28 of file term.cpp.

References Create(), newlang::NONE, and result.

Referenced by newlang::AstAnalysis::CreateOp_().

◆ CreateDict()

TermPtr Term::CreateDict ( )
static

Definition at line 33 of file term.cpp.

References Create(), newlang::DICT, and result.

Referenced by newlang::AstAnalysis::CreateOp_(), and newlang::JIT::MainArgs().

◆ CreateName()

◆ CreateIntName()

TermPtr Term::CreateIntName ( const std::string_view name,
const std::string_view int_name,
TermID id = TermID::NAME )
static

Definition at line 38 of file term.cpp.

References Create(), newlang::Dict< Term >::name(), and result.

Referenced by newlang::Context::Call().

◆ Clone()

TermPtr newlang::Term::Clone ( )
inline

Definition at line 350 of file term.h.

References Create(), m_id, m_lexer_type, m_text, and result.

◆ getTermID()

TermID newlang::Term::getTermID ( ) const
inline

Definition at line 391 of file term.h.

References m_id.

Referenced by toString().

◆ getName() [1/2]

const std::string & newlang::Term::getName ( ) const
inline

Definition at line 395 of file term.h.

References m_name_or_class.

◆ getName() [2/2]

std::string & newlang::Term::getName ( )
inline

Definition at line 399 of file term.h.

References m_name_or_class.

◆ SetName()

void newlang::Term::SetName ( std::string & name)
inline

Definition at line 403 of file term.h.

References m_name_or_class, and newlang::Dict< Term >::name().

◆ getText() [1/2]

std::string & newlang::Term::getText ( )
inline

Definition at line 407 of file term.h.

References m_text.

◆ getText() [2/2]

const std::string & newlang::Term::getText ( ) const
inline

Definition at line 411 of file term.h.

References m_text.

◆ isRef()

bool newlang::Term::isRef ( )
inline

Definition at line 415 of file term.h.

References m_ref.

◆ isCall()

bool newlang::Term::isCall ( ) const
inline

Definition at line 419 of file term.h.

References m_is_call.

Referenced by isCalculated().

◆ isInterrupt()

bool newlang::Term::isInterrupt ( ) const
inline

Definition at line 423 of file term.h.

References newlang::INT_MINUS, newlang::INT_PLUS, newlang::INT_REPEAT, and m_id.

◆ isCreateNew()

bool newlang::Term::isCreateNew ( ) const
inline

Definition at line 434 of file term.h.

References newlang::CREATE_NEW, m_id, and newlang::PURE_NEW.

◆ isCreateUse()

bool newlang::Term::isCreateUse ( ) const
inline

Definition at line 443 of file term.h.

References newlang::CREATE_USE, m_id, and newlang::PURE_USE.

◆ isCreate()

bool newlang::Term::isCreate ( ) const
inline

◆ isPure()

bool newlang::Term::isPure ( ) const
inline

Definition at line 466 of file term.h.

References m_id, newlang::PURE_NEW, and newlang::PURE_USE.

◆ isNone()

bool newlang::Term::isNone ( ) const
inline

Definition at line 475 of file term.h.

References m_id, m_text, and newlang::NAME.

◆ isMacro()

bool newlang::Term::isMacro ( ) const
inline

Definition at line 479 of file term.h.

References isCreate(), m_id, m_left, newlang::MACRO_DEL, and newlang::MACRO_SEQ.

◆ isReturn()

bool newlang::Term::isReturn ( ) const
inline

Definition at line 483 of file term.h.

References newlang::INT_MINUS, newlang::INT_PLUS, and m_id.

◆ GetFullName()

const std::string newlang::Term::GetFullName ( ) const
inline

Definition at line 487 of file term.h.

References m_text, and result.

◆ isFunction()

bool newlang::Term::isFunction ( ) const
inline

Definition at line 493 of file term.h.

References newlang::FUNCTION, and m_id.

◆ isScalar()

bool newlang::Term::isScalar ( ) const
inline

Definition at line 497 of file term.h.

References newlang::INTEGER, m_id, and newlang::NUMBER.

◆ isString()

bool newlang::Term::isString ( ) const
inline

Definition at line 506 of file term.h.

References m_id, newlang::STRCHAR, and newlang::STRWIDE.

◆ isNamed()

bool newlang::Term::isNamed ( ) const
inline

◆ isLiteral()

bool newlang::Term::isLiteral ( ) const
inline

◆ isCalculated()

◆ isExportName()

static bool newlang::Term::isExportName ( const TermPtr & term)
inlinestatic

Definition at line 565 of file term.h.

References newlang::isLocalName().

Referenced by isExport(), and newlang::AstAnalysis::MakeInclude().

◆ isExport()

bool newlang::Term::isExport ( ) const
inline

Definition at line 569 of file term.h.

References isCreate(), isExportName(), m_id, m_left, newlang::MACRO_DEL, and newlang::MACRO_SEQ.

◆ isBlock()

bool newlang::Term::isBlock ( ) const
inline

◆ is_variable_args()

bool newlang::Term::is_variable_args ( )
inline

Definition at line 585 of file term.h.

References newlang::Dict< Term >::at(), and newlang::ELLIPSIS.

◆ dump_items_()

void newlang::Term::dump_items_ ( std::string & str) const
inline

Definition at line 589 of file term.h.

References newlang::isDefaultType().

Referenced by asTypeString(), and toString().

◆ toString()

std::string newlang::Term::toString ( bool nested = false)
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.

Referenced by MakeRef(), and Print().

◆ Print()

std::ostream & newlang::Term::Print ( std::ostream & out = std::cout,
const char * delimiter = nullptr )
inline

Definition at line 1156 of file term.h.

References toString().

◆ Begin()

TermPtr newlang::Term::Begin ( )
inline

Definition at line 1162 of file term.h.

References m_left.

◆ End()

TermPtr newlang::Term::End ( )
inline

Definition at line 1169 of file term.h.

References m_right.

◆ SetSource()

void newlang::Term::SetSource ( std::shared_ptr< std::string > source)
inline

Definition at line 1176 of file term.h.

References m_source.

◆ AppendLeft()

void newlang::Term::AppendLeft ( TermPtr item)
inline

Definition at line 1206 of file term.h.

References ASSERT, and m_source.

◆ AppendRight()

void newlang::Term::AppendRight ( TermPtr item)
inline

Definition at line 1219 of file term.h.

References ASSERT, and m_source.

◆ AppendText() [1/2]

void newlang::Term::AppendText ( const std::string & s)
inline

Definition at line 1234 of file term.h.

References m_text.

◆ AppendText() [2/2]

void newlang::Term::AppendText ( TermPtr txt)
inline

Definition at line 1238 of file term.h.

References m_text.

◆ RightToBlock()

void newlang::Term::RightToBlock ( std::vector< TermPtr > & vect,
bool remove = true )
inline

Definition at line 1242 of file term.h.

References newlang::END.

◆ SetArgs()

void newlang::Term::SetArgs ( TermPtr args)
inline

◆ AppendBlock()

TermPtr newlang::Term::AppendBlock ( TermPtr & item,
TermID id,
bool force = false )
inline

Definition at line 1277 of file term.h.

References ASSERT, Create(), isBlock(), m_block, m_id, result, and newlang::SEQUENCE.

◆ clear_()

void newlang::Term::clear_ ( )
inlineoverridevirtual

Reimplemented from newlang::Dict< Term >.

Definition at line 1315 of file term.h.

References Clear().

Referenced by ~Term().

◆ Clear()

void newlang::Term::Clear ( bool clear_iterator_name)
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_().

◆ First()

TermPtr newlang::Term::First ( )
inline

Definition at line 1349 of file term.h.

References m_left.

◆ Last()

TermPtr newlang::Term::Last ( )
inline

Definition at line 1357 of file term.h.

References m_right.

◆ MakeRef()

void newlang::Term::MakeRef ( TermPtr ref)
inline

◆ asTypeString()

std::string newlang::Term::asTypeString ( ) const
inline

Definition at line 1371 of file term.h.

References dump_items_(), m_dims, m_ref, m_text, and result.

◆ SetType()

◆ GetType()

TermPtr newlang::Term::GetType ( )
inline

Definition at line 1398 of file term.h.

References m_type.

Referenced by toString().

◆ TestConst()

bool newlang::Term::TestConst ( )
inline

Definition at line 1402 of file term.h.

References newlang::isConstName(), newlang::isReservedName(), m_is_const, and m_text.

◆ CheckTermEq()

bool Term::CheckTermEq ( const TermPtr & term,
const TermPtr & proto,
bool type = false,
RuntimePtr rt = nullptr )
static

Проверяет аргументы термина на корректность, обрабатывает системные аргументы, проверяет наличие внешних функций

Definition at line 112 of file term.cpp.

References CheckTermEq().

Referenced by newlang::NameLookupStack::AddName(), CheckTermEq(), and newlang::GlobalObjects::RegisterObject().

Member Data Documentation

◆ m_id

◆ m_source

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().

◆ m_line

int newlang::Term::m_line

Line num this term in the source code.

Definition at line 1421 of file term.h.

Referenced by Clear(), and Term().

◆ m_col

int newlang::Term::m_col

Col num this term in the source code.

Definition at line 1422 of file term.h.

Referenced by Clear(), and Term().

◆ m_left

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().

◆ m_right

TermPtr newlang::Term::m_right

Right node of a linked list.

Definition at line 1425 of file term.h.

Referenced by Clear(), End(), Last(), MakeRef(), and toString().

◆ m_block

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().

◆ m_type

TermPtr newlang::Term::m_type

Term type if specified.

Definition at line 1428 of file term.h.

Referenced by GetType(), and SetType().

◆ m_text

std::string newlang::Term::m_text

◆ m_name_or_class

std::string newlang::Term::m_name_or_class

The name or class of the term, if the term has a name or class.

Definition at line 1431 of file term.h.

Referenced by Clear(), getName(), getName(), SetName(), and toString().

◆ m_namespace

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().

◆ m_dims

TermPtr newlang::Term::m_dims

Dimension of a tensor.

Definition at line 1433 of file term.h.

Referenced by asTypeString(), and toString().

◆ m_docs

BlockType newlang::Term::m_docs

Inline documentation for a term or block.

Definition at line 1434 of file term.h.

Referenced by Clear().

◆ m_level

size_t newlang::Term::m_level

Dict nesting level (if applicable)

Definition at line 1436 of file term.h.

Referenced by Term().

◆ m_is_owner

bool newlang::Term::m_is_owner

The flag of the object's owner (if applicable)

Definition at line 1437 of file term.h.

Referenced by Term().

◆ m_is_take

bool newlang::Term::m_is_take

Object data capture flag.

Definition at line 1438 of file term.h.

Referenced by Term().

◆ m_is_const

bool newlang::Term::m_is_const

Immutability (non changeability) feature.

Definition at line 1439 of file term.h.

Referenced by Term(), TestConst(), and toString().

◆ m_is_call

bool newlang::Term::m_is_call

Call as function flag (brackets used )

Definition at line 1440 of file term.h.

Referenced by isCall(), SetArgs(), Term(), and toString().

◆ m_ref

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().

◆ m_attr

BlockType newlang::Term::m_attr

List of term attributes.

Definition at line 1443 of file term.h.

◆ m_sys_prop

TermPtr newlang::Term::m_sys_prop

System parameters are not included in the argument list when called and are stored separately.

Definition at line 1446 of file term.h.

Referenced by SetArgs().

◆ m_normalized

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().

◆ m_bracket_depth

int newlang::Term::m_bracket_depth

Internal data of the depth of brackets when processed in the lexer.

Definition at line 1451 of file term.h.

Referenced by Term().

◆ m_lexer_type

parser::token_type newlang::Term::m_lexer_type

Internal data for macroprocessor.

Definition at line 1452 of file term.h.

Referenced by Clone(), and Term().

◆ m_lexer_loc

parser::location_type newlang::Term::m_lexer_loc

Internal data for macroprocessor.

Definition at line 1453 of file term.h.

◆ m_macro_id

BlockType newlang::Term::m_macro_id

Internal data for macroprocessor.

Definition at line 1454 of file term.h.

Referenced by Clear().

◆ m_macro_seq

BlockType newlang::Term::m_macro_seq

Internal data for macroprocessor.

Definition at line 1455 of file term.h.

Referenced by Clear(), and toString().


The documentation for this class was generated from the following files: