![]() |
Elementa v8.0.0
Minimalistic library for any C++ application (C++11 and up)
|
General parsing of expressions for diverse programming languages.

Classes | |
| class | elementa::parsing::ExprElement |
| An element within an expression. Elements are data, operations or groupings. More... | |
| class | elementa::parsing::ExprSimpleGroupOpen |
| A simple group-open expression element. More... | |
| class | elementa::parsing::ExprSimpleGroupClose |
| A simple group-close expression element. More... | |
| class | elementa::parsing::ExprSimpleArgsOpen |
| A simple args-open expression element. More... | |
| class | elementa::parsing::ExprSimpleArgsClose |
| A simple args-close expression element. More... | |
| class | elementa::parsing::ExprSimpleArgsSep |
| A simple args-separator expression element. More... | |
| class | elementa::parsing::ExprOperElement |
| An element within an expression that is an operation with a fixed arity. More... | |
| class | elementa::parsing::ExprOperNop |
| An operation that takes no arguments and does nothing. More... | |
| class | elementa::parsing::Expression |
| A general expression composed of a number of elements of type Element. More... | |
| class elementa::parsing::ExprElement |
An element within an expression. Elements are data, operations or groupings.
You must derive your expression data directly from this class; your groupings must derive from the special classes below; operations must derive from ExprOperElement.
Definition at line 60 of file expressions.h.

Public Member Functions | |
Constructors | |
| virtual | ~ExprElement (void)=default |
| Just for polymorphic deletions. | |
Virtual methods | |
| bool | isDatum (void) const noexcept |
| Return TRUE if the element is a datum (not a grouping). More... | |
| bool | isOperation (void) const noexcept |
| Return TRUE if the element is an operation. More... | |
| bool | isOpeningGrouping (void) const noexcept |
| Return TRUE if the element is an opening grouping. More... | |
| bool | isClosingGrouping (void) const noexcept |
| Return TRUE if the element is a closing grouping. More... | |
| bool | isGrouping (void) const noexcept |
| Return TRUE if the element is a grouping. More... | |
| bool | isOpeningArgs (void) const noexcept |
| Return TRUE if the element is an opening args. More... | |
| bool | isClosingArgs (void) const noexcept |
| Return TRUE if the element is a closing args. More... | |
| bool | isGroupingArgs (void) const noexcept |
| Return TRUE if the element is an args grouping. More... | |
| bool | isSepArgs (void) const noexcept |
| Return TRUE if the element is a sep args. More... | |
| bool | isDatumTypedAs (int ty) const noexcept |
| Return TRUE if the element is a datum of a given type. More... | |
| virtual Kind | kind (void) const =0 |
| Must return the kind of the element: datum, grouping or operation. More... | |
| virtual int | type (void) const |
| Can be overriden to return the type of the element (an int value). More... | |
| virtual std::string | to_string (void) const |
Types, consts., etc. | |
| using | Ptr = std::shared_ptr< ExprElement > |
| A safe, polymorphic pointer to an element for container use. More... | |
| ELE_CLASS_ENUM (Kind, kDatum, kGroupOpen, kGroupClose, kArgsOpen, kArgsClose, kArgsSep, kOperation) | |
| Kind ot the elements. | |
| using elementa::parsing::ExprElement::Ptr = std::shared_ptr<ExprElement> |
A safe, polymorphic pointer to an element for container use.
Definition at line 68 of file expressions.h.
|
inlinenoexcept |
Return TRUE if the element is a datum (not a grouping).
Definition at line 114 of file expressions.h.
References kind().
Referenced by isDatumTypedAs().
|
inlinenoexcept |
Return TRUE if the element is an operation.
Definition at line 117 of file expressions.h.
References kind().
|
inlinenoexcept |
Return TRUE if the element is an opening grouping.
Definition at line 120 of file expressions.h.
References kind().
Referenced by isGrouping().
|
inlinenoexcept |
Return TRUE if the element is a closing grouping.
Definition at line 124 of file expressions.h.
References kind().
Referenced by isGrouping().
|
inlinenoexcept |
Return TRUE if the element is a grouping.
Definition at line 128 of file expressions.h.
References isClosingGrouping(), and isOpeningGrouping().
|
inlinenoexcept |
Return TRUE if the element is an opening args.
Definition at line 132 of file expressions.h.
References kind().
Referenced by isGroupingArgs().
|
inlinenoexcept |
Return TRUE if the element is a closing args.
Definition at line 136 of file expressions.h.
References kind().
Referenced by isGroupingArgs().
|
inlinenoexcept |
Return TRUE if the element is an args grouping.
Definition at line 140 of file expressions.h.
References isClosingArgs(), and isOpeningArgs().
|
inlinenoexcept |
Return TRUE if the element is a sep args.
Definition at line 144 of file expressions.h.
References kind().
|
inlinenoexcept |
Return TRUE if the element is a datum of a given type.
Definition at line 148 of file expressions.h.
|
pure virtual |
Must return the kind of the element: datum, grouping or operation.
Implemented in elementa::parsing::ExprSimpleGroupOpen, elementa::parsing::ExprSimpleGroupClose, elementa::parsing::ExprSimpleArgsOpen, elementa::parsing::ExprSimpleArgsClose, elementa::parsing::ExprSimpleArgsSep, elementa::parsing::ExprOperElement, and elementa::parsing::Expression::OpDatumWrapper.
Referenced by isClosingArgs(), isClosingGrouping(), isDatum(), isOpeningArgs(), isOpeningGrouping(), isOperation(), and isSepArgs().
|
inlinevirtual |
Can be overriden to return the type of the element (an int value).
Override it to provide a particular type if you are working with typed expressions. Ignore it otherwise.
Definition at line 157 of file expressions.h.
Referenced by isDatumTypedAs().
|
inlinevirtual |
Reimplemented in elementa::parsing::Expression::OpDatumWrapper.
Definition at line 160 of file expressions.h.
| class elementa::parsing::ExprSimpleGroupOpen |
A simple group-open expression element.
Definition at line 169 of file expressions.h.


