예제 #1
0
파일: A88.C 프로젝트: ALANGUAGE/A2011
int parse() { token=getlex(); do { if (token <= 0) return 1;
    if (istoken('#')) {
      if (istoken(T_DEFINE)) dodefine();
      else if (istoken(T_INCLUDE)) doinclude();
      else error1("define oder include erwartet");
      } else{ typeName();  if (token=='(') dofunc();  else doglob(); } 
    } while(1); 
}
예제 #2
0
파일: A88.C 프로젝트: ALANGUAGE/A2011
int stmt() { int c;
       if(istoken('{'))     {while(istoken('}')==0) stmt();}
  else if(istoken(T_IF))    doif();
  else if(istoken(T_DO))    dodo();
  else if(istoken(T_WHILE)) dowhile();
  else if(istoken(T_GOTO))  {prs("\n jmp @@");name1();prs(symbol);expect(';');}
  else if(token==T_ASM)     {prs("\n"); c=next();
    while(c != '\n') { prc(c);	c=next(); }; token=getlex(); }
  else if(istoken(T_ASMBLOCK)) {prs("\n"); expect('{'); c=next();
    while(c!= '}') { prc(c); c=next(); };   token=getlex(); }
  else if(istoken(T_EMIT))  doemit();
  else if(istoken(';'))     { }
  else if(istoken(T_RETURN)){if (token!=';') expr();
    prs("\n jmp @@retn"); nreturn++; expect(';'); }
  else if(thechar==':')     {prs("\n@@"); /*Label*/
     prs(symbol); prc(':'); expect(T_NAME); expect(':'); }
  else                      {expr(); expect(';'); } }
예제 #3
0
//if input is token, token = getlex(), return 1
int 
istoken(int t)
{
    if (token == t) {
	token = getlex();
	return 1;
    }
    return 0;
}
예제 #4
0
int
parse()
{
    int objid;

    token = getlex();
    while(1) {
	if (token < 0)
	    return 1;
	type();			/* T_INT or CHAR */
	objid = name();		/* T_NAME */
	if (istoken('(')) {
	    /* function */
	    funids[nfun] = objid;
	    funoffs[nfun++] = curloc;
	    narg = 0;
	    if (!istoken(')')) {
		do {
		    type();
		    argids[narg++] = name();
		} while(istoken(','));
		expect(')');
	    }
	    expect('{');
	    /* body */
	    /* decls */
	    nlocal = 0;
	    while(token == T_INT) {
		type();
		do {
		    localids[nlocal++] = name();
		} while (istoken(','));
		expect(';');
	    }
	    if (DEFSTK < nlocal)
		emitop(C_ALLOC, nlocal);
	    /* stmts */
	    while(!istoken('}'))
		stmt();
	    emit(C_RETURN);
	} else {
	    globoffs[nglob] = curgloboffs;
	    if (istoken('[')) {
		/* array */
		expect(T_CONST);
		curgloboffs = curgloboffs + lexval;
		expect(']');
		globscalar[nglob] = 0;
	    } else {
		curgloboffs++;
		globscalar[nglob] = 1;
	    }
	    globids[nglob++] = objid;
	    expect(';');
	}
    }
}
예제 #5
0
파일: A88.C 프로젝트: ALANGUAGE/A2011
int constantexpr() { int mode; int id1;int ids;
  token=getlex();   mode=typeName();  
  id1=searchname(); gettypes(id1); ids=signi;
  if (isrelational() ==0) error1("Vergleich erwartet");
  expect(T_CONST);
  prs("; constant expression");
  prs("\ncmp "); printName(id1); prs(", "); prnum(lexval); cmpneg(ids); 
   expect(')');
}  
예제 #6
0
파일: A88.C 프로젝트: ALANGUAGE/A2011
int doinclude() { int fdtemp;
  if (token==T_STRING) {  fdtemp=fdin;
  prs("\n;Verarbeite Include-Datei: "); prscomment(symbol);  
  fdin=open2(symbol);
  if (DOS_ERR !=0) {prs("Include-Datei fehlt: "); prscomment(symbol); 
    error1("Stop"); }
  linenoinclude=lineno; lineno=1;
  parse(); lineno=linenoinclude;
  fdin=fdtemp; prs("\n;Zurueck in Hauptdatei: "); prs(namein); 
  getfirstchar(); token=getlex(); }
}
예제 #7
0
//if token is not keyword, erroe, else getlex()
int
name()
{
    int r;

    if (token != T_NAME)
	error("name expected");
    r = lexval;
    token = getlex();
    return r;
}
예제 #8
0
int gl()
{
	pSt.l = getlex();
	cur_l = pSt.l;
	pSt.needLex = 0;

	if (cur_l == NULL)
	{
		parserErrorNo = PE_LEXER_ERROR;
		return 1;
	}

	return 0;
}
예제 #9
0
파일: A88.C 프로젝트: ALANGUAGE/A2011
int getlex() { char c; char *p; 
g1: c=next(); if (c == 0) return 0; if (c <= ' ') goto g1;
  if (c=='=') {if(thechar=='=') {next(); return T_EQ; }}
  if (c=='!') {if(thechar=='=') {next(); return T_NE; }}
  if (c=='<') {if(thechar=='=') {next(); return T_LE; }}
  if (c=='>') {if(thechar=='=') {next(); return T_GE; }}
  if (c=='<') {if(thechar=='<') {next(); return T_LESSLESS;  }}
  if (c=='>') {if(thechar=='>') {next(); return T_GREATGREAT;}}
  if (c=='+') {if(thechar=='+') {next(); return T_PLUSPLUS;  }}
  if (c=='-') {if(thechar=='-') {next(); return T_MINUSMINUS;}}
  if (c=='+') {if(thechar=='=') {next(); return T_PLUSASS;   }}
  if (c=='-') {if(thechar=='=') {next(); return T_MINUSASS;  }}
  if (c=='&') {if(thechar=='=') {next(); return T_ANDASS;    }}
  if (c=='|') {if(thechar=='=') {next(); return T_ORASS;     }}    
  if (c=='*') {if(thechar=='=') {next(); return T_MULASS;    }}
  if (c=='/') {if(thechar=='=') {next(); return T_DIVASS;    }}        
  if (instr1("()[]{},;*:%-><=+!&|#", c)) return c ;
  if (c == '/') { if (thechar == '*') { 
      g2: c=next(); if (c != '*') goto g2; if (thechar != '/') goto g2;
      c=next(); return getlex(); } else  return '/'; }
  if (c == '"') {getstring(c); return T_STRING;}
  if (digit(c)) { getdigit(c); return T_CONST; }
  if (c==39) { lexval=next();
    if (lexval==92) {lexval=next();
      if (lexval=='n') lexval=10; if (lexval=='t') lexval= 9;
      if (lexval=='0') lexval= 0; } next(); return T_CONST; }
  if (letter(c)) { 
    strcpy1(symboltemp, symbol); p=&symbol;  *p=c;  p++;
    while(letter(thechar)) {c=next(); *p=c;  p++; } 
      *p=0;
    if (eqstr(symbol,"signed"  )) return T_SIGNED;
    if (eqstr(symbol,"unsigned")) return T_UNSIGNED;
    if (eqstr(symbol,"void"    )) return T_VOID;
    if (eqstr(symbol,"int"     )) return T_INT;
    if (eqstr(symbol,"char"    )) return T_CHAR;
    if (eqstr(symbol,"asm"     )) return T_ASM;
    if (eqstr(symbol,"__asm"   )) return T_ASMBLOCK;
    if (eqstr(symbol,"__emit__")) return T_EMIT;
    if (eqstr(symbol,"return"  )) return T_RETURN;
    if (eqstr(symbol,"if"      )) return T_IF;
    if (eqstr(symbol,"else"    )) return T_ELSE;
    if (eqstr(symbol,"while"   )) return T_WHILE;
    if (eqstr(symbol,"do"      )) return T_DO;
    if (eqstr(symbol,"goto"    )) return T_GOTO;
    if (eqstr(symbol,"define"  )) return T_DEFINE;   
    if (eqstr(symbol,"include" )) return T_INCLUDE;   
    if (convertdefine() ) {strcpy1(symbol, symboltemp); return T_CONST;}
    return T_NAME; } error1("Zeichen nicht erkannt"); }
