NewtParser.c

構文木の生成 [詳細]

#include <stdlib.h>
#include <string.h>
#include "NewtParser.h"
#include "NewtErrs.h"
#include "NewtMem.h"
#include "NewtObj.h"
#include "NewtEnv.h"
#include "NewtFns.h"
#include "NewtVM.h"
#include "NewtIO.h"
#include "NewtPrint.h"
#include "yacc.h"

ソースコードを見る。

データ構造

struct  nps_inputdata_t
 入力データ [詳細]

マクロ定義

#define STREESTACK   ((nps_syntax_node_t *)nps_stree.stackp)
 構文木スタック
#define CX   (nps_stree.sp)
 構文木スタックポインタ

関数

static void NPSBindParserInput (const char *s)
static int nps_yyinput_str (char *buff, int max_size)
static void NPSInit (newtPool pool)
static void NPSPrintNode (FILE *f, nps_node_t r)
static void NPSPrintSyntaxCode (FILE *f, uint32_t code)
int nps_yyinput (FILE *yyin, char *buff, int max_size)
newtErr NPSParse (const char *path, nps_syntax_node_t **streeP, uint32_t *sizeP, bool is_file)
newtErr NPSParseFile (const char *path, nps_syntax_node_t **streeP, uint32_t *sizeP)
newtErr NPSParseStr (const char *s, nps_syntax_node_t **streeP, uint32_t *sizeP)
void NPSCleanup (void)
void NPSDumpSyntaxTree (FILE *f, nps_syntax_node_t *stree, uint32_t size)
nps_node_t NPSGenNode0 (uint32_t code)
nps_node_t NPSGenNode1 (uint32_t code, nps_node_t op1)
nps_node_t NPSGenNode2 (uint32_t code, nps_node_t op1, nps_node_t op2)
nps_node_t NPSGenOP1 (uint32_t op, nps_node_t op1)
nps_node_t NPSGenOP2 (uint32_t op, nps_node_t op1, nps_node_t op2)
nps_node_t NPSGenSend (nps_node_t receiver, uint32_t op, nps_node_t msg, nps_node_t args)
nps_node_t NPSGenResend (uint32_t op, nps_node_t msg, nps_node_t args)
nps_node_t NPSGenIfThenElse (nps_node_t cond, nps_node_t ifthen, nps_node_t ifelse)
nps_node_t NPSGenForLoop (nps_node_t index, nps_node_t v, nps_node_t to, nps_node_t by, nps_node_t expr)
nps_node_t NPSGenForeach (nps_node_t index, nps_node_t val, nps_node_t obj, nps_node_t deeply, nps_node_t op, nps_node_t expr)
nps_node_t NPSGenGlobalFn (nps_node_t name, nps_node_t args, nps_node_t expr)
newtRef NPSMakePathExpr (newtRefArg sym1, newtRefArg sym2)
newtRef NPSMakeArray (newtRefArg v)
newtRef NPSAddArraySlot (newtRefArg r, newtRefArg v)
newtRef NPSInsertArraySlot (newtRefArg r, uint32_t p, newtRefArg v)
newtRef NPSMakeMap (newtRefArg v)
newtRef NPSMakeFrame (newtRefArg slot, newtRefArg v)
newtRef NPSSetSlot (newtRefArg r, newtRefArg slot, newtRefArg v)
newtRef NPSMakeBinary (newtRefArg v)
newtRef NPSAddARef (newtRefArg r, newtRefArg v)
void NPSErrorStr (char c, char *s)
void NPSError (int32_t err)

変数

nps_env_t nps_env
 パーサ環境
static newtStack nps_stree
 構文木スタック情報
static nps_inputdata_t nps_inputdata
 入力データ


説明

構文木の生成

作者:
M.Nukui
日付:
2003-11-07
Copyright (C) 2003-2004 M.Nukui All rights reserved.

NewtParser.c で定義されています。


