Пример #1
0
ll_define_primitive_end


ll_define_primitive(object, eval_no_const_fold, __1(obj, env), _0())
{
  ll_v obj;
  ll_v env;
  ll_v expr;
  ll_v ir;
  ll_v op;

  obj = ll_SELF;
  env = ll_ARGV[1];

  expr = ll_call(ll_o(eval_stage_1), _2(obj, env));

  ir = ll_call(ll_o(eval_stage_2), _2(expr, env));
  
  /* Disable constant folding */
  ll_call(ll_o(set_propertyE), _3(ir, ll_s(no_const_folding), ll_t));

  ir = ll_call(ll_o(eval_stage_3), _2(ir, env));

  op = ll_call(ll_o(_ir_operation), _1(ir));
  
  ll_call_tail(op, _0());
}
Пример #2
0
    Parser::Parser(const vector<Production>& productions, const string& parserTablePath) : BasicParser(productions), parserTablePath(parserTablePath)
    {
#ifdef _DEBUG
        stream.open("ParserResult.txt", fstream::out | fstream::binary);
#endif
        // String Begin
        Rule quotationMarks = Rule('\"', &context);
        Rule ruleString = quotationMarks + *!quotationMarks + quotationMarks;
        ruleString.buildDFA();
        ruleString.setShowName("\"{String}\"");
        Production::Item itemString(ruleString);
        // String End

        // Digit Start
        Rule _0('0', &context);
        Rule _9('9', &context);
        Rule _0_9  = _0 - _9;
        Rule ruleDigit = +_0_9;
        ruleDigit.buildDFA();
        ruleDigit.setShowName("\"{Digit}\"");
        Production::Item itemDigit(ruleDigit);
        // Digit End

        // Real Start
        Rule _point('.', &context);
        Rule ruleReal = *_0_9 + _point + +_0_9;
        ruleReal.buildDFA();
        ruleReal.setShowName("\"{Real}\"");
        Production::Item itemReal(ruleReal);
        // Real End

        // Letter Start
        Rule _('_', &context);
        Rule _a('a', &context);
        Rule _z('z', &context);
        Rule _A('A', &context);
        Rule _Z('Z', &context);
        Rule _a_z = _a - _z;
        Rule _A_Z = _A - _Z;
        Rule ruleLetter = ((+_ + ruleDigit) |
            (+(_ | _a_z | _A_Z))) +
            *(_ | ruleDigit | _a_z | _A_Z);
        ruleLetter.buildDFA();
        ruleLetter.setShowName("\"{Letter}\"");
        Production::Item itemLetter(ruleLetter);
        // Letter End

        vts.push_back(pair<string, Production::Item>("{String}", itemString));
        vts.push_back(pair<string, Production::Item>("{Digit}",  itemDigit));
        vts.push_back(pair<string, Production::Item>("{Real}",   itemReal));
        vts.push_back(pair<string, Production::Item>("{Letter}", itemLetter));
    }
Пример #3
0
void move_image_roi_alt(Mat& img, Mat& trans, const Point2d& offset) {

	// TODO: Optimize

	trans = Mat::zeros(img.size(), img.type());
	img(
		Rect(
			_0(static_cast<int>(offset.x)),
			_0(static_cast<int>(offset.y)),
			img.cols-abs(static_cast<int>(offset.x)),
			img.rows-abs(static_cast<int>(offset.y))
		)
	).copyTo(trans(
		Rect(
			_0ia(static_cast<int>(offset.x)),
			_0ia(static_cast<int>(offset.y)),
			img.cols-abs(static_cast<int>(offset.x)), 
			img.rows-abs(static_cast<int>(offset.y))
		)	
	));

}
Пример #4
0
ll_define_primitive_end


ll_define_primitive(list, eval_list, __1(list, env), _0())
{
  int eval_each = 1; // getenv("ll_LOAD_EVAL_EACH") ? 1 : 0;
  ll_v exprs = ll_SELF;

  if ( eval_each ) {
    ll_v result = ll_undef;

    ll_LIST_LOOP(exprs, expr);
    {
      result = ll_call(ll_o(eval), _1(expr));
    }
    ll_LIST_LOOP_END;

    ll_return(result);
  } else {
    exprs = ll_call(ll_o(map), _2(ll_o(Seval_hookS), exprs));

    exprs = ll_call(ll_o(map), _2(ll_o(macro_expand), exprs));

    {
      ll_v ir;
      ll_v op;
      
      ir = ll_call(ll_o(make), _2(ll_type(_ir),
				  exprs               /* body */
				  ));
      
      op = ll_call(ll_o(_ir_operation), _1(ir));
      
      ll_call_tail(op, _0());
    }
  }
}
Пример #5
0
static const char __rcs_id_ll_port_c[] = "$Id: port.c,v 1.26 2008/01/06 18:36:33 stephens Exp $";
#endif
#endif /* __rcs_id__ */


#include "ll.h"
#include <stdio.h>
#include <string.h>
#include <errno.h>


/******************************************************************/
/* (current-output-port) */


ll_define_primitive(object, current_output_port, _0(), _1(no_side_effect,"#t"))
{
    ll_return(ll_g(_current_output_port));
}
ll_define_primitive_end


ll_define_primitive(output_port, set_current_output_port, _1(port), _0())
{
    ll_set_g(_current_output_port, ll_SELF);
}
ll_define_primitive_end


/******************************************************************/
/* (current-input-port) */
Пример #6
0
Файл: llt.c Проект: kstephens/ll
int main(int argc, char **argv, char **envp)
{
  int interactive = 1;
  int print_result = 0;
  ll_v result;

  ll_init(&argc, &argv, &envp);

  result = ll_undef;

  {
    int argi;
    for ( argi = 1; argi < argc; ++ argi ) {
      const char *arg = argv[argi];
      if ( arg[0] == '-' ) {
	if ( ! strcmp("-h", arg) || ! strcmp("--help", arg) ) {
	  if ( interactive == 1 ) {
	    interactive = 0;
	  }
	  printf(
		 "%s [ -h | -d | -p | -i | -e expr ]\n"
		 "\n"
		 "  -h \n"
		 "    This help message. \n"
		 "  -d \n"
		 "    Invoke debugger on error. \n"
		 "  -p \n"
		 "    Print result of -e eval. \n"
		 "  -i \n"
		 "    Force interactive REPL. \n"
		 "  -e expr \n"
		 "    Evaluate expression (disables interactive unless -i). \n"
		 , argv[0]);
	} else
	if ( ! strcmp("-d", arg) ) {
	  ll_bind_fluid(ll_s(error_handler), ll_o(error_start_debugger));
	} else
	if ( ! strcmp("-p", arg) ) {
	  print_result = 1;
	} else
	if ( ! strcmp("-i", arg) ) {
	  interactive = 2;
	} else
	if ( ! strcmp("-e", arg) ) {
	  if ( interactive == 1 ) {
	    interactive = 0;
	  }

	  result = ll_eval_string(argv[++ argi], (size_t) -1);

	  if ( print_result ) {
	    if ( ll_NE(result, ll_unspec) ) {
	      ll_format(ll_undef, "~S\n", 1, result);
	    }
	  }	  
	} else {
	  fprintf(stderr, "ll: invalid argument: \"%s\"\n", arg);
	  exit(1);
	}
      }
    }
  }

  if ( interactive ) {
    ll_call(ll_o(llCtop_level), _0());
  }

  return 0;
}