예제 #10
0
LISP getlist ()		/* чтение списка ВЫР ('.' СПИС | ВЫР)... */
{
	LISP p = cons (getexpr (), NIL);
	switch (getlex ()) {
	case '.':
		setcdr (p, getexpr ());
		break;
	case ')':
		ungetlex ();
		break;
	default:
		ungetlex ();
		setcdr (p, getlist ());
		break;
	case 0:
		fatal ("unexpected eof");
	}
	return (p);
}
예제 #11
0
LISP getvector ()       /* чтение вектора ВЫР... */
{
	int len = 0;
	LISP vect[MAXVECT];

	for (;;) {
		switch (getlex ()) {
		case ')':
			ungetlex ();
			return (vector (len, vect));
		default:
			if (len >= MAXVECT)
				fatal ("too long vector constant");
			ungetlex ();
			vect[len++] = getexpr ();
			continue;
		case 0:
			fatal ("unexpected eof");
		}
	}
}
예제 #12
0
//Skip comments, convert characters into their int codes, or if and int is found, return the code for integer etc
int
getlex()
{
    int c;
    char *p;

    while( 0 <= (c = next()) && c <= ' ')	/* consider all control chars as whitespace */
	;

    if (c == -1 || instr("()[]{},;", c)) {
	return c;
    }
    if (c == '/') {
	if (thechar == '*') {
	    /* next(); dropping this is wrong */
	    while(next() != '*' || thechar != '/')
		;
	    next();
	    return getlex();
	} else
	    return T_DIV;
    }
    if (c == '*') return T_MUL;
    if (c == '%') return T_MOD;
    if (c == '-')
	return gobble(c,T_POSTDEC,T_SUB);
    if (c == '>')
	return gobble('=',T_GE,T_GT);
    if (c == '<')
	return gobble('=',T_LE,T_LT);
    if (c == '=')
	return gobble(c,T_EQ,T_ASSIGN);
    if (c == '+')
	return gobble(c,T_POSTINC,T_ADD);
    if (c == '!')
	return gobble('=',T_NE,T_NOT);
    if (c == '&')
	return gobble(c,T_ANDAND,T_AND);
    if (c == '|')
	return gobble(c,T_OROR,T_OR);
    if (c == '\'') {
	getstring(c);
	lexval = symbol[0];
	return T_CONST;
    }
    if (c == '"') {
	getstring(c);
	return T_STRING;
    }
    if (digit(c)) {
	lexval = c - '0';
	while(digit(thechar)) {
	    lexval = lexval * 10 + next() - '0';
	}
	return T_CONST;
    }
    if (letter(c)) {
	p = symbol;
	*p++ = c;
	while(letter(thechar))
	    *p++ = next();
	*p = 0;
	if ( (lexval = lookup(symbol)) < RES) {
	    if (lexval == I_CHAR)
		return T_INT;
	    return lexval + RESBASE;
	}
	return T_NAME;
    }
    error("Bad input");
}
예제 #13
0
void swf_AddButtonLinks(SWF*swf, char stop_each_frame, char events)
{
    int num_frames = 0;
    int has_buttons = 0;
    TAG*tag=swf->firstTag;

    unsigned int checksum = 0;
    while(tag) {
        if(tag->id == ST_SHOWFRAME)
            num_frames++;
        if(tag->id == ST_DEFINEBUTTON || tag->id == ST_DEFINEBUTTON2)
            has_buttons = 1;
	crc32_add_bytes(checksum, tag->data, tag->len);
        tag = tag->next;
    }
    int t = time(0);
    checksum = crc32_add_bytes(checksum, &t, sizeof(t));

    unsigned char h[16];
    unsigned char file_signature[33];
    sprintf((char*)file_signature, "%x", checksum);

    char scenename1[80], scenename2[80];
    sprintf(scenename1, "rfx.MainTimeline_%s", file_signature);
    sprintf(scenename2, "rfx::MainTimeline_%s", file_signature);

    abc_file_t*file = abc_file_new();
    abc_method_body_t*c = 0;
   
    abc_class_t*cls = abc_class_new2(file, scenename2, "flash.display::MovieClip");
  
    TAG*abctag = swf_InsertTagBefore(swf, swf->firstTag, ST_DOABC);
    
    tag = swf_InsertTag(abctag, ST_SYMBOLCLASS);
    swf_SetU16(tag, 1);
    swf_SetU16(tag, 0);
    swf_SetString(tag, scenename1);

    c = abc_class_getstaticconstructor(cls, 0)->body;
    c->old.max_stack = 1;
    c->old.local_count = 1;
    c->old.init_scope_depth = 9;
    c->old.max_scope_depth = 10;

    __ getlocal_0(c);
    __ pushscope(c);
    __ returnvoid(c);

    c = abc_class_getconstructor(cls, 0)->body;
    c->old.max_stack = 3;
    c->old.local_count = 1;
    c->old.init_scope_depth = 10;
    c->old.max_scope_depth = 11;
    
    debugfile(c, "constructor.as");

    __ getlocal_0(c);
    __ pushscope(c);

    __ getlocal_0(c);
    __ constructsuper(c,0);

    if(stop_each_frame || has_buttons) {
        int frame = 0;
        tag = swf->firstTag;
        abc_method_body_t*f = 0; //frame script
        while(tag && tag->id!=ST_END) {
            char framename[80];
            char needs_framescript=0;
            char buttonname[80];
            char functionname[80];
            sprintf(framename, "[packageinternal]rfx::frame%d_%s", frame, file_signature);
            
            if(!f && (tag->id == ST_DEFINEBUTTON || tag->id == ST_DEFINEBUTTON2 || stop_each_frame)) {
                /* make the contructor add a frame script */
                __ findpropstrict(c,"[package]::addFrameScript");
                __ pushuint(c,frame);
                __ getlex(c,framename);
                __ callpropvoid(c,"[package]::addFrameScript",2);

                f = abc_class_method(cls, 0, multiname_fromstring(framename))->body;
                f->old.max_stack = 3;
                f->old.local_count = 1;
                f->old.init_scope_depth = 10;
                f->old.max_scope_depth = 11;
                __ debugfile(f, "framescript.as");
                __ debugline(f, 1);
                __ getlocal_0(f);
                __ pushscope(f);
                if(stop_each_frame) {
                    __ findpropstrict(f, "[package]::stop");
                    __ callpropvoid(f, "[package]::stop", 0);
                }
            }

            if(tag->id == ST_DEFINEBUTTON || tag->id == ST_DEFINEBUTTON2) {
                U16 id = swf_GetDefineID(tag);
                sprintf(buttonname, "::button%d", swf_GetDefineID(tag));
                __ getlex(f,buttonname);
                __ getlex(f,"flash.events::MouseEvent");
                __ getproperty(f, "::CLICK");
                sprintf(functionname, "::clickbutton%d_%s", swf_GetDefineID(tag), file_signature);
                __ getlex(f,functionname);
                __ callpropvoid(f, "::addEventListener" ,2);

                needs_framescript = 1;

                abc_method_body_t*h =
                    abc_class_method(cls, 0, multiname_fromstring(functionname))->body;
                list_append(h->method->parameters, multiname_fromstring("flash.events::MouseEvent"));

                h->old.max_stack = 6;
                h->old.local_count = 2;
                h->old.init_scope_depth = 10;
                h->old.max_scope_depth = 11;
                __ getlocal_0(h);
                __ pushscope(h);

                ActionTAG*oldaction = swf_ButtonGetAction(tag);
                if(oldaction && oldaction->op == ACTION__GOTOFRAME) {
                    int framenr = GET16(oldaction->data);
                    if(!events) {
                        __ findpropstrict(h,"[package]::gotoAndStop");
                        __ pushuint(h,framenr+1);
                        __ callpropvoid(h,"[package]::gotoAndStop", 1);
                    } else {
                        char framename[80];
                        sprintf(framename, "frame%d_%s", framenr, file_signature);
                        __ getlocal_0(h); //this
                        __ findpropstrict(h, "[package]flash.events::TextEvent");
                        __ pushstring(h, "link");
                        __ pushtrue(h);
                        __ pushtrue(h);
                        __ pushstring(h, framename);
                        __ constructprop(h,"[package]flash.events::TextEvent", 4);
                        __ callpropvoid(h,"[package]::dispatchEvent", 1);
                    }
                } else if(oldaction && oldaction->op == ACTION__GETURL) {
                    if(!events) {
                        __ findpropstrict(h,"flash.net::navigateToURL");
                        __ findpropstrict(h,"flash.net::URLRequest");
                        // TODO: target _blank
                        __ pushstring(h,(char*)oldaction->data); //url
                        __ constructprop(h,"flash.net::URLRequest", 1);
                        __ callpropvoid(h,"flash.net::navigateToURL", 1);
                    } else {
                        __ getlocal_0(h); //this
                        __ findpropstrict(h, "[package]flash.events::TextEvent");
                        __ pushstring(h, "link");
                        __ pushtrue(h);
                        __ pushtrue(h);
                        __ pushstring(h,(char*)oldaction->data); //url
                        __ constructprop(h,"[package]flash.events::TextEvent", 4);
                        __ callpropvoid(h,"[package]::dispatchEvent", 1);
                    }
                } else if(oldaction) {
                    fprintf(stderr, "Warning: Couldn't translate button code of button %d to flash 9 abc action\n", id);
                }
                __ returnvoid(h);
                swf_ActionFree(oldaction);
            }
            if(tag->id == ST_SHOWFRAME) {
                if(f) {
                    __ returnvoid(f);
                    f = 0;
                }
                frame++;
            }
            tag = tag->next;
        }
        if(f) {
            __ returnvoid(f);
        }
    }
    __ returnvoid(c);

    tag = swf->firstTag;
    while(tag) {
        if(tag->id == ST_DEFINEBUTTON || tag->id == ST_DEFINEBUTTON2) {
            char buttonname[80];
            sprintf(buttonname, "::button%d", swf_GetDefineID(tag));
            multiname_t*s = multiname_fromstring(buttonname);
            //abc_class_slot(cls, multiname_fromstring(buttonname), s);
            abc_class_slot(cls, multiname_fromstring(buttonname), 
                                multiname_fromstring("flash.display::SimpleButton"));
        }
        tag = tag->next;
    }


    abc_script_t*s = abc_initscript(file);
    c = s->method->body;
    c->old.max_stack = 2;
    c->old.local_count = 1;
    c->old.init_scope_depth = 1;
    c->old.max_scope_depth = 9;

    __ getlocal_0(c);
    __ pushscope(c);
    __ getscopeobject(c, 0);
    __ getlex(c,"::Object");
    __ pushscope(c);
    __ getlex(c,"flash.events::EventDispatcher");
    __ pushscope(c);
    __ getlex(c,"flash.display::DisplayObject");
    __ pushscope(c);
    __ getlex(c,"flash.display::InteractiveObject");
    __ pushscope(c);
    __ getlex(c,"flash.display::DisplayObjectContainer");
    __ pushscope(c);
    __ getlex(c,"flash.display::Sprite");
    __ pushscope(c);
    __ getlex(c,"flash.display::MovieClip");
    __ pushscope(c);
    __ getlex(c,"flash.display::MovieClip");
    __ newclass(c,cls);
    __ popscope(c);
    __ popscope(c);
    __ popscope(c);
    __ popscope(c);
    __ popscope(c);
    __ popscope(c);
    __ popscope(c);
    __ initproperty(c,scenename2);
    __ returnvoid(c);

    //abc_method_body_addClassTrait(c, "rfx:MainTimeline", 1, cls);
    multiname_t*classname = multiname_fromstring(scenename2);
    abc_initscript_addClassTrait(s, classname, cls);
    multiname_destroy(classname);

    swf_WriteABC(abctag, file);
}
예제 #14
0
파일: A88.C 프로젝트: ALANGUAGE/A2011
int name1() {if (token!=T_NAME) error1("Name erwartet"); token=getlex(); }
예제 #15
0
파일: command.c 프로젝트: tjmahr/TRACE
command()
{
float tval;
int i,echeck;
int pmin,pmax,pstep;
char tbuf[20];

while (echeck = getstring(": ")) {
	if (echeck == EOF) {
		fileinput(STD);
	}
	else if (startsame(in,"cycle")) {
		cycle();
	}
	else if (startsame(in,"coarticulation")) {
		ttyprint("coarticulation %s: change? ",(coartflag ? "ON":"OFF"));
		fscanf(infp,"%s",in);
		if(in[0] == 'n') continue;
		coartflag = 1 - coartflag;
	}
	else if (startsame(in,"rc")) {
		printf("reset and cycle\n");
		zarrays();
		cycle();
	}
	else if (startsame(in,"wordacts")) {
		printwords(printmin,printmax,3,stdout);
		if (outfile) printwords(printmin,printmax,3,outfile);
	}
	else if (startsame(in,"wtacts")) {
		printwt(printmin,printmax,3,stdout);
		if (outfile) printwt(printmin,printmax,3,outfile);
	}
	else if (startsame(in,"owtacts")) {
		getstring("word: ");
		strcpy(tbuf,in);
		printonewt(tbuf,printmin,printmax,3,stdout);
		if (outfile) printonewt(tbuf,printmin,printmax,3,outfile);
	}
	else if (startsame(in,"phonacts")) {
		printphonemes(printmin,printmax,3,stdout);
		if (outfile) 
		    printphonemes(printmin,printmax,3,outfile);
	}
	else if (startsame(in,"featacts")) {
		printf("feature activations - give min,max,step: ");
		scanf("%d %d %d",&pmin,&pmax,&pstep);
		printfeatures(pmin,pmax,pstep,stdout);
		if (outfile) printfeatures(pmin,pmax,pstep,outfile);
	}
	else if (startsame(in,"expression")) {
		setex();
	}
	else if (startsame(in,"fileinput")) {
		fileinput(NONSTD);
	}
	else if (startsame(in,"inspecs")) {
		ttyprint("File name (- = stdin): ");
		fscanf(infp,"%s",in);
		inspecs(in);
	}
	else if (startsame(in,"infeatures")) {
		ttyprint("File name: ");
		fscanf(infp,"%s",in);
		infeats(in);
	}
	/* NOT PRESENTLY OPERATIVE -- JLM 10-5-82
	else if (startsame(in,"wsubset")) {
		wordsubset();
	}
	*/
	else if (startsame(in,"test")) {
		getstring("test string: ");
		test(in);
	}
	else if (startsame(in,"topdown")) {
		topdown();
	}
	else if (startsame(in,"output")) {
		setout();
	}
	else if (startsame(in,"ofile")) {
		getstring("give filename (or - for none): ");
		setoutfile(in);
	}
	else if (in[0] == '!') {
		system(&in[1]);
	}
	else if (in[0] == '?') {
		help();
	}
	else if (startsame(in,"help")) {
		help();
	}
	else if (startsame(in,"lexicon")) {
		getlex();
	}
	else if (startsame(in,"parameters")) {
		getpars();
	}
	else if (startsame(in,"quit")) {
		quit();
	}
	else if (startsame(in,"decay")) {
		ttyprint ("decay values:\n");
		getfloat(decay,NLEVS,"F","P","W");
	}
	else if (startsame(in,"alpha")) {
		ttyprint ("alpha values:\n");
		getfloat(alpha,NPARAMS,
		 "IF","FF","FP","PP","PW","WW","WP","PF","PFC");
	}
	else if (startsame(in,"gamma")) {
		ttyprint ("gamma values:\n");
		getfloat(ga,NLEVS,"F","P","W");
	}
	else if (startsame(in,"grace")) {
		ttyprint ("grace %s: change? ",(grace ? "ON" : "OFF"));
		fscanf(infp,"%s",in);
		if (in[0] == 'n') continue;
		grace = 1 - grace;
	}
	else if (startsame(in,"rest")) {
		tval = rest[W];
		ttyprint ("rest values:\n");
		getfloat(rest,NLEVS,"F","P","W");
		if (tval != rest[W]) {
			initialize();
		}
	}
	else if (startsame(in,"fweight")) {
		ttyprint ("fweight values:\n");
		getfloat(fweight,NCONTINS,
		"POW","PIT","VOI","ABT","DIF","ACU","CON","LWS",
		"MDS", "HIS","FT1","FT2","FT3","FT4","FT5","FT6");
	}
	else if (startsame(in,"pthresh")) {
		ttyprint ("pthresh values:\n");
		getfloat(pthresh,NLEVS,"F","P","W");
	}
	else if (startsame(in,"nreps")) {
		ttyprint ("%d nreps: change? ",nreps);
		fscanf(infp,"%s",in);
		if (in[0] == 'n') continue;
		sscanf(in,"%d",&nreps);
	}
	else if (startsame(in,"pfreq")) {
		ttyprint ("%d pfreq: change? ",printfreq);
		fscanf(infp,"%s",in);
		if (in[0] == 'n') continue;
		sscanf(in,"%d",&printfreq);
	}
	else if (startsame(in,"summarypr")) {
		ttyprint("give min, max, and step: ");
		fscanf(infp,"%d %d %d",&pmin,&pmax,&pstep);
		summarypr(pmin,pmax,pstep,stdout);
		if (outfile) summarypr(pmin,pmax,pstep,outfile);
	}
	else if (startsame(in,"spointers")) {
		qsort(wordptr,nwptrs,sizeof(struct word *),ecomp);
	}
	else if (startsame(in,"sinspec")) {
		sinspec();
	}
	else if (startsame(in,"sfeatures")) {
		ttyprint("file name: ");
		fscanf(infp,"%s",in);
		sfeatures(in);
	}
	else if (startsame(in,"dinspec")) {
		dinspec();
	}
	else if (startsame(in,"acoustinput")) {
		ttyprint("give min, max, and step: ");
		fscanf(infp,"%d %d %d",&pmin,&pmax,&pstep);
		acoustinput(pmin,pmax,pstep,stdout);
		if (outfile) acoustinput(pmin,pmax,pstep,outfile);
	}
	else if (startsame(in,"sumopt")) {
		ttyprint ("summaryprint %s: change? ",(sumflag ? "ON" : "OFF"));
		fscanf(infp,"%s",in);
		if (in[0] == 'n') continue;
		sumflag = 1 - sumflag;
	}
	else if (startsame(in,"echooutput")) {
		ttyprint ("echooutput %s: change? ",(echoflag ? "ON" : "OFF"));
		fscanf(infp,"%s",in);
		if (in[0] == 'n') continue;
		echoflag = 1 - echoflag;
	}
	else if (startsame(in,"min")) {
		ttyprint ("min = ");
		getval(&min);
	}
	else if (startsame(in,"max")) {
		ttyprint ("max = ");
		getval(&max);
	}
	else if (startsame(in,"windowcent")) {
		ttyprint ("windowcent = ");
		getval(&windowcent);
	}
	else if (startsame(in,"wbase")) {
		ttyprint ("wbase = ");
		getval(&wbase);
	}
	else if (startsame(in,"wchange")) {
		ttyprint ("wchange = ");
		getval(&wchange);
	}
	else if (startsame(in,"wgain")) {
		ttyprint ("wgain = ");
		getval(&wgain);
	}
	else if (startsame(in,"wramp")) {
		ttyprint ("wramp = ");
		getval(&wramp);
	}
	else if (startsame(in,"imax")) {
		ttyprint ("imax = ");
		getval(&imax);
	}
	else if (startsame(in,"freqscale")) {
		ttyprint ("freqscale = ");
		tval = fscale;
		getval(&fscale);
		if (tval != fscale) {
		    initialize();
		}
	}
	else if (startsame(in,"abort")) {
		abort();	/* to get a core dump for sdb */
	}
	else {
		printf("Unrecognized request: For help type ?.\n");
		if (infp != stdin) fileinput(STD);
	}
	wait(0);
}
}
예제 #16
0
LISP getexpr ()         /* чтение выражения АТОМ | ЧИСЛО | '(' СПИСОК ')' */
{
	LISP p;

	switch (getlex ()) {
	default:
		fatal ("syntax error");
	case ')':
		ungetlex ();
	case 0:
		return (NIL);
	case '(':
		if (getlex () == ')')
			return (NIL);
		ungetlex ();
		p = getlist ();
		if (getlex () != ')')
			fatal ("right parence expected");
		break;
	case '\'':
		p = cons (symbol ("quote"), cons (getexpr (), NIL));
		break;
	case '`':
		p = cons (symbol ("quasiquote"), cons (getexpr (), NIL));
		break;
	case ',':
		if (getlex () == '@')
			p = cons (symbol ("unquote-splicing"), cons (getexpr (), NIL));
		else {
			ungetlex ();
			p = cons (symbol ("unquote"), cons (getexpr (), NIL));
		}
		break;
	case TSYMBOL:
		p = symbol (lexsym);
		if (trace > 2)
			fprintf (stderr, "%s\n", lexsym);
		break;
	case TBOOL:
		p = lexval ? T : NIL;
		if (trace > 2)
			fprintf (stderr, "#%c\n", lexval ? 't' : 'f');
		break;
	case TCHAR:
		p = character (lexval);
		if (trace > 2)
			fprintf (stderr, "#\\\\%03o\n", (unsigned) lexval);
		break;
	case TINTEGER:
		p = number (lexval);
		if (trace > 2)
			fprintf (stderr, "%ld\n", lexval);
		break;
	case TREAL:
		p = real (lexrealval);
		if (trace > 2)
			fprintf (stderr, "%#g\n", lexrealval);
		break;
	case TSTRING:
		p = string (lexlen, lexsym);
		if (trace > 2) {
			putstring (p, stderr);
			fprintf (stderr, "\n");
		}
		break;
	case TVECTOR:
		p = getvector ();
		if (getlex () != ')')
			fatal ("right parence expected");
		break;
	}
	return (p);
}
예제 #17
0
/* returns true if lvalue, else false */
int
expr(int needval, int prec)
{
    int na;
    int islval;
    int jdst;
    int op;
    int any;
    int opprec;

    islval = 0;

    /* parse one expr */
    if (istoken(T_CONST)) {
	emitop(C_PUSHC, lexval);
    } else if (istoken(T_STRING)) {
	/* If the syntax is ok the string must still be in the symbol buffer.
	   Stuff it into global space. */
	emitop(C_PUSHS, strsize);
	any = 0;
	while(any < strsize)
	    emit(symbol[any++]);
    } else if (istoken(T_NAME)) {
	islval = pushval();
    } else if (istoken('(')) {
	islval = expr(0, P_NONE);
	expect(')');
    } else if (istoken(T_NOT)) {
	expr(1, P_PRE);
	emit(C_NOT);
    } else if (istoken(T_SUB)) {
	expr(1, P_PRE);
	emit(C_NEG);
    } else if (istoken(T_MUL)) {
	expr(1, P_PRE);
	islval = 1;
    } else if (istoken(T_AND)) {
	if (expr(0, P_PRE) == 0)
	    error("lvalue required");
    } else
	error("syntax error in expr");

    /* one expression parsed, try for hi prec ops */
    any = 1;
    while(any) {
	op = token % OPMOD;
	if (istoken('(')) {
	    /* function call */
	    pderef(islval);
	    na = 0;
	    if (!istoken(')')) {
		do {
		    expr(1, P_NONE);
		    na++;
		} while(istoken(','));
		expect(')');
	    }
	    emitop(C_CALL, na*2);
	    islval = 0;
	} else if (istoken('[')) {
	    /* array ref */
	    pderef(islval);
	    expr(1, P_NONE);
	    emit(C_ADD);
	    expect(']');
	    islval = 1;
	} else if (istoken(T_POSTINC) || istoken(T_POSTDEC)) {
	    if (!islval)
		error("no lval for ++");
	    emit(op);
	    islval = 0;
	} else
	    any = 0;
    }

    opprec = token / OPMOD;
    while (prec < opprec) {
	if ( (op = token % OPMOD) != C_ASSIGN) {
	    pderef(islval);
	} else {
	    if (!islval)
		error("no lval for =");
	}
	if (istoken(T_ANDAND) || istoken(T_OROR)) {
	    emit(C_DUP);
	    if (op == C_OROR)
		emit(C_NOT);
	    jdst = emitj(C_JFALSE, 0);
            emit(C_POP);
	    expr(1, opprec);
	    emitat(jdst, curloc);
	} else {
	    /* emit binop code */
	    token = getlex();
	    expr(1, opprec);
	    emit(op);
	}
	islval = 0;
	opprec = token / OPMOD;
    }
    if (needval) {
	pderef(islval);
	islval = 0;
    }
    return islval;
}
예제 #18
0
파일: A88.C 프로젝트: ALANGUAGE/A2011
int doemit() {prs("\n db ");
  L1: token=getlex(); prnum(lexval); token=getlex();
    if (token== ',') {prc(','); goto L1;} expect(')'); }