関数

int nps_yyinput ( FILE *  yyin,
char *  buff,
int  max_size 
)

構文解析するデータを取出す

引数:
yyin [in] 入力ファイル
buff [out]バッファ
max_size [in] 最大長
戻り値:
取出したデータサイズ

NewtParser.c120 行で定義されています。

参照先 nps_inputdata_t::datanps_inputdatanps_yyinput_str().

関数の呼び出しグラフ:

int nps_yyinput_str ( char *  buff,
int  max_size 
) [static]

構文解析するデータを文字列から取出す

引数:
buff [out]バッファ
max_size [in] 最大長
戻り値:
取出したデータサイズ

NewtParser.c93 行で定義されています。

参照先 nps_inputdata_t::currpnps_inputdata_t::limitnps_inputdata.

参照元 nps_yyinput().

newtRef NPSAddARef ( newtRefArg  r,
newtRefArg  v 
)

バイナリオブジェクトの最後にデータを追加

引数:
r [in] バイナリオブジェクト
v [in] 追加するデータ
戻り値:
バイナリオブジェクト

NewtParser.c968 行で定義されています。

参照先 NewtBinaryLength()NewtBinarySetLength()NewtSetARef().

関数の呼び出しグラフ:

newtRef NPSAddArraySlot ( newtRefArg  r,
newtRefArg  v 
)

配列オブジェクトの最後にオブジェクトを追加する

引数:
r [in] 配列オブジェクト
v [in] 追加するオブジェクト
戻り値:
配列オブジェクト

NewtParser.c831 行で定義されています。

参照先 NcAddArraySlot().

関数の呼び出しグラフ:

void NPSBindParserInput ( const char *  s  )  [static]

構文解析する文字列をセットする

引数:
s [in] 文字列
戻り値:
なし

NewtParser.c73 行で定義されています。

参照先 nps_inputdata_t::currpnps_inputdata_t::datanps_inputdata_t::limitnps_inputdata.

参照元 NPSParseStr().

void NPSCleanup ( void   ) 

構文解析の後始末

戻り値:
なし

NewtParser.c263 行で定義されています。

参照先 NewtStackFree()nps_stree.

参照元 NBCCompileFile()NBCCompileStr()NPSParse()NVMInterpret2().

関数の呼び出しグラフ:

void NPSDumpSyntaxTree ( FILE *  f,
nps_syntax_node_t stree,
uint32_t  size 
)

構文木をダンプする

引数:
f [in] 出力ファイル
stree [in] 構文木
size [in] 構文木のサイズ
戻り値:
なし

NewtParser.c414 行で定義されています。

参照先 nps_syntax_node_t::codekNPSAddkNPSFreqFunckNPSPopHandlersNewtFprintf()NPSPrintNode()NPSPrintSyntaxCode()NVMDumpInstName()nps_syntax_node_t::op1nps_syntax_node_t::op2.

参照元 NPSParse().

関数の呼び出しグラフ:

void NPSError ( int32_t  err  ) 

構文エラー

引数:
err [in] エラーコード
戻り値:
なし

NewtParser.c1022 行で定義されています。

参照先 yyerror().

参照元 NPSGenOP1()NPSGenOP2().

関数の呼び出しグラフ:

void NPSErrorStr ( char  c,
char *  s 
)

エラーメッセージの表示

引数:
c [in] エラー種別
s [in] エラーメッセージ
戻り値:
なし

NewtParser.c990 行で定義されています。

参照先 nps_env_t::fnamenps_env_t::linebufnps_env_t::linenoNewtFprintf()nps_envnps_env_t::numerrsnps_env_t::numwarnsnps_env_t::tokenposnps_env_t::yyleng.

参照元 yyerror().

関数の呼び出しグラフ:

nps_node_t NPSGenForeach ( nps_node_t  index,
nps_node_t  val,
nps_node_t  obj,
nps_node_t  deeply,
nps_node_t  op,
nps_node_t  expr 
)

