Frequently Used TypeDef Structures and Variables

From NARS2000
Revision as of 18:46, 6 August 2015 by Robert Wallick (talk | contribs) (created page, general outline, LPPL_YYSTYPE - Frequently Used TypeDef Structures and Variables)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

NARS C Source Code Frequently Used TypeDef Structures and Variables:

NARS has multiple frequently used TypeDefs, Structures, Type-Variables and Variables. Familiarity with these structures, including variables employed, is essential toward gaining increased understanding of how NARS C source code works, including insight into C program flow.

TypeDefs

LPPL_YYSTYPE

The full definition for typedef LPPL_YYTYPE is found in file <pl_parse.h>. Partial, extracted, compiler-directives-excluded/simplified definition:

typedef struct tagPL_YYSTYPE        // YYSTYPE for ParseLine
{
    // N.B.:  The first item in this struct *MUST* be the TOKEN
    //   because when we pass it as an argument to an LPPRIMFNS
    //   we might need it to be an LPPL_YYSTYPE (for a function strand)
    //   or an LPTOKEN (single function).
    TOKEN   tkToken;                // 00:  Token info (28 bytes)
    UINT    TknCount;               // 1C:  Count of adjacent tokens including this one
    UINT    YYInuse:1,              // 20:  00000001:  This entry is in use
            YYIndirect:1,           //      00000002:  Arg is indirect
            YYPerm:1,               //      00000004:  Item is permanent, don't free
            YYStranding:1,          //      00000008:  Item is in the process of being stranded
            :28;                    //      FFFFFFF0:  Available bits

    struct tagPL_YYSTYPE
           *lpYYFcnBase,            // 24:  Ptr to base function/operator
                                    //      Not valid outside the enclosing
                                    //        invocation of ParseLine
           *lpYYStrandBase,         // 28:  Ptr to this token's strand base
           *lpplYYArgCurry,         // 2C:  Ptr to left argument curry
           *lpplYYIdxCurry,         // 30:  Ptr to axis curry
           *lpplYYFcnCurry,         // 34:  ...         function ...
           *lpplYYOpRCurry;         // 38:  ...    right operand ...
    LPTOKEN lptkLftBrace,           // 3C:  Ptr to the AFO's left brace token
            lptkRhtBrace;           // 40:  ...              right ...
                                    // 44:  Length
} PL_YYSTYPE, *LPPL_YYSTYPE;        // Data type of yacc stack

LPPL_YYSTYPE is customarily variable-type for the following:

   LPPL_YYSTYPE lpYYRes = NULL,    // initialize, Ptr to result of a ⎕ quad system function call

and macro call:

   lpYYRes = YYAlloc ();           // Allocate free memory, fill LPPL_YYSTYPE memory structure with default setup/values

Variable Types

Variables