import { PRuleResult, PElementResult } from "./PObjectMap"; import GRule from "./grammar/GRule"; /** * Grammar to object mapper. * * */ export default class ObjectMapper { static BAD_CHILD_TYPE_NODE: string; static UNNAMED_ARRAY: string; static CANNOT_SET_PROPERTY: string; static UNNAMED_HOIST_WITH_TREE: string; static OPTIONAL_RAW_TYPE_NODE: string; static COLLECTION_ON_TREE_TYPE_NODE: string; static INVALID_TREE_NODE: string; mapFrom(result: PRuleResult): void; private map; /** * Maps values of variables matched in the grammar to an object * @param data the parent data object - ie (var0)[(var1) (var2)] * @param collectionData parent collection object - ie ^(vars)* [(var1) (var2)] * @param isRoot indicates that this is the root node. * @return Returns the rule's matched tree node (^) if present, falling back to the type/hoist (^^) node if present, null otherwise. */ mapValues(result: PRuleResult, rule: GRule, data?: any, collectionData?: Array, isRoot?: boolean): PElementResult; private addData(item, e, varName, dataIsSimpleString, data, typeNode, treeNode, treeData, treeCollection, isRef, collectionData); private allowMany(item); /** * Iterate over a collection result, ie [...]* * * @result parent rule * @item element result /w multiple children * @childItems The array object into which child result are pushed * @childCollection c.f. parent array, ie ^(vars)* (morevars)* * */ private extractToCollection(result, item, childItems, childCollection?); private addCollectionData(childElement, childItems, value); /** * * @param force Create a simple Object even if we don't have a registered class type */ private createDataObject(r, force?, treeNode?, parentRule?); private createType(r, type); private rawContent(item, element); incrementalMap(out: PRuleResult): any; }