XenevaOS
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Enumerations | Functions
xe_script.cpp File Reference
#include "xe_script.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for xe_script.cpp:

Classes

struct  XsBlock
 
struct  XsArena
 
struct  Redir
 
struct  CaseItem
 
struct  Node
 
struct  Label
 
struct  Prog
 
struct  HHdr
 
struct  Var
 
struct  Func
 
struct  Frame
 
struct  Ob
 
struct  RbSlot
 
struct  Ar
 
struct  Parser
 
struct  ArgVec
 
struct  Ex
 
struct  IoSave
 
struct  BuiltinDef
 
struct  Ts
 

Macros

#define XS_VAR_SLOTS   256 /* power of two */
 
#define XS_FUNC_SLOTS   128 /* power of two */
 
#define XS_NAME_MAX   32
 
#define XS_VAL_MAX   256
 
#define XS_FIELD_MAX   1024
 
#define XS_SCRATCH   (64 * 1024)
 
#define XS_MAX_FRAMES   32
 
#define XS_MAX_DEPTH   64
 
#define XS_MAX_SCRIPT   (1 << 20)
 
#define XS_MAX_NEST   8
 
#define XS_FD_NULL   (-2)
 
#define BPUT(s)
 
#define XS_NBUILTINS   ((int)(sizeof(g_builtins) / sizeof(g_builtins[0])))
 

Typedefs

typedef struct XsBlock XsBlock
 
typedef struct XsArena XsArena
 
typedef struct Redir Redir
 
typedef struct CaseItem CaseItem
 
typedef struct Node Node
 
typedef struct HHdr HHdr
 
typedef struct Parser Parser
 
typedef int(* BuiltinFn) (int, char **)
 

Enumerations

enum  {
  N_CMD = 1 , N_AND , N_OR , N_PIPE ,
  N_NOT , N_IF , N_WHILE , N_FOR ,
  N_CASE , N_FUNC , N_GROUP , N_BCMD ,
  N_BIF , N_BFOR , N_GOTO , N_SELECT
}
 
enum  { R_IN , R_OUT , R_APP , R_DUP }
 
enum  { BK_EXIST = 1 , BK_DEF , BK_ERR , BK_CMP }
 
enum  {
  CMP_EQ = 1 , CMP_NE , CMP_LT , CMP_LE ,
  CMP_GT , CMP_GE
}
 
enum  {
  FL_NONE = 0 , FL_BREAK , FL_CONT , FL_RETURN ,
  FL_EXIT , FL_GOTO
}
 
enum  {
  T_EOF , T_NL , T_WORD , T_SEMI ,
  T_DSEMI , T_AMP , T_AND , T_OR ,
  T_PIPE , T_LP , T_RP , T_REDIR
}
 

Functions

bool XsScriptKind (const char *name, bool *isBat)
 
int XsRunText (const char *text, int len, bool bat, int argc, char **argv)
 
int XsRunFile (const char *path, int argc, char **argv)
 

Macro Definition Documentation

◆ BPUT

#define BPUT (   s)
Value:
do { \
const char* _s = (s); \
while (*_s && o < max - 1) \
out[o++] = *_s++; \
} while (0)
#define out(...)
Definition main.cpp:65
#define max(a, b)
Definition minmax.h:28

◆ XS_FD_NULL

#define XS_FD_NULL   (-2)

◆ XS_FIELD_MAX

#define XS_FIELD_MAX   1024

◆ XS_FUNC_SLOTS

#define XS_FUNC_SLOTS   128 /* power of two */

◆ XS_MAX_DEPTH

#define XS_MAX_DEPTH   64

◆ XS_MAX_FRAMES

#define XS_MAX_FRAMES   32

◆ XS_MAX_NEST

#define XS_MAX_NEST   8

◆ XS_MAX_SCRIPT

#define XS_MAX_SCRIPT   (1 << 20)

◆ XS_NAME_MAX

#define XS_NAME_MAX   32

◆ XS_NBUILTINS

#define XS_NBUILTINS   ((int)(sizeof(g_builtins) / sizeof(g_builtins[0])))

◆ XS_SCRATCH

#define XS_SCRATCH   (64 * 1024)

◆ XS_VAL_MAX

#define XS_VAL_MAX   256

◆ XS_VAR_SLOTS

#define XS_VAR_SLOTS   256 /* power of two */

BSD 2-Clause License

Copyright (c) 2022, Manas Kamal Choudhury All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. NOTE : GENERATED USING CLAUDE Sonnet 5.5 (Medium)

Typedef Documentation

◆ BuiltinFn

typedef int(* BuiltinFn) (int, char **)

◆ CaseItem

typedef struct CaseItem CaseItem

◆ HHdr

typedef struct HHdr HHdr

◆ Node

typedef struct Node Node

◆ Parser

typedef struct Parser Parser

◆ Redir

typedef struct Redir Redir

◆ XsArena

typedef struct XsArena XsArena

◆ XsBlock

typedef struct XsBlock XsBlock

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
N_CMD 
N_AND 
N_OR 
N_PIPE 
N_NOT 
N_IF 
N_WHILE 
N_FOR 
N_CASE 
N_FUNC 
N_GROUP 
N_BCMD 
N_BIF 
N_BFOR 
N_GOTO 
N_SELECT 

◆ anonymous enum

anonymous enum
Enumerator
R_IN 
R_OUT 
R_APP 
R_DUP 

◆ anonymous enum

anonymous enum
Enumerator
BK_EXIST 
BK_DEF 
BK_ERR 
BK_CMP 

◆ anonymous enum

anonymous enum
Enumerator
CMP_EQ 
CMP_NE 
CMP_LT 
CMP_LE 
CMP_GT 
CMP_GE 

◆ anonymous enum

anonymous enum
Enumerator
FL_NONE 
FL_BREAK 
FL_CONT 
FL_RETURN 
FL_EXIT 
FL_GOTO 

◆ anonymous enum

anonymous enum
Enumerator
T_EOF 
T_NL 
T_WORD 
T_SEMI 
T_DSEMI 
T_AMP 
T_AND 
T_OR 
T_PIPE 
T_LP 
T_RP 
T_REDIR 

Function Documentation

◆ XsRunFile()

int XsRunFile ( const char *  path,
int  argc,
char **  argv 
)

BSD 2-Clause License

Copyright (c) 2022, Manas Kamal Choudhury All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. NOTE : GENERATED USING CLAUDE Sonnet 5.5 (Medium)

◆ XsRunText()

int XsRunText ( const char *  text,
int  len,
bool  bat,
int  argc,
char **  argv 
)

◆ XsScriptKind()

bool XsScriptKind ( const char *  name,
bool *  isBat 
)