Public Member Functions | |
| Kind | kind (void) const |
| Must return the kind of the element: datum, grouping or operation. More... | |
Virtual methods | |
| bool | isDatum (void) const noexcept |
| Return TRUE if the element is a datum (not a grouping). More... | |
| bool | isOperation (void) const noexcept |
| Return TRUE if the element is an operation. More... | |
| bool | isOpeningGrouping (void) const noexcept |
| Return TRUE if the element is an opening grouping. More... | |
| bool | isClosingGrouping (void) const noexcept |
| Return TRUE if the element is a closing grouping. More... | |
| bool | isGrouping (void) const noexcept |
| Return TRUE if the element is a grouping. More... | |
| bool | isOpeningArgs (void) const noexcept |
| Return TRUE if the element is an opening args. More... | |
| bool | isClosingArgs (void) const noexcept |
| Return TRUE if the element is a closing args. More... | |
| bool | isGroupingArgs (void) const noexcept |
| Return TRUE if the element is an args grouping. More... | |
| bool | isSepArgs (void) const noexcept |
| Return TRUE if the element is a sep args. More... | |
| bool | isDatumTypedAs (int ty) const noexcept |
| Return TRUE if the element is a datum of a given type. More... | |
| virtual int | type (void) const |
| Can be overriden to return the type of the element (an int value). More... | |
| virtual std::string | to_string (void) const |
Types, consts., etc. | |
| ELE_CLASS_ENUM (Kind, kDatum, kGroupOpen, kGroupClose, kArgsOpen, kArgsClose, kArgsSep, kOperation) | |
| Kind ot the elements. | |
| using | Ptr = std::shared_ptr< ExprElement > |
| A safe, polymorphic pointer to an element for container use. More... | |
|
inherited |
A safe, polymorphic pointer to an element for container use.
Definition at line 68 of file expressions.h.
|
inlinevirtual |
Must return the kind of the element: datum, grouping or operation.
Implements elementa::parsing::ExprElement.
Definition at line 173 of file expressions.h.
|
inlinenoexceptinherited |
Return TRUE if the element is a datum (not a grouping).
Definition at line 114 of file expressions.h.
References elementa::parsing::ExprElement::kind().
Referenced by elementa::parsing::ExprElement::isDatumTypedAs().
|
inlinenoexceptinherited |
Return TRUE if the element is an operation.
Definition at line 117 of file expressions.h.
References elementa::parsing::ExprElement::kind().
|
inlinenoexceptinherited |
Return TRUE if the element is an opening grouping.
Definition at line 120 of file expressions.h.
References elementa::parsing::ExprElement::kind().
Referenced by elementa::parsing::ExprElement::isGrouping().
|
inlinenoexceptinherited |
Return TRUE if the element is a closing grouping.
Definition at line 124 of file expressions.h.
References elementa::parsing::ExprElement::kind().
Referenced by elementa::parsing::ExprElement::isGrouping().
|
inlinenoexceptinherited |
Return TRUE if the element is a grouping.
Definition at line 128 of file expressions.h.
References elementa::parsing::ExprElement::isClosingGrouping(), and elementa::parsing::ExprElement::isOpeningGrouping().
|
inlinenoexceptinherited |
Return TRUE if the element is an opening args.
Definition at line 132 of file expressions.h.
References elementa::parsing::ExprElement::kind().
Referenced by elementa::parsing::ExprElement::isGroupingArgs().
|
inlinenoexceptinherited |
Return TRUE if the element is a closing args.
Definition at line 136 of file expressions.h.
References elementa::parsing::ExprElement::kind().
Referenced by elementa::parsing::ExprElement::isGroupingArgs().
|
inlinenoexceptinherited |
Return TRUE if the element is an args grouping.
Definition at line 140 of file expressions.h.
References elementa::parsing::ExprElement::isClosingArgs(), and elementa::parsing::ExprElement::isOpeningArgs().
|
inlinenoexceptinherited |
Return TRUE if the element is a sep args.
Definition at line 144 of file expressions.h.
References elementa::parsing::ExprElement::kind().
|
inlinenoexceptinherited |
Return TRUE if the element is a datum of a given type.
Definition at line 148 of file expressions.h.
References elementa::parsing::ExprElement::isDatum(), and elementa::parsing::ExprElement::type().
|
inlinevirtualinherited |
Can be overriden to return the type of the element (an int value).
Override it to provide a particular type if you are working with typed expressions. Ignore it otherwise.
Definition at line 157 of file expressions.h.
Referenced by elementa::parsing::ExprElement::isDatumTypedAs().
|
inlinevirtualinherited |
Reimplemented in elementa::parsing::Expression::OpDatumWrapper.
Definition at line 160 of file expressions.h.
| class elementa::parsing::ExprSimpleGroupClose |
A simple group-close expression element.
Definition at line 178 of file expressions.h.


Public Member Functions | |
| Kind | kind (void) const |
| Must return the kind of the element: datum, grouping or operation. More... | |
Virtual methods | |
| bool | isDatum (void) const noexcept |
| Return TRUE if the element is a datum (not a grouping). More... | |
| bool | isOperation (void) const noexcept |
| Return TRUE if the element is an operation. More... | |
| bool | isOpeningGrouping (void) const noexcept |
| Return TRUE if the element is an opening grouping. More... | |
| bool | isClosingGrouping (void) const noexcept |
| Return TRUE if the element is a closing grouping. More... | |
| bool | isGrouping (void) const noexcept |
| Return TRUE if the element is a grouping. More... | |
| bool | isOpeningArgs (void) const noexcept |
| Return TRUE if the element is an opening args. More... | |
| bool | isClosingArgs (void) const noexcept |
| Return TRUE if the element is a closing args. More... | |
| bool | isGroupingArgs (void) const noexcept |
| Return TRUE if the element is an args grouping. More... | |
| bool | isSepArgs (void) const noexcept |
| Return TRUE if the element is a sep args. More... | |
| bool | isDatumTypedAs (int ty) const noexcept |
| Return TRUE if the element is a datum of a given type. More... | |
| virtual int | type (void) const |
| Can be overriden to return the type of the element (an int value). More... | |
| virtual std::string | to_string (void) const |
Types, consts., etc. | |
| ELE_CLASS_ENUM (Kind, kDatum, kGroupOpen, kGroupClose, kArgsOpen, kArgsClose, kArgsSep, kOperation) | |
| Kind ot the elements. | |
| using | Ptr = std::shared_ptr< ExprElement > |
| A safe, polymorphic pointer to an element for container use. More... | |
|
inherited |
A safe, polymorphic pointer to an element for container use.
Definition at line 68 of file expressions.h.
|
inlinevirtual |
Must return the kind of the element: datum, grouping or operation.
Implements elementa::parsing::ExprElement.
Definition at line 182 of file expressions.h.
|
inlinenoexceptinherited |
Return TRUE if the element is a datum (not a grouping).
Definition at line 114 of file expressions.h.
References elementa::parsing::ExprElement::kind().
Referenced by elementa::parsing::ExprElement::isDatumTypedAs().
|
inlinenoexceptinherited |
Return TRUE if the element is an operation.
Definition at line 117 of file expressions.h.
References elementa::parsing::ExprElement::kind().
|
inlinenoexceptinherited |
Return TRUE if the element is an opening grouping.
Definition at line 120 of file expressions.h.
References elementa::parsing::ExprElement::kind().
Referenced by elementa::parsing::ExprElement::isGrouping().
|
inlinenoexceptinherited |
Return TRUE if the element is a closing grouping.
Definition at line 124 of file expressions.h.
References elementa::parsing::ExprElement::kind().
Referenced by elementa::parsing::ExprElement::isGrouping().
|
inlinenoexceptinherited |
Return TRUE if the element is a grouping.
Definition at line 128 of file expressions.h.
References elementa::parsing::ExprElement::isClosingGrouping(), and elementa::parsing::ExprElement::isOpeningGrouping().
|
inlinenoexceptinherited |
Return TRUE if the element is an opening args.
Definition at line 132 of file expressions.h.
References elementa::parsing::ExprElement::kind().
Referenced by elementa::parsing::ExprElement::isGroupingArgs().
|
inlinenoexceptinherited |
Return TRUE if the element is a closing args.
Definition at line 136 of file expressions.h.
References elementa::parsing::ExprElement::kind().
Referenced by elementa::parsing::ExprElement::isGroupingArgs().
|
inlinenoexceptinherited |
Return TRUE if the element is an args grouping.
Definition at line 140 of file expressions.h.
References elementa::parsing::ExprElement::isClosingArgs(), and elementa::parsing::ExprElement::isOpeningArgs().
|
inlinenoexceptinherited |
Return TRUE if the element is a sep args.
Definition at line 144 of file expressions.h.
References elementa::parsing::ExprElement::kind().
|
inlinenoexceptinherited |
Return TRUE if the element is a datum of a given type.
Definition at line 148 of file expressions.h.
References elementa::parsing::ExprElement::isDatum(), and elementa::parsing::ExprElement::type().
|
inlinevirtualinherited |
Can be overriden to return the type of the element (an int value).
Override it to provide a particular type if you are working with typed expressions. Ignore it otherwise.
Definition at line 157 of file expressions.h.
Referenced by elementa::parsing::ExprElement::isDatumTypedAs().
|
inlinevirtualinherited |
Reimplemented in elementa::parsing::Expression::OpDatumWrapper.
Definition at line 160 of file expressions.h.
| class elementa::parsing::ExprSimpleArgsOpen |
A simple args-open expression element.
Definition at line 186 of file expressions.h.