FOREACH 文のオペノードを作成

引数:
index [in] インデックス変数
val [in] 値を格納する変数
obj [in] ループの対象となるオブジェクト
deeply [in] deeply フラグ
op [in] オペレーション種別(DO or COLLECT)
expr [in] 繰り返し式
戻り値:
ノード

NewtParser.c739 行で定義されています。

参照先 kNewtRefUnbindNewtMakeArray()NewtSetArraySlot()NPSGenNode2().

関数の呼び出しグラフ:

nps_node_t NPSGenForLoop ( nps_node_t  index,
nps_node_t  v,
nps_node_t  to,
nps_node_t  by,
nps_node_t  expr 
)

FOR 文のオペノードを作成

引数:
index [in] インデックス変数
v [in] 初期値
to [in] 終了値
by [in] ステップ値
expr [in] 繰り返し式
戻り値:
ノード

NewtParser.c711 行で定義されています。

参照先 kNewtRefUnbindNewtMakeArray()NewtSetArraySlot()NPSGenNode2().

関数の呼び出しグラフ:

nps_node_t NPSGenGlobalFn ( nps_node_t  name,
nps_node_t  args,
nps_node_t  expr 
)

グローバル関数のオペノードを作成

引数:
name [in] 関数名
args [in] 関数の引数
expr [in] 実行式
戻り値:
ノード

NewtParser.c765 行で定義されています。

参照先 NPSGenNode2().

関数の呼び出しグラフ:

nps_node_t NPSGenIfThenElse ( nps_node_t  cond,
nps_node_t  ifthen,
nps_node_t  ifelse 
)

条件文のオペノードを作成

引数:
cond [in] 条件式
ifthen [in] THEN 式
ifelse [in] ELSE 式
戻り値:
ノード

NewtParser.c680 行で定義されています。

参照先 kNewtRefUnbindNewtMakeArray()NewtSetArraySlot()NPSGenNode2().

関数の呼び出しグラフ:

nps_node_t NPSGenNode0 ( uint32_t  code  ) 

引数0のノードを作成

引数:
code [in] 構文コード
戻り値:
ノード

NewtParser.c455 行で定義されています。

参照先 kNewtRefUnbindNPSGenNode2().

関数の呼び出しグラフ:

nps_node_t NPSGenNode1 ( uint32_t  code,
nps_node_t  op1 
)

引数1のノードを作成

引数:
code [in] 構文コード
op1 [in] 引数1
戻り値:
ノード

NewtParser.c470 行で定義されています。

参照先 kNewtRefUnbindNPSGenNode2().

参照元 NPSGenOP1().

関数の呼び出しグラフ:

nps_node_t NPSGenNode2 ( uint32_t  code,
nps_node_t  op1,
nps_node_t  op2 
)

引数2のノードを作成

引数:
code [in] 構文コード
op1 [in] 引数1
op2 [in] 引数2
戻り値:
ノード

NewtParser.c486 行で定義されています。

参照先 nps_syntax_node_t::codeCXNewtStackExpand()nps_streeNPSMakeSyntaxNodenps_syntax_node_t::op1nps_syntax_node_t::op2STREESTACKyyerror().

参照元 NPSGenForeach()NPSGenForLoop()NPSGenGlobalFn()NPSGenIfThenElse()NPSGenNode0()NPSGenNode1()NPSGenOP2()NPSGenResend()NPSGenSend().

関数の呼び出しグラフ:

nps_node_t NPSGenOP1 ( uint32_t  op,
nps_node_t  op1 
)

引数1のオペレータノードを作成

引数:
op [in] オペコード
op1 [in] 引数1
戻り値:
ノード

NewtParser.c517 行で定義されています。

参照先 kNErrSyntaxErrorkNewtRefUnbindkNPS_NOTkNPSNotKNPSUnknownCodeNPSError()NPSGenNode1().

