pike.git
/
src
/
modules
/
Parser
/
parser.c
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/modules/Parser/parser.c:1:
+
/*
+
|| This file is part of Pike. For copyright information see COPYRIGHT.
+
|| Pike is distributed under GPL, LGPL and MPL. See the file COPYING
+
|| for more information.
+
*/
+
#include "global.h" #include "stralloc.h" #include "global.h"
-
RCSID("$Id: parser.c,v 1.11 2000/12/01 08:10:18 hubbe Exp $");
+
#include "pike_macros.h" #include "interpret.h" #include "program.h" #include "program_id.h" #include "object.h" #include "operators.h"
-
+
#include "module.h"
#include "parser.h"
-
/* must be included last */
-
#include "module_magic.h"
+
-
+
#define sp Pike_sp
+
#define fp Pike_fp
+
#define PARSER_INITER /*#define DEBUG*/ #define PARSER_CLASS(name,init,exit,prog,id) \ void init(void); void exit(void); struct program *prog; #define PARSER_SUBMODULE(name,init,exit) \ void init(void); void exit(void); #define PARSER_SUBMODMAG(name,init,exit) \ void init(void); void exit(void);
pike.git/src/modules/Parser/parser.c:76:
#undef PARSER_SUBMODMAG #define PARSER_SUBMODULE(a,b,c) #define PARSER_SUBMODMAG(name,init,exit) { name,init,exit,NULL,NULL }, #include "initstuff.h" { 0,0,0,0,0 } }; #ifdef PIKE_DEBUG #define PARSER_CHECK_STACK(X) do { \ if (save_sp != sp) { \
-
fatal("%s:%d: %ld droppings on stack! previous init: %s\n", \
+
Pike_
fatal("%s:%d: %ld droppings on stack! previous init: %s\n", \
__FILE__, __LINE__, \ PTRDIFF_T_TO_LONG(sp - save_sp), X); \ } \ } while(0) #else #define PARSER_CHECK_STACK(X) #endif /* PIKE_DEBUG */
-
+
/*! @module Parser
+
*/
-
+
/*! @module _parser
+
*!
+
*! Low-level helpers for parsers.
+
*!
+
*! @note
+
*! You probably don't want to use the modules contained in
+
*! this module directly, but instead use the other @[Parser]
+
*! modules. See instead the modules below.
+
*!
+
*! @seealso
+
*! @[Parser], @[Parser.C], @[Parser.Pike], @[Parser.RCS],
+
*! @[Parser.HTML], @[Parser.XML]
+
*/
+
static void parser_magic_index(INT32 args) {
-
struct svalue tmp;
+
int i; if (args!=1) Pike_error("Parser.`[]: Too few or too many arguments\n");
-
if (sp[-1]
.type
!=T_STRING)
+
if (
TYPEOF(
sp[-1]
)
!=
T_STRING)
Pike_error("Parser.`[]: Illegal type of argument\n"); for (i=0; i<(int)NELEM(submagic)-1; i++) if (sp[-1].u.string==submagic[i].ps) { #ifdef PIKE_DEBUG struct svalue *save_sp; #endif pop_stack();
pike.git/src/modules/Parser/parser.c:128:
ref_push_object(submagic[i].o); return; } stack_dup(); ref_push_object(fp->current_object); stack_swap(); f_arrow(2);
-
if (sp[-1]
.type
==T_INT)
+
if (
TYPEOF(
sp[-1]
)
==
T_INT)
{ pop_stack(); stack_dup();
-
push_text("_Parser_");
+
push_
constant_
text("_Parser_");
stack_swap(); f_add(2);
-
push_int(0);
-
SAFE_APPLY_MASTER("resolv",
2
);
+
SAFE_APPLY_MASTER("resolv",
1
);
}
-
if (sp[-1]
.type
==T_INT)
+
if (
TYPEOF(
sp[-1]
)
==
T_INT)
{ pop_stack(); stack_dup();
-
push_text("_Parser");
-
push_int(0);
-
SAFE_APPLY_MASTER("resolv",
2
);
+
push_
constant_
text("_Parser");
+
SAFE_APPLY_MASTER("resolv",
1
);
stack_swap();
-
if(sp[-2]
.type
== T_INT)
+
if(
TYPEOF(
sp[-2]
)
== T_INT)
{ pop_stack(); }else{ f_index(2); } } stack_swap(); pop_stack(); }
-
void
pike
_
module
_
init(void)
+
/*!
@endmodule
+
*/
+
+
/*! @endmodule
+
*/
+
+
PIKE
_
MODULE
_
INIT
{ #ifdef PIKE_DEBUG struct svalue *save_sp = sp; #endif int i; for (i=0; i<(int)NELEM(initclass); i++) { start_new_program(); if (initclass[i].id) Pike_compiler->new_program->id = initclass[i].id;
pike.git/src/modules/Parser/parser.c:213:
submagic[i].ps=make_shared_string(submagic[i].name); #undef PARSER_FUNCTION #define PARSER_FUNCTION(name,func,def0,def1) ADD_FUNCTION(name,func,def0,def1); #include "initstuff.h" ADD_FUNCTION("`[]",parser_magic_index, tFunc(tString,tMixed),0); }
-
void pike
_
module
_
exit(void)
+
PIKE
_
MODULE
_
EXIT
{ int i; for (i=0; i<(int)NELEM(initclass); i++) { (initclass[i].exit)(); free_program(initclass[i].dest[0]); } for (i=0; i<(int)NELEM(initsubmodule)-1; i++) (initsubmodule[i].exit)(); for (i=0; i<(int)NELEM(submagic)-1; i++) if (submagic[i].o) { (submagic[i].exit)(); free_object(submagic[i].o); } }