Public Member Functions | |
| Kind | kind (void) const |
| Must return the kind of the element: datum, grouping or operation. More... | |
Virtual methods | |
| bool | isDatum (void) const noexcept |
| Return TRUE if the element is a datum (not a grouping). More... | |
| bool | isOperation (void) const noexcept |
| Return TRUE if the element is an operation. More... | |
| bool | isOpeningGrouping (void) const noexcept |
| Return TRUE if the element is an opening grouping. More... | |
| bool | isClosingGrouping (void) const noexcept |
| Return TRUE if the element is a closing grouping. More... | |
| bool | isGrouping (void) const noexcept |
| Return TRUE if the element is a grouping. More... | |
| bool | isOpeningArgs (void) const noexcept |
| Return TRUE if the element is an opening args. More... | |
| bool | isClosingArgs (void) const noexcept |
| Return TRUE if the element is a closing args. More... | |
| bool | isGroupingArgs (void) const noexcept |
| Return TRUE if the element is an args grouping. More... | |
| bool | isSepArgs (void) const noexcept |
| Return TRUE if the element is a sep args. More... | |
| bool | isDatumTypedAs (int ty) const noexcept |
| Return TRUE if the element is a datum of a given type. More... | |
| virtual int | type (void) const |
| Can be overriden to return the type of the element (an int value). More... | |
| virtual std::string | to_string (void) const |
Types, consts., etc. | |
| ELE_CLASS_ENUM (Kind, kDatum, kGroupOpen, kGroupClose, kArgsOpen, kArgsClose, kArgsSep, kOperation) | |
| Kind ot the elements. | |
| using | Ptr = std::shared_ptr< ExprElement > |
| A safe, polymorphic pointer to an element for container use. More... | |
|
inherited |
A safe, polymorphic pointer to an element for container use.
Definition at line 68 of file expressions.h.
|
inlinevirtual |
Must return the kind of the element: datum, grouping or operation.
Implements elementa::parsing::ExprElement.
Definition at line 190 of file expressions.h.
|
inlinenoexceptinherited |
Return TRUE if the element is a datum (not a grouping).
Definition at line 114 of file expressions.h.
References elementa::parsing::ExprElement::kind().
Referenced by elementa::parsing::ExprElement::isDatumTypedAs().
|
inlinenoexceptinherited |
Return TRUE if the element is an operation.
Definition at line 117 of file expressions.h.
References elementa::parsing::ExprElement::kind().
|
inlinenoexceptinherited |
Return TRUE if the element is an opening grouping.
Definition at line 120 of file expressions.h.
References elementa::parsing::ExprElement::kind().
Referenced by elementa::parsing::ExprElement::isGrouping().
|
inlinenoexceptinherited |
Return TRUE if the element is a closing grouping.
Definition at line 124 of file expressions.h.
References elementa::parsing::ExprElement::kind().
Referenced by elementa::parsing::ExprElement::isGrouping().
|
inlinenoexceptinherited |
Return TRUE if the element is a grouping.
Definition at line 128 of file expressions.h.
References elementa::parsing::ExprElement::isClosingGrouping(), and elementa::parsing::ExprElement::isOpeningGrouping().
|
inlinenoexceptinherited |
Return TRUE if the element is an opening args.
Definition at line 132 of file expressions.h.
References elementa::parsing::ExprElement::kind().
Referenced by elementa::parsing::ExprElement::isGroupingArgs().
|
inlinenoexceptinherited |
Return TRUE if the element is a closing args.
Definition at line 136 of file expressions.h.
References elementa::parsing::ExprElement::kind().
Referenced by elementa::parsing::ExprElement::isGroupingArgs().
|
inlinenoexceptinherited |
Return TRUE if the element is an args grouping.
Definition at line 140 of file expressions.h.
References elementa::parsing::ExprElement::isClosingArgs(), and elementa::parsing::ExprElement::isOpeningArgs().
|
inlinenoexceptinherited |
Return TRUE if the element is a sep args.
Definition at line 144 of file expressions.h.
References elementa::parsing::ExprElement::kind().
|
inlinenoexceptinherited |
Return TRUE if the element is a datum of a given type.
Definition at line 148 of file expressions.h.
References elementa::parsing::ExprElement::isDatum(), and elementa::parsing::ExprElement::type().
|
inlinevirtualinherited |
Can be overriden to return the type of the element (an int value).
Override it to provide a particular type if you are working with typed expressions. Ignore it otherwise.
Definition at line 157 of file expressions.h.
Referenced by elementa::parsing::ExprElement::isDatumTypedAs().
|
inlinevirtualinherited |
Reimplemented in elementa::parsing::Expression::OpDatumWrapper.
Definition at line 160 of file expressions.h.
| class elementa::parsing::ExprSimpleArgsClose |
A simple args-close expression element.
Definition at line 194 of file expressions.h.


Public Member Functions | |
| Kind | kind (void) const |
| Must return the kind of the element: datum, grouping or operation. More... | |
Virtual methods | |
| bool | isDatum (void) const noexcept |
| Return TRUE if the element is a datum (not a grouping). More... | |
| bool | isOperation (void) const noexcept |
| Return TRUE if the element is an operation. More... | |
| bool | isOpeningGrouping (void) const noexcept |
| Return TRUE if the element is an opening grouping. More... | |
| bool | isClosingGrouping (void) const noexcept |
| Return TRUE if the element is a closing grouping. More... | |
| bool | isGrouping (void) const noexcept |
| Return TRUE if the element is a grouping. More... | |
| bool | isOpeningArgs (void) const noexcept |
| Return TRUE if the element is an opening args. More... | |
| bool | isClosingArgs (void) const noexcept |
| Return TRUE if the element is a closing args. More... | |
| bool | isGroupingArgs (void) const noexcept |
| Return TRUE if the element is an args grouping. More... | |
| bool | isSepArgs (void) const noexcept |
| Return TRUE if the element is a sep args. More... | |
| bool | isDatumTypedAs (int ty) const noexcept |
| Return TRUE if the element is a datum of a given type. More... | |
| virtual int | type (void) const |
| Can be overriden to return the type of the element (an int value). More... | |
| virtual std::string | to_string (void) const |
Types, consts., etc. | |
| ELE_CLASS_ENUM (Kind, kDatum, kGroupOpen, kGroupClose, kArgsOpen, kArgsClose, kArgsSep, kOperation) | |
| Kind ot the elements. | |
| using | Ptr = std::shared_ptr< ExprElement > |
| A safe, polymorphic pointer to an element for container use. More... | |
|
inherited |
A safe, polymorphic pointer to an element for container use.
Definition at line 68 of file expressions.h.
|
inlinevirtual |
Must return the kind of the element: datum, grouping or operation.
Implements elementa::parsing::ExprElement.
Definition at line 198 of file expressions.h.
|
inlinenoexceptinherited |
Return TRUE if the element is a datum (not a grouping).
Definition at line 114 of file expressions.h.
References elementa::parsing::ExprElement::kind().
Referenced by elementa::parsing::ExprElement::isDatumTypedAs().
|
inlinenoexceptinherited |
Return TRUE if the element is an operation.
Definition at line 117 of file expressions.h.
References elementa::parsing::ExprElement::kind().
|
inlinenoexceptinherited |
Return TRUE if the element is an opening grouping.
Definition at line 120 of file expressions.h.
References elementa::parsing::ExprElement::kind().
Referenced by elementa::parsing::ExprElement::isGrouping().
|
inlinenoexceptinherited |
Return TRUE if the element is a closing grouping.
Definition at line 124 of file expressions.h.
References elementa::parsing::ExprElement::kind().
Referenced by elementa::parsing::ExprElement::isGrouping().
|
inlinenoexceptinherited |
Return TRUE if the element is a grouping.
Definition at line 128 of file expressions.h.
References elementa::parsing::ExprElement::isClosingGrouping(), and elementa::parsing::ExprElement::isOpeningGrouping().
|
inlinenoexceptinherited |
Return TRUE if the element is an opening args.
Definition at line 132 of file expressions.h.
References elementa::parsing::ExprElement::kind().
Referenced by elementa::parsing::ExprElement::isGroupingArgs().
|
inlinenoexceptinherited |
Return TRUE if the element is a closing args.
Definition at line 136 of file expressions.h.
References elementa::parsing::ExprElement::kind().
Referenced by elementa::parsing::ExprElement::isGroupingArgs().
|
inlinenoexceptinherited |
Return TRUE if the element is an args grouping.
Definition at line 140 of file expressions.h.
References elementa::parsing::ExprElement::isClosingArgs(), and elementa::parsing::ExprElement::isOpeningArgs().
|
inlinenoexceptinherited |
Return TRUE if the element is a sep args.
Definition at line 144 of file expressions.h.
References elementa::parsing::ExprElement::kind().
|
inlinenoexceptinherited |
Return TRUE if the element is a datum of a given type.
Definition at line 148 of file expressions.h.
References elementa::parsing::ExprElement::isDatum(), and elementa::parsing::ExprElement::type().
|
inlinevirtualinherited |
Can be overriden to return the type of the element (an int value).
Override it to provide a particular type if you are working with typed expressions. Ignore it otherwise.
Definition at line 157 of file expressions.h.
Referenced by elementa::parsing::ExprElement::isDatumTypedAs().
|
inlinevirtualinherited |
Reimplemented in elementa::parsing::Expression::OpDatumWrapper.
Definition at line 160 of file expressions.h.
| class elementa::parsing::ExprSimpleArgsSep |
A simple args-separator expression element.
Definition at line 202 of file expressions.h.


Public Member Functions | |
| Kind | kind (void) const |
| Must return the kind of the element: datum, grouping or operation. More... | |
Virtual methods | |
| bool | isDatum (void) const noexcept |
| Return TRUE if the element is a datum (not a grouping). More... | |
| bool | isOperation (void) const noexcept |
| Return TRUE if the element is an operation. More... | |
| bool | isOpeningGrouping (void) const noexcept |
| Return TRUE if the element is an opening grouping. More... | |
| bool | isClosingGrouping (void) const noexcept |
| Return TRUE if the element is a closing grouping. More... | |
| bool | isGrouping (void) const noexcept |
| Return TRUE if the element is a grouping. More... | |
| bool | isOpeningArgs (void) const noexcept |
| Return TRUE if the element is an opening args. More... | |
| bool | isClosingArgs (void) const noexcept |
| Return TRUE if the element is a closing args. More... | |
| bool | isGroupingArgs (void) const noexcept |
| Return TRUE if the element is an args grouping. More... | |
| bool | isSepArgs (void) const noexcept |
| Return TRUE if the element is a sep args. More... | |
| bool | isDatumTypedAs (int ty) const noexcept |
| Return TRUE if the element is a datum of a given type. More... | |
| virtual int | type (void) const |
| Can be overriden to return the type of the element (an int value). More... | |
| virtual std::string | to_string (void) const |
Types, consts., etc. | |
| ELE_CLASS_ENUM (Kind, kDatum, kGroupOpen, kGroupClose, kArgsOpen, kArgsClose, kArgsSep, kOperation) | |
| Kind ot the elements. | |
| using | Ptr = std::shared_ptr< ExprElement > |
| A safe, polymorphic pointer to an element for container use. More... | |
|
inherited |
A safe, polymorphic pointer to an element for container use.
Definition at line 68 of file expressions.h.
|
inlinevirtual |
Must return the kind of the element: datum, grouping or operation.
Implements elementa::parsing::ExprElement.
Definition at line 206 of file expressions.h.
|
inlinenoexceptinherited |
Return TRUE if the element is a datum (not a grouping).
Definition at line 114 of file expressions.h.
References elementa::parsing::ExprElement::kind().
Referenced by elementa::parsing::ExprElement::isDatumTypedAs().
|
inlinenoexceptinherited |
Return TRUE if the element is an operation.
Definition at line 117 of file expressions.h.
References elementa::parsing::ExprElement::kind().
|
inlinenoexceptinherited |
Return TRUE if the element is an opening grouping.
Definition at line 120 of file expressions.h.
References elementa::parsing::ExprElement::kind().
Referenced by elementa::parsing::ExprElement::isGrouping().
|
inlinenoexceptinherited |
Return TRUE if the element is a closing grouping.
Definition at line 124 of file expressions.h.
References elementa::parsing::ExprElement::kind().
Referenced by elementa::parsing::ExprElement::isGrouping().
|
inlinenoexceptinherited |
Return TRUE if the element is a grouping.
Definition at line 128 of file expressions.h.
References elementa::parsing::ExprElement::isClosingGrouping(), and elementa::parsing::ExprElement::isOpeningGrouping().
|
inlinenoexceptinherited |
Return TRUE if the element is an opening args.
Definition at line 132 of file expressions.h.
References elementa::parsing::ExprElement::kind().
Referenced by elementa::parsing::ExprElement::isGroupingArgs().
|
inlinenoexceptinherited |
Return TRUE if the element is a closing args.
Definition at line 136 of file expressions.h.
References elementa::parsing::ExprElement::kind().
Referenced by elementa::parsing::ExprElement::isGroupingArgs().
|
inlinenoexceptinherited |
Return TRUE if the element is an args grouping.
Definition at line 140 of file expressions.h.
References elementa::parsing::ExprElement::isClosingArgs(), and elementa::parsing::ExprElement::isOpeningArgs().
|
inlinenoexceptinherited |
Return TRUE if the element is a sep args.
Definition at line 144 of file expressions.h.
References elementa::parsing::ExprElement::kind().
|
inlinenoexceptinherited |
Return TRUE if the element is a datum of a given type.
Definition at line 148 of file expressions.h.
References elementa::parsing::ExprElement::isDatum(), and elementa::parsing::ExprElement::type().
|
inlinevirtualinherited |
Can be overriden to return the type of the element (an int value).
Override it to provide a particular type if you are working with typed expressions. Ignore it otherwise.
Definition at line 157 of file expressions.h.
Referenced by elementa::parsing::ExprElement::isDatumTypedAs().
|
inlinevirtualinherited |
Reimplemented in elementa::parsing::Expression::OpDatumWrapper.
Definition at line 160 of file expressions.h.
| class elementa::parsing::ExprOperElement |
An element within an expression that is an operation with a fixed arity.
Definition at line 216 of file expressions.h.


Public Member Functions | |
Base methods (not overridable) | |
| Kind | kind (void) const |
| Return the kind of the element: an operation. More... | |
| unsigned char | arity (void) const |
| Return the arity -number of arguments- of the operation (from 0 on). More... | |
| virtual bool | inFixed (void) const |
| Return whether the op. must be in infix form if arity == 2 when in InFix. More... | |
| virtual ArgsGroupOmitting | argGroupingsOmit (void) const |
| Return how the args grouping are allowed to be in 0/1 arity ops. More... | |
| virtual ExprElement::Ptr | argsOpening (void) const |
| Return the opening argument element for this operation. More... | |
| virtual ExprElement::Ptr | argsClosing (void) const |
| Return the closing argument element for this operation. More... | |
| virtual ExprElement::Ptr | argsSeparating (void) const |
| Return the separating argument element for this operation. More... | |
Virtual methods | |
| virtual const ParamSpec & | prototype (void) const =0 |
| Must return a const reference to the specification of parms and return. More... | |
| virtual unsigned | precedence (void) const =0 |
| Must return a number that indicates the precedence of the operation. More... | |
| virtual bool | withResult (void) const |
| Can be overriden to return whether the operation produces a result. More... | |
Virtual methods | |
| bool | isDatum (void) const noexcept |
| Return TRUE if the element is a datum (not a grouping). More... | |
| bool | isOperation (void) const noexcept |
| Return TRUE if the element is an operation. More... | |
| bool | isOpeningGrouping (void) const noexcept |
| Return TRUE if the element is an opening grouping. More... | |
| bool | isClosingGrouping (void) const noexcept |
| Return TRUE if the element is a closing grouping. More... | |
| bool | isGrouping (void) const noexcept |
| Return TRUE if the element is a grouping. More... | |
| bool | isOpeningArgs (void) const noexcept |
| Return TRUE if the element is an opening args. More... | |
| bool | isClosingArgs (void) const noexcept |
| Return TRUE if the element is a closing args. More... | |
| bool | isGroupingArgs (void) const noexcept |
| Return TRUE if the element is an args grouping. More... | |
| bool | isSepArgs (void) const noexcept |
| Return TRUE if the element is a sep args. More... | |
| bool | isDatumTypedAs (int ty) const noexcept |
| Return TRUE if the element is a datum of a given type. More... | |
| virtual int | type (void) const |
| Can be overriden to return the type of the element (an int value). More... | |
| virtual std::string | to_string (void) const |
Types, consts., etc. | |
| using | VectorOfParamSpecs = std::vector< ParamSpec > |
| A number of specifications. More... | |
| ELE_CLASS_ENUM (ArgsGroupOmitting, CanOmit, MustOmit, CannotOmit) | |
| Mode of omitting args groupings for operations of arity 0 or 1. | |
Types, consts., etc. | |
| using | Ptr = std::shared_ptr< ExprElement > |
| A safe, polymorphic pointer to an element for container use. More... | |
| ELE_CLASS_ENUM (Kind, kDatum, kGroupOpen, kGroupClose, kArgsOpen, kArgsClose, kArgsSep, kOperation) | |
| Kind ot the elements. | |
| using elementa::parsing::ExprOperElement::VectorOfParamSpecs = std::vector<ParamSpec> |
|
inherited |
A safe, polymorphic pointer to an element for container use.
Definition at line 68 of file expressions.h.
|
inlinevirtual |
Return the kind of the element: an operation.
Implements elementa::parsing::ExprElement.
Definition at line 256 of file expressions.h.
|
inline |
Return the arity -number of arguments- of the operation (from 0 on).
Return the value using prototype() and withResult(), that must be provided by the derivative class.
Definition at line 262 of file expressions.h.
References ELE_CODE_INVSTATE, prototype(), and withResult().
|
inlinevirtual |
Return whether the op. must be in infix form if arity == 2 when in InFix.
Override it only in operations of arity 2 that cannot be in infix form, such as calls to functions with 2 parameters. The rest can leave it as it is here.
Definition at line 277 of file expressions.h.
|
inlinevirtual |
Return how the args grouping are allowed to be in 0/1 arity ops.
Only used if the operation is 0-arity or 1-arity; operations of 2-arity do not use arg groupings if they are infix and never when they are postfix, while >2-arity must always use arg groupings.
Reimplemented in elementa::parsing::ExprOperNop.
Definition at line 283 of file expressions.h.
|
inlinevirtual |
Return the opening argument element for this operation.
Definition at line 287 of file expressions.h.
|
inlinevirtual |
Return the closing argument element for this operation.
Definition at line 291 of file expressions.h.
|
inlinevirtual |
Return the separating argument element for this operation.
Definition at line 295 of file expressions.h.
|
pure virtual |
Must return a const reference to the specification of parms and return.
Recall that the prototype must include as first element the type of the return value of the operation, and then their args.
Implemented in elementa::parsing::ExprOperNop.
Referenced by arity().
|
pure virtual |
Must return a number that indicates the precedence of the operation.
If it is a 0-arity operation, it can return anything because it will be ignored. Highest numbers indicate highest precedences. The precedence indicates, in the case that an operation appears in a midfix expression right after another operation, which one is executed first (the one with greater precedence).
Implemented in elementa::parsing::ExprOperNop.
|
inlinevirtual |
Can be overriden to return whether the operation produces a result.
By default, the operation produces a result. It can be overriden for the cases where the operation produces side effects only.
Reimplemented in elementa::parsing::ExprOperNop.
Definition at line 321 of file expressions.h.
Referenced by arity().
|
inlinenoexceptinherited |
Return TRUE if the element is a datum (not a grouping).
Definition at line 114 of file expressions.h.
References elementa::parsing::ExprElement::kind().
Referenced by elementa::parsing::ExprElement::isDatumTypedAs().
|
inlinenoexceptinherited |
Return TRUE if the element is an operation.
Definition at line 117 of file expressions.h.
References elementa::parsing::ExprElement::kind().
|
inlinenoexceptinherited |
Return TRUE if the element is an opening grouping.
Definition at line 120 of file expressions.h.
References elementa::parsing::ExprElement::kind().
Referenced by elementa::parsing::ExprElement::isGrouping().
|
inlinenoexceptinherited |
Return TRUE if the element is a closing grouping.
Definition at line 124 of file expressions.h.
References elementa::parsing::ExprElement::kind().
Referenced by elementa::parsing::ExprElement::isGrouping().
|
inlinenoexceptinherited |
Return TRUE if the element is a grouping.
Definition at line 128 of file expressions.h.
References elementa::parsing::ExprElement::isClosingGrouping(), and elementa::parsing::ExprElement::isOpeningGrouping().
|
inlinenoexceptinherited |
Return TRUE if the element is an opening args.
Definition at line 132 of file expressions.h.
References elementa::parsing::ExprElement::kind().
Referenced by elementa::parsing::ExprElement::isGroupingArgs().
|
inlinenoexceptinherited |
Return TRUE if the element is a closing args.
Definition at line 136 of file expressions.h.
References elementa::parsing::ExprElement::kind().
Referenced by elementa::parsing::ExprElement::isGroupingArgs().
|
inlinenoexceptinherited |
Return TRUE if the element is an args grouping.
Definition at line 140 of file expressions.h.
References elementa::parsing::ExprElement::isClosingArgs(), and elementa::parsing::ExprElement::isOpeningArgs().
|
inlinenoexceptinherited |
Return TRUE if the element is a sep args.
Definition at line 144 of file expressions.h.
References elementa::parsing::ExprElement::kind().
|
inlinenoexceptinherited |
Return TRUE if the element is a datum of a given type.
Definition at line 148 of file expressions.h.
References elementa::parsing::ExprElement::isDatum(), and elementa::parsing::ExprElement::type().
|
inlinevirtualinherited |
Can be overriden to return the type of the element (an int value).
Override it to provide a particular type if you are working with typed expressions. Ignore it otherwise.
Definition at line 157 of file expressions.h.
Referenced by elementa::parsing::ExprElement::isDatumTypedAs().
|
inlinevirtualinherited |
Reimplemented in elementa::parsing::Expression::OpDatumWrapper.
Definition at line 160 of file expressions.h.
| class elementa::parsing::ExprOperNop |
An operation that takes no arguments and does nothing.
Definition at line 329 of file expressions.h.


Public Member Functions | |
| const ParamSpec & | prototype (void) const |
| Must return a const reference to the specification of parms and return. More... | |
| unsigned | precedence (void) const |
| Must return a number that indicates the precedence of the operation. More... | |
| bool | withResult (void) const override |
| Can be overriden to return whether the operation produces a result. More... | |
| ArgsGroupOmitting | argGroupingsOmit (void) const override |
| Return how the args grouping are allowed to be in 0/1 arity ops. More... | |
| std::string | to_string (void) const override |
Base methods (not overridable) | |
| Kind | kind (void) const |
| Return the kind of the element: an operation. More... | |
| unsigned char | arity (void) const |
| Return the arity -number of arguments- of the operation (from 0 on). More... | |
| virtual bool | inFixed (void) const |
| Return whether the op. must be in infix form if arity == 2 when in InFix. More... | |
| virtual ExprElement::Ptr | argsOpening (void) const |
| Return the opening argument element for this operation. More... | |
| virtual ExprElement::Ptr | argsClosing (void) const |
| Return the closing argument element for this operation. More... | |
| virtual ExprElement::Ptr | argsSeparating (void) const |
| Return the separating argument element for this operation. More... | |
Virtual methods | |
| bool | isDatum (void) const noexcept |
| Return TRUE if the element is a datum (not a grouping). More... | |
| bool | isOperation (void) const noexcept |
| Return TRUE if the element is an operation. More... | |
| bool | isOpeningGrouping (void) const noexcept |
| Return TRUE if the element is an opening grouping. More... | |
| bool | isClosingGrouping (void) const noexcept |
| Return TRUE if the element is a closing grouping. More... | |
| bool | isGrouping (void) const noexcept |
| Return TRUE if the element is a grouping. More... | |
| bool | isOpeningArgs (void) const noexcept |
| Return TRUE if the element is an opening args. More... | |
| bool | isClosingArgs (void) const noexcept |
| Return TRUE if the element is a closing args. More... | |
| bool | isGroupingArgs (void) const noexcept |
| Return TRUE if the element is an args grouping. More... | |
| bool | isSepArgs (void) const noexcept |
| Return TRUE if the element is a sep args. More... | |
| bool | isDatumTypedAs (int ty) const noexcept |
| Return TRUE if the element is a datum of a given type. More... | |
| virtual int | type (void) const |
| Can be overriden to return the type of the element (an int value). More... | |
Types, consts., etc. | |
| ELE_CLASS_ENUM (ArgsGroupOmitting, CanOmit, MustOmit, CannotOmit) | |
| Mode of omitting args groupings for operations of arity 0 or 1. | |
| using | VectorOfParamSpecs = std::vector< ParamSpec > |
| A number of specifications. More... | |
Types, consts., etc. | |
| ELE_CLASS_ENUM (Kind, kDatum, kGroupOpen, kGroupClose, kArgsOpen, kArgsClose, kArgsSep, kOperation) | |
| Kind ot the elements. | |
| using | Ptr = std::shared_ptr< ExprElement > |
| A safe, polymorphic pointer to an element for container use. More... | |
|
inherited |
|
inherited |
A safe, polymorphic pointer to an element for container use.
Definition at line 68 of file expressions.h.
|
inlinevirtual |
Must return a const reference to the specification of parms and return.
Recall that the prototype must include as first element the type of the return value of the operation, and then their args.
Implements elementa::parsing::ExprOperElement.
Definition at line 333 of file expressions.h.
|
inlinevirtual |
Must return a number that indicates the precedence of the operation.
If it is a 0-arity operation, it can return anything because it will be ignored. Highest numbers indicate highest precedences. The precedence indicates, in the case that an operation appears in a midfix expression right after another operation, which one is executed first (the one with greater precedence).
Implements elementa::parsing::ExprOperElement.
Definition at line 335 of file expressions.h.
|
inlineoverridevirtual |
Can be overriden to return whether the operation produces a result.
By default, the operation produces a result. It can be overriden for the cases where the operation produces side effects only.
Reimplemented from elementa::parsing::ExprOperElement.
Definition at line 336 of file expressions.h.
|
inlineoverridevirtual |
Return how the args grouping are allowed to be in 0/1 arity ops.
Only used if the operation is 0-arity or 1-arity; operations of 2-arity do not use arg groupings if they are infix and never when they are postfix, while >2-arity must always use arg groupings.
Reimplemented from elementa::parsing::ExprOperElement.
Definition at line 338 of file expressions.h.
|
inlineoverridevirtual |
Reimplemented from elementa::parsing::ExprElement.
Definition at line 341 of file expressions.h.
|
inlinevirtualinherited |
Return the kind of the element: an operation.
Implements elementa::parsing::ExprElement.
Definition at line 256 of file expressions.h.
|
inlineinherited |
Return the arity -number of arguments- of the operation (from 0 on).
Return the value using prototype() and withResult(), that must be provided by the derivative class.
Definition at line 262 of file expressions.h.
References ELE_CODE_INVSTATE, elementa::parsing::ExprOperElement::prototype(), and elementa::parsing::ExprOperElement::withResult().
|
inlinevirtualinherited |
Return whether the op. must be in infix form if arity == 2 when in InFix.
Override it only in operations of arity 2 that cannot be in infix form, such as calls to functions with 2 parameters. The rest can leave it as it is here.
Definition at line 277 of file expressions.h.
|
inlinevirtualinherited |
Return the opening argument element for this operation.
Definition at line 287 of file expressions.h.
|
inlinevirtualinherited |
Return the closing argument element for this operation.
Definition at line 291 of file expressions.h.
|
inlinevirtualinherited |
Return the separating argument element for this operation.
Definition at line 295 of file expressions.h.
|
inlinenoexceptinherited |
Return TRUE if the element is a datum (not a grouping).
Definition at line 114 of file expressions.h.
References elementa::parsing::ExprElement::kind().
Referenced by elementa::parsing::ExprElement::isDatumTypedAs().
|
inlinenoexceptinherited |
Return TRUE if the element is an operation.
Definition at line 117 of file expressions.h.
References elementa::parsing::ExprElement::kind().
|
inlinenoexceptinherited |
Return TRUE if the element is an opening grouping.
Definition at line 120 of file expressions.h.
References elementa::parsing::ExprElement::kind().
Referenced by elementa::parsing::ExprElement::isGrouping().
|
inlinenoexceptinherited |
Return TRUE if the element is a closing grouping.
Definition at line 124 of file expressions.h.
References elementa::parsing::ExprElement::kind().
Referenced by elementa::parsing::ExprElement::isGrouping().
|
inlinenoexceptinherited |
Return TRUE if the element is a grouping.
Definition at line 128 of file expressions.h.
References elementa::parsing::ExprElement::isClosingGrouping(), and elementa::parsing::ExprElement::isOpeningGrouping().
|
inlinenoexceptinherited |
Return TRUE if the element is an opening args.
Definition at line 132 of file expressions.h.
References elementa::parsing::ExprElement::kind().
Referenced by elementa::parsing::ExprElement::isGroupingArgs().
|
inlinenoexceptinherited |
Return TRUE if the element is a closing args.
Definition at line 136 of file expressions.h.
References elementa::parsing::ExprElement::kind().
Referenced by elementa::parsing::ExprElement::isGroupingArgs().
|
inlinenoexceptinherited |
Return TRUE if the element is an args grouping.
Definition at line 140 of file expressions.h.
References elementa::parsing::ExprElement::isClosingArgs(), and elementa::parsing::ExprElement::isOpeningArgs().
|
inlinenoexceptinherited |
Return TRUE if the element is a sep args.
Definition at line 144 of file expressions.h.
References elementa::parsing::ExprElement::kind().
|
inlinenoexceptinherited |
Return TRUE if the element is a datum of a given type.
Definition at line 148 of file expressions.h.
References elementa::parsing::ExprElement::isDatum(), and elementa::parsing::ExprElement::type().
|
inlinevirtualinherited |
Can be overriden to return the type of the element (an int value).
Override it to provide a particular type if you are working with typed expressions. Ignore it otherwise.
Definition at line 157 of file expressions.h.
Referenced by elementa::parsing::ExprElement::isDatumTypedAs().
| class elementa::parsing::Expression |
A general expression composed of a number of elements of type Element.
Definition at line 354 of file expressions.h.


Public Attributes | |
| T | elements |
| STL member. | |
Public Member Functions | |
| virtual std::string | to_string (void) const |
| Build a text with the sequence of elements. | |
Constructors. Copy ctor/assign copy smart pointers. | |
| Expression (Order order=Order::kInfix, const ExprElement::Ptr &groupopening=ExprElement::Ptr{new ExprSimpleGroupOpen{}}, const ExprElement::Ptr &groupclosing=ExprElement::Ptr{new ExprSimpleGroupClose{}}) | |
| Default constructor: empty expression in InFix. More... | |
| Expression (Order order, Base &&elems, const ExprElement::Ptr &groupopening=ExprElement::Ptr{new ExprSimpleGroupOpen{}}, const ExprElement::Ptr &groupclosing=ExprElement::Ptr{new ExprSimpleGroupClose{}}) | |
| Constructor from a list of elements assumed to be in the given order. More... | |
| Expression (const Expression &oth) | |
| Expression (Expression &&oth) | |
| Expression & | operator= (const Expression &oth) |
| Expression & | operator= (Expression &&oth) |
Getters | |
| Order | order (void) const |
| Return the current order of the expression. More... | |
| ExprElement::Ptr | buildTree (void) const |
| Build a tree from the expression and return the root node. More... | |
Checking/execution methods | |
| long | checkGrouping (void) const |
| Check grouping validity in the expression (not args-grouping). More... | |
| long | checkArgGrouping (void) const |
| The same as checkGrouping but for the args-open and -close elements. | |
| int | checkType (Base::const_iterator &errloc, const TypeCompatChecker &tcc=defaultTypeCompatChecker, const TypeConfirming &tcf=defaultTypeConfirming) const |
| Evaluate the type of the expression, returning the resulting type. More... | |
| ExprElement::Ptr | evaluate (Base::const_iterator &errloc, Evaluator &evaluator) const |
| Evaluate the expression using the given evaluator; only if postfix. More... | |
| bool | reduce (Evaluator &evaluator) |
| Reduce the expression partial or totally. More... | |
Transforming methods | |
| void | changeOrder (Order neword, bool forcegrouping=false) |
| Change the order of operations to NEWORD, if possible. More... | |
| void | deleteNOPs (void) |
| Delete all NOP operations. More... | |
| void | changeElements (const std::function< std::pair< bool, ExprElement::Ptr >(ExprElement::Ptr &) > &pred) |
| Change all elements in the expression that satisfy a predicate. More... | |
| void | deleteElements (const std::function< bool(ExprElement::Ptr &) > &pred) |
| Delete all elements in the expression that satisfy a predicate. More... | |
Types, consts., etc. | |
| using | Base = ExprElement::PList |
| Shortcut. More... | |
| using | Length = Base::size_type |
| Shortcut. More... | |
| using | Evaluator = std::function< ExprElement::Ptr(const ExprElement::Ptr &, const ExprElement::PList &) > |
| An evaluator function of a given operation or datum. More... | |
| using | TypeCompatChecker = std::function< bool(const ExprOperElement &, const ExprElement::Ptr &, ExprOperElement::ParamSpec::Base::size_type, int, int) > |
| An op arg type compatibility checker used when checking types. More... | |
| using | TypeConfirming = std::function< int(ExprOperElement &, const ExprOperElement::ParamSpec &, int) > |
| An op result type confirming routine used when checking types. More... | |
| ELE_CLASS_ENUM (Order, kPostfix, kInfix) | |
| Kind of ordering in the expression. More... | |
| static bool | defaultTypeCompatChecker (const ExprOperElement &oper, const ExprElement::Ptr &, ExprOperElement::ParamSpec::Base::size_type apos, int tparm, int targ) |
| Default compatibility checker. More... | |
| static int | defaultTypeConfirming (ExprOperElement &oper, const ExprOperElement::ParamSpec &actualproto, int proposed) |
| Default confirming routine that just return the proposed type. More... | |
Shortcut.
Definition at line 362 of file expressions.h.
| using elementa::parsing::Expression::Length = Base::size_type |
Shortcut.
Definition at line 365 of file expressions.h.
| using elementa::parsing::Expression::Evaluator = std::function< ExprElement::Ptr(const ExprElement::Ptr &, const ExprElement::PList &) > |
An evaluator function of a given operation or datum.
The first parameter is the operation, the second the list of operands, that is guaranteed to agree with the operation arity (type checking is not carried out) and to be all Datum. Any exception in the evaluator produced by some error in the expression should derive from EvalError. It will receive the list of operands for the operation (same length as its arity, and empty if arity is 0 or if the element is a datum), all of them of kind kDatum, in the same order as found in the expression. It must return either a new element of kind kDatum with the result or a copy of some argument if that is the resulting datum. If the operation has no result, then the returned ExprElement::Ptr will be discarded.
Definition at line 394 of file expressions.h.
| using elementa::parsing::Expression::TypeCompatChecker = std::function< bool(const ExprOperElement &, const ExprElement::Ptr &, ExprOperElement::ParamSpec::Base::size_type, int,int) > |
An op arg type compatibility checker used when checking types.
A routine that must return TRUE if an operation admitting a parameter of some type can also work if the argument passed is of another type. I.e., checker(oper,arg,apos,tparm,targ) must return TRUE if the operation OPER, when called with argument arg of type TARG for its parameter number APOS (from 0), which in principle should be of type TPARM, should not complaint.
Definition at line 406 of file expressions.h.
| using elementa::parsing::Expression::TypeConfirming = std::function< int(ExprOperElement &, const ExprOperElement::ParamSpec &, int) > |
An op result type confirming routine used when checking types.
The call confirming(const ExprOperElement & oper, const ExprOperElement::ParamSpec & proto, int proposed) receives in PROTO the actual prototype generated for the OPER operation during type checking of the expression, and the PROPOSED type by the prototype of the expression, and must return the same proposed type or any other if it wishes to cast.
Definition at line 420 of file expressions.h.
|
inline |
Default constructor: empty expression in InFix.
| groupopening,groupclosing | are used to generate kInFix expressions automatically from kPostFix. |
Definition at line 568 of file expressions.h.
|
inline |
Constructor from a list of elements assumed to be in the given order.
Move the others elements inside this.
Definition at line 580 of file expressions.h.
|
inline |
Definition at line 590 of file expressions.h.
|
inline |
Definition at line 591 of file expressions.h.
| elementa::parsing::Expression::ELE_CLASS_ENUM | ( | Order | , |
| kPostfix | , | ||
| kInfix | |||
| ) |
Kind of ordering in the expression.
|
inlinestatic |
Default compatibility checker.
Return TRUE only if both parameter and argument have the same type.
Definition at line 427 of file expressions.h.
|
inlinestatic |
Default confirming routine that just return the proposed type.
Definition at line 435 of file expressions.h.
|
inline |
Definition at line 592 of file expressions.h.
|
inline |
Definition at line 594 of file expressions.h.
|
inline |
Return the current order of the expression.
Definition at line 604 of file expressions.h.
| ExprElement::Ptr elementa::parsing::Expression::buildTree | ( | void | ) | const |
Build a tree from the expression and return the root node.
This only works if the expression is in Postfix order. The returned element actually contains a pointer to a TreeNode.
| long elementa::parsing::Expression::checkGrouping | ( | void | ) | const |
Check grouping validity in the expression (not args-grouping).
Only for kInfix expressions. If grouping is valid, return 0. Otherwise, return the number of unbalanced grouping indicators: positive if there are more opening than closings, negative if there are more closings than openings.
| int elementa::parsing::Expression::checkType | ( | Base::const_iterator & | errloc, |
| const TypeCompatChecker & | tcc = defaultTypeCompatChecker, |
||
| const TypeConfirming & | tcf = defaultTypeConfirming |
||
| ) | const |
Evaluate the type of the expression, returning the resulting type.
This method also check the correct arities in all arguments of operations. Throw if any error. Cannot work with expressions that are not in kPostfix order.
| errloc | will be filled with the location of the offending element if any error. |
| tcc | is the type compatibility checker to be used. It will be called for every argument type in operation calls, not for datum. |
| tcf | is the type confirming routine to be used. It will be called for every operation that has a return type, not for datum, and after tcc has done its work on all arguments. |
| ExprElement::Ptr elementa::parsing::Expression::evaluate | ( | Base::const_iterator & | errloc, |
| Evaluator & | evaluator | ||
| ) | const |
Evaluate the expression using the given evaluator; only if postfix.
The arguments passed to the evaluator in each operation are not checked against type, i.e., they are ok for this method as long as they are of kind ExprElement::kDatum. Return the resulting datum, that can be either a copy of any of the data in the expression or a new object resulting from calculations. If some error is detected during the execution, fill ERRLOC with an iterator pointing just before the offending element, and then throw. All errors throw by this method must be derived from EvalError.
| bool elementa::parsing::Expression::reduce | ( | Evaluator & | evaluator | ) |
Reduce the expression partial or totally.
It only works in postfix order. The EVALUATOR must throw EvalError if a part of the evaluation cannot be reduced, or a valid value for the reduction otherwise. The difference between this method and evaluate() is that in this one the evaluator will be called after any error to detect other parts of the expression that can be reduced. Return TRUE if the original expression has changed.
| void elementa::parsing::Expression::changeOrder | ( | Order | neword, |
| bool | forcegrouping = false |
||
| ) |
Change the order of operations to NEWORD, if possible.
This method check some issues, such as unbalanced groupings, but not others, such as invalid use of arities. Do nothing if the expression is already in the desired order. \parm neword is the target order. \parm forcegrouping includes groupings when some changes of order occur even if those groupings are not needed according to the precedences of operators; if FALSE, only the strictly needed groupings for disambiguating operators according to their precedences are included (i.e., FALSE should be enough for most cases).
| void elementa::parsing::Expression::deleteNOPs | ( | void | ) |
Delete all NOP operations.
NOP operations must be of class ExprOperNop of derived from it.
| void elementa::parsing::Expression::changeElements | ( | const std::function< std::pair< bool, ExprElement::Ptr >(ExprElement::Ptr &) > & | pred | ) |
Change all elements in the expression that satisfy a predicate.
| pred | must return a pair with the first value a boolean indicating whether to change the element and the second value, if the first one is true, with the new element to use. If the first one is false, the second value of the pair is not used. |
| void elementa::parsing::Expression::deleteElements | ( | const std::function< bool(ExprElement::Ptr &) > & | pred | ) |
Delete all elements in the expression that satisfy a predicate.
| pred | must return TRUE to delete that element. |