compile.c File Reference

Compile parsed jam statements. More...

#include "jam.h"
#include "lists.h"
#include "parse.h"
#include "compile.h"
#include "variable.h"
#include "expand.h"
#include "rules.h"
#include "newstr.h"
#include "search.h"

Functions

static void debug_compile (int which, const char *s)
int glob (const char *s, const char *c)
LISTcompile_append (PARSE *parse, LOL *args, int *jmp)
LISTcompile_break (PARSE *parse, LOL *args, int *jmp)
static int lcmp (LIST *t, LIST *s)
LISTcompile_eval (PARSE *parse, LOL *args, int *jmp)
LISTcompile_foreach (PARSE *p, LOL *args, int *jmp)
LISTcompile_if (PARSE *p, LOL *args, int *jmp)
LISTcompile_include (PARSE *parse, LOL *args, int *jmp)
LISTcompile_list (PARSE *parse, LOL *args, int *jmp)
LISTcompile_local (PARSE *parse, LOL *args, int *jmp)
LISTcompile_null (PARSE *parse, LOL *args, int *jmp)
LISTcompile_on (PARSE *parse, LOL *args, int *jmp)
LISTcompile_rule (PARSE *parse, LOL *args, int *jmp)
LISTevaluate_rule (const char *rulename, LOL *args, LIST *result)
LISTcompile_rules (PARSE *parse, LOL *args, int *jmp)
LISTcompile_set (PARSE *parse, LOL *args, int *jmp)
LISTcompile_setcomp (PARSE *parse, LOL *args, int *jmp)
LISTcompile_setexec (PARSE *parse, LOL *args, int *jmp)
LISTcompile_settings (PARSE *parse, LOL *args, int *jmp)
LISTcompile_switch (PARSE *parse, LOL *args, int *jmp)
LISTcompile_while (PARSE *p, LOL *args, int *jmp)

Variables

static const char * set_names [] = { "=", "+=", "?=" }


Detailed Description

Compile parsed jam statements.

Todo:
study this file
External routines:

compile_append() - append list results of two statements compile_break() - compile 'break/continue/return' rule compile_eval() - evaluate if to determine which leg to compile compile_foreach() - compile the "for x in y" statement compile_if() - compile 'if' rule compile_include() - support for 'include' - call include() on file compile_list() - expand and return a list compile_local() - declare (and set) local variables compile_null() - do nothing -- a stub for parsing compile_on() - run rule under influence of on-target variables compile_rule() - compile a single user defined rule compile_rules() - compile a chain of rules compile_set() - compile the "set variable" statement compile_setcomp() - support for `rule` - save parse tree compile_setexec() - support for `actions` - save execution string compile_settings() - compile the "on =" (set variable on exec) statement compile_switch() - compile 'switch' rule

Internal routines:

debug_compile() - printf with indent to show rule expansion. evaluate_rule() - execute a rule invocation


Function Documentation

LIST* compile_append ( PARSE parse,
LOL args,
int *  jmp 
)

append list results of two statements

parse->left more compile_append() by left-recursion parse->right single rule

LIST* compile_break ( PARSE parse,
LOL args,
int *  jmp 
)

compile 'break/continue/return' rule

parse->left results parse->num JMP_BREAK/CONTINUE/RETURN

LIST* compile_eval ( PARSE parse,
LOL args,
int *  jmp 
)

LIST* compile_foreach ( PARSE p,
LOL args,
int *  jmp 
)

compile the "for x in y" statement

Compile_foreach() resets the given variable name to each specified value, executing the commands enclosed in braces for each iteration.

parse->string index variable parse->left variable values parse->right rule to compile

LIST* compile_if ( PARSE p,
LOL args,
int *  jmp 
)

compile 'if' rule

parse->left condition tree parse->right then tree parse->third else tree

LIST* compile_include ( PARSE parse,
LOL args,
int *  jmp 
)

support for 'include' - call include() on file

parse->left list of files to include (can only do 1)

LIST* compile_list ( PARSE parse,
LOL args,
int *  jmp 
)

expand and return a list

parse->string - character string to expand

LIST* compile_local ( PARSE parse,
LOL args,
int *  jmp 
)

declare (and set) local variables

parse->left list of variables parse->right list of values parse->third rules to execute

LIST* compile_null ( PARSE parse,
LOL args,
int *  jmp 
)

do nothing -- a stub for parsing

LIST* compile_on ( PARSE parse,
LOL args,
int *  jmp 
)

run rule under influence of on-target variables

parse->left target list; only first used parse->right rule to run

LIST* compile_rule ( PARSE parse,
LOL args,
int *  jmp 
)

compile a single user defined rule

parse->left list of rules to run parse->right parameters (list of lists) to rule, recursing left

Wrapped around evaluate_rule() so that headers() can share it.

LIST* compile_rules ( PARSE parse,
LOL args,
int *  jmp 
)

compile a chain of rules

parse->left single rule parse->right more compile_rules() by right-recursion

LIST* compile_set ( PARSE parse,
LOL args,
int *  jmp 
)

LIST* compile_setcomp ( PARSE parse,
LOL args,
int *  jmp 
)

LIST* compile_setexec ( PARSE parse,
LOL args,
int *  jmp 
)

LIST* compile_settings ( PARSE parse,
LOL args,
int *  jmp 
)

LIST* compile_switch ( PARSE parse,
LOL args,
int *  jmp 
)

LIST* compile_while ( PARSE p,
LOL args,
int *  jmp 
)

static void debug_compile ( int  which,
const char *  s 
) [static]

LIST* evaluate_rule ( const char *  rulename,
LOL args,
LIST result 
)

execute a rule invocation

int glob ( const char *  s,
const char *  c 
)

static int lcmp ( LIST t,
LIST s 
) [static]

evaluate if to determine which leg to compile

Returns:
list If expression true - compile 'then' clause

L0 If expression false - compile 'else' clause


Variable Documentation

const char* set_names[] = { "=", "+=", "?=" } [static]


Generated on Thu Aug 17 15:54:32 2006 for MaJam by  doxygen 1.4.7