예제 #19
0
파일: command.c 프로젝트: tjmahr/TRACE
command()
{
double tval;
int i,echeck;
int pmin,pmax,pstep;

while (echeck = getstring(": ")) {
	if (echeck == EOF) {
		fileinput(EOF);
	}
	else if (in[0] == '\0') {
		errprint("");
	}
	else if (startsame(in,"cycle")) {
		cycle();
	}
	else if (startsame(in,"clear")) {
		clear();
	}
	else if (startsame(in,"coarticulation")) {
		getint(&coartflag);
	}
	else if (startsame(in,"rc")) {
		zarrays();
		cycle();
	}
	else if (startsame(in,"wordacts")) {
		scr_words(printmin,printmax,3,0,"MAX");
	}
	else if (startsame(in,"wtacts")) {
		scr_words(printmin,printmax,3,0,"ALL");
	}
	else if (startsame(in,"owtacts")) {
		getstring("word: ");
		scr_words(printmin,printmax,3,0,in);
	}
	else if (startsame(in,"phonacts")) {
		scr_phonemes(printmin,printmax,3,0);
	}
	else if (startsame(in,"featacts")) {
		scr_features();
	}
	else if (startsame(in,"sfeatacts")) {
		getstring("fname: ");
		sfeatacts(in);
	}
	else if (startsame(in,"memo")) {
		getstring("string: ");
		strcpy(memo,in);
	}
	else if (startsame(in,"expr")) {
		setex();
	}
	else if (startsame(in,"fcopt")) {
	    getint(&fcflag);
	}
	else if (startsame(in,"fpcyc")) {
	    getint(&fpcyc);
	}
	else if (startsame(in,"finput")) {
		fileinput(NONSTD);
	}
	else if (startsame(in,"inoise")) {
		getval(&inoise);
	}
	else if (startsame(in,"inspecs")) {
		getstring("File name (- = stdin): ");
		inspecs(in);
	}
	else if (startsame(in,"infeatures")) {
		getstring("File name: ");
		infeats(in);
	}
	/* NOT PRESENTLY OPERATIVE -- JLM 10-5-82
	else if (startsame(in,"wsubset")) {
		wordsubset();
	}
	*/
	else if (startsame(in,"test")) {
		getstring("test string: ");
		strcpy(memo,in);
		test(in);
	}
	else if (startsame(in,"topdown")) {
		topdown();
	}
	else if (startsame(in,"output")) {
		setout();
	}
	else if (startsame(in,"ofile")) {
		getstring("give filename (or - for none): ");
		setoutfile(in);
	}
	else if (in[0] == '?') {
		help();
	}
	else if (startsame(in,"help")) {
		help();
	}
	else if (startsame(in,"lexicon")) {
		getlex();
	}
	else if (startsame(in,"params")) {
		getpars();
	}
	else if (startsame(in,"quit")) {
		quit();
	}
	else if (startsame(in,"decay")) {
		getdouble(decay,NLEVS,levlabs);
	}
	else if (startsame(in,"alpha")) {
		getdouble(alpha,NPARAMS,conlabs);
	}
	else if (startsame(in,"gamma")) {
		getdouble(ga,NLEVS,levlabs);
	}
	else if (startsame(in,"grace")) {
		getint(&grace);
	}
	else if (startsame(in,"rest")) {
		tval = rest[W];
		getdouble(rest,NLEVS,levlabs);
		if (tval != rest[W]) {
			initialize();
		}
	}
	else if (startsame(in,"fweight")) {
		getdouble(fweight,NCONTINS,contname);
	}
	else if (startsame(in,"pthresh")) {
		getdouble(pthresh,NLEVS,levlabs);
	}
	else if (startsame(in,"ngraph")) {
		newgraph(pmin,ng_max,pstep);
	}
	else if (startsame(in,"ngmax")) {
		getint(&ng_max);
	}
	else if (startsame(in,"ngwscale")) {
		getval(&ng_wscale);
	}
	else if (startsame(in,"ngsscale")) {
		getval(&ng_sscale);
	}
	else if (startsame(in,"ngpscale")) {
		getval(&ng_pscale);
	}
	else if (startsame(in,"nreps")) {
		getint(&nreps);
	}
	else if (startsame(in,"pfreq")) {
		getint(&printfreq);
	}
	else if (startsame(in,"rarate")) {
		getval(&rarate);
	}
	else if (startsame(in,"sumpr")) {
		scr_sum(pmin,pmax,pstep);
	}
	else if (startsame(in,"sinspec")) {
		sinspec();
	}
	else if (startsame(in,"sfeatures")) {
		getstring("Filename: ");
		sfeatures(in);
	}
	else if (startsame(in,"dinspec")) {
		dinspec();
	}
	else if (startsame(in,"sumopt")) {
	    getint(&sumflag);
	}
	else if (startsame(in,"pmin")) {
		getint(&pmin);
	}
	else if (startsame(in,"pmax")) {
		getint(&pmax);
	}
	else if (startsame(in,"pstep")) {
		getint(&pstep);
	}
	else if (startsame(in,"min")) {
		getval(&min);
	}
	else if (startsame(in,"max")) {
		getval(&max);
	}
	else if (startsame(in,"windowcent")) {
		getval(&windowcent);
	}
	else if (startsame(in,"wbase")) {
		getval(&wbase);
	}
	else if (startsame(in,"wgraph")) {
		wgraph(pmin,ng_max,pstep);
	}
	else if (startsame(in,"wchange")) {
		getval(&wchange);
	}
	else if (startsame(in,"wgain")) {
		getval(&wgain);
	}
	else if (startsame(in,"wramp")) {
		getval(&wramp);
	}
	else if (startsame(in,"imax")) {
		getval(&imax);
	}
	else if (startsame(in,"sscale")) {
		getval(&sscale);
	}
	else if (startsame(in,"nsscale")) {
		getval(&nsscale);
	}
	else if (startsame(in,"freqscale")) {
		tval = fscale;
		getval(&fscale);
		if (tval != fscale) {
		    initialize();
		}
	}
	else if (startsame(in,"abort")) {
		abort();	/* to get a core dump for sdb */
	}
	else {
		errprint("Unrecognized request: For help type ?.");
		if (infp != stdin) fileinput(STD);
	}
	wait(0);
}
}
예제 #20
0
파일: A88.C 프로젝트: ALANGUAGE/A2011
int isrelational() {
  if (token==T_EQ) goto w; if (token==T_NE) goto w;
  if (token==T_LE) goto w; if (token==T_GE) goto w;
  if (token=='<' ) goto w; if (token=='>' ) goto w;
  return 0;  w: iscmp=token; token=getlex(); return 1;}