Not logged in
Diff

Differences From Artifact [dd44ba1520]:

  • File src/subscript.c — part of check-in [39aa870f8f] at 2007-10-14 00:29:14 on branch trunk — Work toward a new mechanism for configuring the ticket subsystem and rendering ticket entry, editing, and viewing screens. Nothing works, but it is all commented out so the code code compile. (user: drh size: 14793)

To Artifact [ad67c7f9bb]:

  • File src/subscript.c — part of check-in [8ffd32c2b7] at 2007-10-28 20:52:52 on branch trunk — Add the ability to edit the CSS for all pages in the Setup menu. Other miscellaneous changes toward getting ticketing to work. (user: drh size: 15726)

23
24
25
26
27
28
29
30

31
32





















33
34
35
36
37
38
39
23
24
25
26
27
28
29

30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60







-
+


+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







**
** This file contains an implementation of the "subscript" interpreter.
**
** Subscript attempts to be an extremely light-weight scripting
** language.  It contains the barest of bare essentials.  It is
** stack-based and forth-like.  Everything is in a single global
** namespace.  There is only a single datatype of zero-terminated
** string.  The stack is of fixed, limited depth.  The hash table
** string.  The stack is of fixed, limited depth.  The symbal table
** is of a limited and fixed size.
**
** TOKENS:
**
**      *  All tokens are separated from each other by whitespace.
**      *  Leading and trailing whitespace is ignored.
**      *  Text within nested {...} is a single string token.  The outermost
**         curly braces are not part of the token.
**      *  An identifier with a leading "/" is a string token.
**      *  A token that looks like a number is a string token.
**      *  An identifier token is called a "verb".
**
** PROCESSING:
**
**      *  The input is divided into tokens.  Whitespace is discarded.
**         String and verb tokens are passed into the engine.
**      *  String tokens are pushed onto the stack.
**      *  If a verb token corresponds to a procedure, that procedure is
**         run.  The procedure might use, pop, or pull elements from 
**         the stack.
**      *  If a verb token corresponds to a variable, the value of that
**         variable is pushed onto the stack.
**
** This module attempts to be completely self-contained so that it can
** be portable to other projects.
*/
#include "config.h"
#include "subscript.h"
#include <assert.h>

288
289
290
291
292
293
294
295

296
297
298
299
300
301
302
309
310
311
312
313
314
315

316
317
318
319
320
321
322
323







-
+







    return SBS_ERROR;
  }
  p->aStack[p->nStack++] = *pVal;
  return SBS_OK;
}

/*
** Destroy an underscore interpreter
** Destroy an subscript interpreter
*/
void SbS_Destroy(struct Subscript *p){
  int i;
  sbs_hash_reset(&p->symTab);
  for(i=0; i<p->nStack; i++){
    sbs_value_reset(&p->aStack[i]);
  }
512
513
514
515
516
517
518
519

520
521
522
523
524
525
526
533
534
535
536
537
538
539

540
541
542
543
544
545
546
547







-
+







  sbs_store(&p->symTab, pTos->u.str.z, pTos->u.str.size, pNos);
  sbs_value_reset(pTos);
  return 0;
}


/*
** Create a new underscore interpreter
** Create a new subscript interpreter
*/
struct Subscript *SbS_Create(void){
  Subscript *p;

  p = malloc( sizeof(*p) );
  if( p ){
    memset(p, 0, sizeof(*p));