Esempio n. 1
0
//错误函数
void myflexer::LexerError(const char* msg)
{
	FKLOG("parse error : %s at line:%d near:%s\n", msg, lineno(), yytext);
	char buff[100];
	tsnprintf(buff, sizeof(buff)-1, "%s at line(%d) near(%s)", msg, lineno(), yytext);
	m_error = buff;
}
Esempio n. 2
0
/*
 * Display a new line at physical line p, returning
 * the depth of the newly displayed line.  We may decide
 * to expand the window on an intelligent terminal if it is
 * less than a full screen by deleting a line above the top of the
 * window before doing an insert line to keep all the good text
 * on the screen in which case the line may actually end up
 * somewhere other than line p.
 */
void 
vopen(line *tp, int p)
{
	register int cnt;
	register struct vlinfo *vp, *vpc;

#ifdef ADEBUG
	if (trace != NULL)
		tfixnl(), fprintf(trace, "vopen(%d, %d)\n", lineno(tp), p);
#endif
	if (state != VISUAL) {
		if (vcnt)
			if (hold & HOLDROL)
				vup1();
			else
				vclean();

		/*
		 * Forget all that we once knew.
		 */
		vcnt = vcline = 0;
		p = WBOT; LASTLINE = WBOT + 1;
		state = bastate;
		WTOP = basWTOP;
		WLINES = basWLINES;
	}
	vpc = &vlinfo[vcline];
	for (vp = &vlinfo[vcnt]; vp >= vpc; vp--)
		vlcopy(vp[1], vp[0]);
	vcnt++;
	if (Pline == numbline)
		/*
		 * Dirtying all the lines is rather inefficient
		 * internally, but number mode is used rarely
		 * and so its not worth optimizing.
		 */
		vdirty(vcline+1, WECHO);
	getline(*tp);

	/*
	 * If we are opening at the top of the window, can try a window
	 * expansion at the top.
	 */
	if (state == VISUAL && vcline == 0 && vcnt > 1 && p > ZERO) {
		cnt = p + vdepth() - LINE(1);
		if (cnt > 0) {
			p -= cnt;
			if (p < ZERO)
				p = ZERO;
			WTOP = p;
			WLINES = WBOT - WTOP + 1;
		}
	}
	vpc->vliny = p, vpc->vdepth = 0, vpc->vflags = 0;
	cnt = vreopen(p, lineno(tp), vcline);
	if (vcline + 1 == vcnt)
		LINE(vcnt) = LINE(vcline) + cnt;
}
Esempio n. 3
0
bool
pub3::break_t::to_xdr (xpub3_statement_t *x) const
{
  x->set_typ (XPUB3_STATEMENT_BREAK);
  x->break_statement->lineno = lineno ();
  return true;
}
Esempio n. 4
0
void FileLine::lineDirective(const char* textp, int& enterExitRef) {
    // Handle `line directive
    // Skip `line
    while (*textp && isspace(*textp)) textp++;
    while (*textp && !isspace(*textp)) textp++;
    while (*textp && (isspace(*textp) || *textp=='"')) textp++;

    // Grab linenumber
    const char *ln = textp;
    while (*textp && !isspace(*textp)) textp++;
    if (isdigit(*ln)) {
	lineno(atoi(ln));
    }
    while (*textp && (isspace(*textp) || *textp=='"')) textp++;

    // Grab filename
    const char *fn = textp;
    while (*textp && !(isspace(*textp) || *textp=='"')) textp++;
    if (textp != fn) {
	string strfn = fn;
	strfn = strfn.substr(0, textp-fn);
	filename(strfn);
    }

    // Grab level
    while (*textp && (isspace(*textp) || *textp=='"')) textp++;
    if (isdigit(*textp)) enterExitRef = atoi(textp);
    else enterExitRef = 0;

    //printf ("PPLINE %d '%s'\n", s_lineno, s_filename.c_str());
}
Esempio n. 5
0
static int
confirmed(line *a)
{
	register int c, ch;

	if (xflag == 0)
		return (1);
	pofix();
	pline(lineno(a));
	if (inopen)
		ex_putchar('\n' | RE_QUOTE);
	c = column(loc1 - 1);
	ugo(c - 1 + (inopen ? 1 : 0), ' ');
	ugo(column(loc2 - 1) - c, '^');
	flush();
	ch = c = getkey();
again:
	if (c == '\r')
		c = '\n';
	if (inopen)
		ex_putchar(c), flush();
	if (c != '\n' && c != EOF) {
		c = getkey();
		goto again;
	}
	noteinp();
	return (ch == 'y');
}
Esempio n. 6
0
bool
pub3::continue_t::to_xdr (xpub3_statement_t *x) const
{
  x->set_typ (XPUB3_STATEMENT_CONTINUE);
  x->continue_statement->lineno = lineno ();
  return true;
}
Esempio n. 7
0
bool
pub3::exit_t::to_xdr (xpub3_statement_t *x) const
{
  x->set_typ (XPUB3_STATEMENT_EXIT);
  x->exit_statement->lineno = lineno ();
  return true;
}
Esempio n. 8
0
bool
pub3::zone_raw_t::to_xdr (xpub3_zone_t *z) const
{
  z->set_typ (XPUB3_ZONE_RAW);
  z->zone_raw->lineno = lineno ();
  zstr_to_xdr (_data, &z->zone_raw->data, Z_BEST_COMPRESSION);
  return true;
}
Esempio n. 9
0
bool
pub3::decl_block_t::to_xdr (xpub3_statement_t *x) const
{
  x->set_typ (statement_typ ());
  x->decls->lineno = lineno ();
  _bindings->to_xdr (&x->decls->decls);
  return true;
}
Esempio n. 10
0
bool
pub3::statement_zone_t::to_xdr (xpub3_statement_t *x) const
{
  x->set_typ (XPUB3_STATEMENT_ZONE);
  x->zone->lineno = lineno ();
  _zone->to_xdr (&x->zone->zone);
  return true;
}
Esempio n. 11
0
bool
pub3::return_t::to_xdr (xpub3_statement_t *x) const
{
  x->set_typ (XPUB3_STATEMENT_RETURN);
  x->return_statement->lineno = lineno ();
  expr_to_xdr (_val, &x->return_statement->retval);
  return true;
}
Esempio n. 12
0
bool
pub3::zone_inline_expr_t::to_xdr (xpub3_zone_t *x) const
{
  x->set_typ (XPUB3_ZONE_INLINE_EXPR);
  x->zone_inline->lineno = lineno ();
  expr_to_xdr (_expr, &x->zone_inline->expr);
  return true;
}
Esempio n. 13
0
bool
pub3::while_t::to_xdr (xpub3_statement_t *x) const
{
  x->set_typ (XPUB3_STATEMENT_WHILE);
  x->while_statement->lineno = lineno ();
  expr_to_xdr (_cond, &x->while_statement->cond);
  if (_body) { _body->to_xdr (&x->while_statement->body); }
  return true;
}
Esempio n. 14
0
bool
pub3::zone_wss_boundary_t::to_xdr (xpub3_zone_t *x) const
{
  x->set_typ (XPUB3_ZONE_WSS_BOUNDARY);
  x->zone_wss_boundary->lineno = lineno ();
  x->zone_wss_boundary->on = _on;
  x->zone_wss_boundary->tag = _tag;
  return true;
}
Esempio n. 15
0
bool
pub3::fndef_t::to_xdr (xpub3_statement_t *x) const
{
  x->set_typ (XPUB3_STATEMENT_FNDEF);
  x->fndef->name = _name;
  x->fndef->lineno = lineno ();
  _lambda->to_xdr (&x->fndef->lambda);
  return true;
}
Esempio n. 16
0
bool
pub3::zone_text_t::to_xdr (xpub3_zone_t *z) const
{
  z->set_typ (XPUB3_ZONE_TEXT);
  z->text->lineno = lineno ();
  cook_text ();
  zstr_to_xdr (_original, &z->text->original_text, Z_BEST_COMPRESSION);
  zstr_to_xdr (_wss, &z->text->wss_text, Z_BEST_COMPRESSION);
  return true;
}
Esempio n. 17
0
bool
pub3::include_t::to_xdr_base (xpub3_statement_t *x, 
			      xpub3_statement_typ_t typ) const
{
  x->set_typ (typ);
  x->include->lineno = lineno ();
  expr_to_xdr (_file, &x->include->file);
  expr_to_xdr (_dict, &x->include->dict);
  return true;
}
Esempio n. 18
0
bool
pub3::print_t::to_xdr (xpub3_statement_t *x) const
{
  x->set_typ (XPUB3_STATEMENT_PRINT);
  x->print->lineno = lineno ();
  if (_args) {
    _args->to_xdr (&x->print->args);
  }
  return true;
}
Esempio n. 19
0
    /**
    * @brief de-compile the code in order to list in human readable fashion.
    */
	void CVue::do_list()
	{
		int k=0;
        reset();
        while(token() != TOKEN_EOF && token() != TOKEN_ERROR && !get_ended() )
        {
            switch(token())
            {
                case TOKEN_REM:
                    {
                        uint8_t* p = (uint8_t*)tok_nextptr();
                        fprintf(io(),"%s ",tokkeyword());
                        while (*p && *p != TOKEN_CR && *p != '\n')
                        {
                            fprintf(io(),"%c",*p++);
                        }
                    }
                    next_line();
                    break;
                case TOKEN_CR:
                    fprintf(io(),"\n");
                    accept(token());
                    k=-1;
                    break;
				case TOKEN_NUMBER:
				case TOKEN_STRING:
				case TOKEN_VARIABLE:
                    {
                        int len = tok_nextptr()-tok_ptr();
                        for(int n=0; n < len; n++)
                            fputc(tok_ptr()[n],io());
						if (k==0)
							fputc(' ',io());
                    }
                    accept(token());
                    break;
                default:
					{
						char* p = (char*)tokkeyword();
						if ( k != 1 && *p >= 'A' && *p <= 'Z' && p[strlen(p)-1]!='(' )
							fputc(' ',io());
						fprintf(io(),"%s",p);
						if ( *p >= 'A' && *p <= 'Z' && p[strlen(p)-1]!='(' )
							fputc(' ',io());
						accept(token());
					}
                    break;
            }
            ++k;
        }
        if ( get_runtime_error() )
        {
            fprintf(io(),"@%d, %s\n",lineno(),get_runtime_error_str());
        }
	}
Esempio n. 20
0
const string FileLine::profileFuncname() const {
    // Return string that is OK as a function name - for profiling
    string name  = filebasenameNoExt();
    string::size_type pos;
    while ((pos = name.find_first_not_of("abcdefghijlkmnopqrstuvwxyzABCDEFGHIJLKMNOPQRSTUVWXYZ0123456789_"))
	   != string::npos) {
	name.replace(pos, 1, "_");
    }
    name += "__l"+cvtToStr(lineno());
    return name;
}
Esempio n. 21
0
	void CVue::show_prompt()
	{
		const char* error_str;
		if ( get_runtime_error() != RUNTIME_READY )
		{
			fprintf(io(),"@%d ",lineno());
		}
		error_str = get_runtime_error_str();
		fprintf(io(),"%s%s", error_str,prompt() );
		set_runtime_error(RUNTIME_READY);
	}
Esempio n. 22
0
bool
pub3::zone_pub_t::to_xdr (xpub3_zone_t *x) const
{
  x->set_typ (XPUB3_ZONE_PUB);
  x->zone_pub->lineno = lineno ();
  x->zone_pub->statements.setsize (_statements.size ());
  for (size_t i = 0; i < _statements.size (); i++) {
    _statements[i]->to_xdr (&x->zone_pub->statements[i]);
  }
  return true;
}
Esempio n. 23
0
bool
pub3::expr_statement_t::to_xdr (xpub3_statement_t *x) const
{
  x->set_typ (XPUB3_EXPR_STATEMENT);
  x->expr_statement->lineno = lineno ();
  if (_expr) {
    x->expr_statement->expr.alloc ();
    _expr->to_xdr (x->expr_statement->expr);
  }
  return true;
}
Esempio n. 24
0
bool
pub3::heredoc_t::to_xdr (xpub3_expr_t *x) const
{
  x->set_typ (XPUB3_EXPR_HEREDOC);
  x->heredoc->lineno = lineno ();
  if (_body) { 
    x->heredoc->body.alloc ();
    _body->to_xdr (x->heredoc->body); 
  }
  return true;
}
Esempio n. 25
0
bool
pub3::zone_html_t::to_xdr (xpub3_zone_t *z) const
{
  z->set_typ (XPUB3_ZONE_HTML);
  z->html->lineno = lineno ();
  z->html->zones.setsize (_children.size ());
  for (size_t i = 0; i < _children.size (); i++) {
    _children[i]->to_xdr (&z->html->zones[i]);
  }
  return true;

}
Esempio n. 26
0
bool
pub3::if_t::to_xdr (xpub3_statement_t *x) const
{
  x->set_typ (XPUB3_STATEMENT_IF);
  x->if_statement->lineno = lineno ();

  size_t s = _clauses ? _clauses->size () : size_t (0);
  x->if_statement->clauses.setsize (s);
  for (size_t i = 0; i < s; i++) {
    (*_clauses)[i]->to_xdr (&x->if_statement->clauses[i]);
  }
  return true;
}
Esempio n. 27
0
bool
pub3::switch_t::to_xdr (xpub3_statement_t *x) const
{
  x->set_typ (XPUB3_STATEMENT_SWITCH);
  x->switch_statement->lineno = lineno ();
  expr_to_xdr (_key, &x->switch_statement->key);

  if (_cases) {
    _cases->to_xdr (&x->switch_statement->cases);
  }

  return true;
}
Esempio n. 28
0
bool
pub3::for_t::to_xdr (xpub3_statement_t *x) const
{
  x->set_typ (XPUB3_STATEMENT_FOR);
  x->for_statement->lineno = lineno ();
  x->for_statement->iter = _iter;
  expr_to_xdr (_arr, &x->for_statement->arr);
  if (_body) { _body->to_xdr (&x->for_statement->body); }
  if (_empty) {
    x->for_statement->empty.alloc ();
    _empty->to_xdr (x->for_statement->empty);
  }
  return true;
}
Esempio n. 29
0
// Subclassed handle() for keyboard searching
int EDE_Browser::handle(int e) {
	if (e==FL_FOCUS) { fprintf(stderr, "EB::focus\n"); }
	if (e==FL_KEYBOARD && Fl::event_state()==0) {
		// when user presses a key, jump to row starting with that character
		int k=Fl::event_key();
		if ((k>='a'&&k<='z') || (k>='A'&&k<='Z') || (k>='0'&&k<='9')) {
			if (k>='A'&&k<='Z') k+=('a'-'A');
			int ku = k - ('a'-'A'); //upper case
			int p=lineno(selection());
			for (int i=1; i<=size(); i++) {
				int mi = (i+p-1)%size() + 1; // search from currently selected one
				if (text(mi)[0]==k || text(mi)[0]==ku) {
					// select(line,0) just moves focus to line without selecting
					// if line was already selected, it won't be anymore
					select(mi,selected(mi));
					middleline(mi);
					//break;
					return 1; // menu will get triggered on key press :(
				}
			}
		}
		// Attempt to fix erratic behavior on enter key
		// Fl_Browser seems to do the following on enter key:
		// - when item is both selected and focused, callback isn't called at all (even FL_WHEN_ENTER_KEY_ALWAYS)
		// - when no item is selected, callback is called 2 times on focused item
		// - when one item is selected and other is focused, callback is first called on selected then on
		//   focused item, then the focused becomes selected
		// This partial fix at least ensures that callback is always called. Callback function should
		// deal with being called many times repeatedly.
		if ((when() & FL_WHEN_ENTER_KEY_ALWAYS) && k == FL_Enter) {
//			if (changed()!=0) {
				//fprintf(stderr,"do_callback()\n"); 
				do_callback();
//			}
		}

		if (k == FL_Tab) {
fprintf (stderr, "TAB\n");
			
//			Fl_Icon_Browser::handle(FL_UNFOCUS); return 1;
		}
	}
	return Fl_Icon_Browser::handle(e);
}
Esempio n. 30
0
    /**
    * @brief Compile the program code.
    */
	bool CVue::compile(CARIBOU::CString& output)
	{
		bool rc=true;
		output.clear();
		inherited::reset();
        while(rc && token() != TOKEN_EOF && token() != TOKEN_ERROR && !get_ended() )
        {
            switch(token())
            {
				case TOKEN_NUMBER:
				case TOKEN_STRING:
				case TOKEN_VARIABLE:
                    {
                        int len = tok_nextptr()-tok_ptr();
                        for(int n=0; n < len; n++)
                            output.append(tok_ptr()[n]);
                    }
                    rc = accept(token());
                    break;
                case TOKEN_REM:
                    {
                        uint8_t* p = (uint8_t*)tok_nextptr();
                        output.append((uint8_t)token());
                        while (*p && *p != TOKEN_CR && *p != '\n')
                        {
                            output.append(*p++);
                        }
                    }
                    next_line();
                    /* fall through... */
                 default:
                    output.append((uint8_t)token());
                    rc = accept(token());
                   break;
            }
        }
        if ( get_runtime_error() )
        {
            fprintf(io(),"Compile @%d, %s\n",lineno(),get_runtime_error_str());
            rc = false;
        }
        return rc;
	}