関数の呼び出しグラフ:

nps_node_t NPSGenOP2 ( uint32_t  op,
nps_node_t  op1,
nps_node_t  op2 
)

引数2のオペレータノードを作成

引数:
op [in] オペコード
op1 [in] 引数1
op2 [in] 引数2
戻り値:
ノード

NewtParser.c546 行で定義されています。

参照先 kNErrSyntaxErrorkNewtRefUnbindkNPS_CONCAT2kNPS_DIVkNPS_GREATER_EQUALkNPS_LESS_EQUALkNPS_MODkNPS_NOT_EQUALkNPS_OBJECT_EQUALkNPS_SHIFT_LEFTkNPS_SHIFT_RIGHTkNPSAddkNPSConcatkNPSConcat2kNPSDivkNPSDividekNPSEqualskNPSGreaterOrEqualkNPSGreaterThankNPSLessOrEqualkNPSLessThankNPSModkNPSMultiplykNPSNotEqualkNPSObjectEqualkNPSShiftLeftkNPSShiftRightkNPSSubtractKNPSUnknownCodeNPSError()NPSGenNode2().

関数の呼び出しグラフ:

nps_node_t NPSGenResend ( uint32_t  op,
nps_node_t  msg,
nps_node_t  args 
)

メッセージ再送信のオペノードを作成

引数:
op [in] オペコード
msg [in] メッセージ
args [in] メッセージの引数
戻り値:
ノード

NewtParser.c662 行で定義されています。

参照先 kNPSResendkNPSResendIfDefinedNPSGenNode2().

関数の呼び出しグラフ:

nps_node_t NPSGenSend ( nps_node_t  receiver,
uint32_t  op,
nps_node_t  msg,
nps_node_t  args 
)

メッセージ送信のオペノードを作成

引数:
receiver [in] レシーバ
op [in] オペコード
msg [in] メッセージ
args [in] メッセージの引数
戻り値:
ノード

NewtParser.c640 行で定義されています。

参照先 kNPSSendkNPSSendIfDefinedNPSGenNode2().

関数の呼び出しグラフ:

void NPSInit ( newtPool  pool  )  [static]

構文解析のための初期化

引数:
pool [in] メモリプール
戻り値:
なし

NewtParser.c138 行で定義されています。

参照先 nps_env_t::first_timenps_env_t::fnamenps_env_t::linebufnps_env_t::linenoNEWT_NUM_STREESTACKNEWT_POOLNewtStackSetup()nps_envnps_streenps_env_t::numerrsnps_env_t::numwarnsnps_env_t::tokenpos.

参照元 NPSParse().

関数の呼び出しグラフ:

newtRef NPSInsertArraySlot ( newtRefArg  r,
uint32_t  p,
newtRefArg  v 
)

配列オブジェクトのオブジェクトを挿入する

引数:
r [in] 配列オブジェクト
p [in] 挿入する位置
v [in] 挿入るオブジェクト
戻り値:
配列オブジェクト

NewtParser.c848 行で定義されています。

参照先 NewtInsertArraySlot().

関数の呼び出しグラフ:

newtRef NPSMakeArray ( newtRefArg  v  ) 

配列オブジェクトの作成

引数:
v [in] 初期値
戻り値:
配列オブジェクト

NewtParser.c804 行で定義されています。

参照先 kNewtRefUnbindNewtMakeArray()NewtSetArraySlot().

関数の呼び出しグラフ:

newtRef NPSMakeBinary ( newtRefArg  v  ) 

バイナリオブジェクトの作成

引数:
v [in] 初期値
戻り値:
バイナリオブジェクト

NewtParser.c935 行で定義されています。

参照先 kNewtRefUnbindNcClone()NcSetClass()NewtBinarySetLength()NewtMakeBinary()NewtRefIsString()NewtSetARef()NewtStringLength().

関数の呼び出しグラフ:

newtRef NPSMakeFrame ( newtRefArg  slot,
newtRefArg  v 
)

フレームオブジェクトの作成

引数:
slot [in] スロットシンボル
v [in] 初期値
戻り値:
フレームオブジェクト

NewtParser.c891 行で定義されています。

参照先 NcMakeFrameNewtMakeFrame2()NewtRefIsNIL().

関数の呼び出しグラフ:

newtRef NPSMakeMap ( newtRefArg  v  ) 

フレームマップオブジェクトの作成

引数:
v [in] 初期値
戻り値:
フレームマップオブジェクト

NewtParser.c864 行で定義されています。

参照先 kNewtRefNILkNewtRefUnbindNewtMakeMap()NewtSetArraySlot().

関数の呼び出しグラフ:

newtRef NPSMakePathExpr ( newtRefArg  sym1,
newtRefArg  sym2 
)

参照パスオブジェクトの作成

引数:
sym1 [in] シンボル1
sym2 [in] シンボル2
戻り値:
参照パスオブジェクト

NewtParser.c784 行で定義されています。

参照先 NewtMakeArray()NewtSetArraySlot()NSSYM0.

関数の呼び出しグラフ:

newtErr NPSParse ( const char *  path,
nps_syntax_node_t **  streeP,
uint32_t *  sizeP,
bool  is_file 
)

構文解析する

引数:
path [in] 入力ファイルのパス
streeP [out]構文木
sizeP [out]構文木のサイズ
is_file [in] ファイルかどうか(#! 処理をおこなうかどうか)
戻り値:
エラーコード

NewtParser.c165 行で定義されています。

参照先 CXnps_env_t::first_timenps_env_t::fnamekNErrNonekNErrSyntaxErrorNEWT_DUMPSYNTAXNewtFprintf()NewtStackSlim()nps_envnps_streeNPSCleanup()NPSDumpSyntaxTree()NPSInit()nps_env_t::numerrsSTREESTACK.

参照元 NPSParseFile()NPSParseStr().

関数の呼び出しグラフ:

newtErr NPSParseFile ( const char *  path,
nps_syntax_node_t **  streeP,
uint32_t *  sizeP 
)

指定されたファイルをソースに構文解析する

引数:
path [in] 入力ファイルのパス
streeP [out]構文木
sizeP [out]構文木のサイズ
戻り値:
エラーコード

NewtParser.c207 行で定義されています。

参照先 kNErrFileNotOpenNewtFprintf()NPSParse()yyin.

参照元 NBCCompileFile()NVMInterpretFile().

関数の呼び出しグラフ:

newtErr NPSParseStr ( const char *  s,
nps_syntax_node_t **  streeP,
uint32_t *  sizeP 
)

文字列をソースに構文解析する

引数:
s [in] 入力データ
streeP [out]構文木
sizeP [out]構文木のサイズ
戻り値:
エラーコード

NewtParser.c244 行で定義されています。

参照先 NPSBindParserInput()NPSParse().

参照元 NBCCompileStr()NVMInterpretStr().

関数の呼び出しグラフ:

void NPSPrintNode ( FILE *  f,
nps_node_t  r 
) [static]

構文木のノードを印字する

引数:
f [in] 出力ファイル
r [in] ノード
戻り値:
なし

NewtParser.c279 行で定義されています。

参照先 NewtFprintf()NewtPrintObj()NPSRefIsSyntaxNodeNPSRefToSyntaxNode.

参照元 NPSDumpSyntaxTree().

関数の呼び出しグラフ:

void NPSPrintSyntaxCode ( FILE *  f,
uint32_t  code 
) [static]

構文コードを印字する

引数:
f [in] 出力ファイル
code [in] 構文コード
戻り値:
なし

NewtParser.c297 行で定義されています。

参照先 NewtFprintf().

参照元 NPSDumpSyntaxTree().

関数の呼び出しグラフ: