Lines Matching refs:psp

1903 static void parseonetoken(psp)
1904 struct pstate *psp;
1907 x = Strsafe(psp->tokenstart); /* Save the token permanently */
1909 printf("%s:%d: Token=[%s] state=%d\n",psp->filename,psp->tokenlineno,
1910 x,psp->state);
1912 switch( psp->state ){
1914 psp->prevrule = 0;
1915 psp->preccounter = 0;
1916 psp->firstrule = psp->lastrule = 0;
1917 psp->gp->nrule = 0;
1921 psp->state = WAITING_FOR_DECL_KEYWORD;
1923 psp->lhs = Symbol_new(x);
1924 psp->nrhs = 0;
1925 psp->lhsalias = 0;
1926 psp->state = WAITING_FOR_ARROW;
1928 if( psp->prevrule==0 ){
1929 ErrorMsg(psp->filename,psp->tokenlineno,
1932 psp->errorcnt++;
1933 }else if( psp->prevrule->code!=0 ){
1934 ErrorMsg(psp->filename,psp->tokenlineno,
1937 psp->errorcnt++;
1939 psp->prevrule->line = psp->tokenlineno;
1940 psp->prevrule->code = &x[1];
1943 psp->state = PRECEDENCE_MARK_1;
1945 ErrorMsg(psp->filename,psp->tokenlineno,
1948 psp->errorcnt++;
1953 ErrorMsg(psp->filename,psp->tokenlineno,
1955 psp->errorcnt++;
1956 }else if( psp->prevrule==0 ){
1957 ErrorMsg(psp->filename,psp->tokenlineno,
1959 psp->errorcnt++;
1960 }else if( psp->prevrule->precsym!=0 ){
1961 ErrorMsg(psp->filename,psp->tokenlineno,
1964 psp->errorcnt++;
1966 psp->prevrule->precsym = Symbol_new(x);
1968 psp->state = PRECEDENCE_MARK_2;
1972 ErrorMsg(psp->filename,psp->tokenlineno,
1974 psp->errorcnt++;
1976 psp->state = WAITING_FOR_DECL_OR_RULE;
1980 psp->state = IN_RHS;
1982 psp->state = LHS_ALIAS_1;
1984 ErrorMsg(psp->filename,psp->tokenlineno,
1986 psp->lhs->name);
1987 psp->errorcnt++;
1988 psp->state = RESYNC_AFTER_RULE_ERROR;
1993 psp->lhsalias = x;
1994 psp->state = LHS_ALIAS_2;
1996 ErrorMsg(psp->filename,psp->tokenlineno,
1998 x,psp->lhs->name);
1999 psp->errorcnt++;
2000 psp->state = RESYNC_AFTER_RULE_ERROR;
2005 psp->state = LHS_ALIAS_3;
2007 ErrorMsg(psp->filename,psp->tokenlineno,
2008 "Missing \")\" following LHS alias name \"%s\".",psp->lhsalias);
2009 psp->errorcnt++;
2010 psp->state = RESYNC_AFTER_RULE_ERROR;
2015 psp->state = IN_RHS;
2017 ErrorMsg(psp->filename,psp->tokenlineno,
2019 psp->lhs->name,psp->lhsalias);
2020 psp->errorcnt++;
2021 psp->state = RESYNC_AFTER_RULE_ERROR;
2028 sizeof(struct symbol*)*psp->nrhs + sizeof(char*)*psp->nrhs );
2030 ErrorMsg(psp->filename,psp->tokenlineno,
2032 psp->errorcnt++;
2033 psp->prevrule = 0;
2036 rp->ruleline = psp->tokenlineno;
2038 rp->rhsalias = (char**)&(rp->rhs[psp->nrhs]);
2039 for(i=0; i<psp->nrhs; i++){
2040 rp->rhs[i] = psp->rhs[i];
2041 rp->rhsalias[i] = psp->alias[i];
2043 rp->lhs = psp->lhs;
2044 rp->lhsalias = psp->lhsalias;
2045 rp->nrhs = psp->nrhs;
2048 rp->index = psp->gp->nrule++;
2052 if( psp->firstrule==0 ){
2053 psp->firstrule = psp->lastrule = rp;
2055 psp->lastrule->next = rp;
2056 psp->lastrule = rp;
2058 psp->prevrule = rp;
2060 psp->state = WAITING_FOR_DECL_OR_RULE;
2062 if( psp->nrhs>=MAXRHS ){
2063 ErrorMsg(psp->filename,psp->tokenlineno,
2066 psp->errorcnt++;
2067 psp->state = RESYNC_AFTER_RULE_ERROR;
2069 psp->rhs[psp->nrhs] = Symbol_new(x);
2070 psp->alias[psp->nrhs] = 0;
2071 psp->nrhs++;
2073 }else if( x[0]=='(' && psp->nrhs>0 ){
2074 psp->state = RHS_ALIAS_1;
2076 ErrorMsg(psp->filename,psp->tokenlineno,
2078 psp->errorcnt++;
2079 psp->state = RESYNC_AFTER_RULE_ERROR;
2084 psp->alias[psp->nrhs-1] = x;
2085 psp->state = RHS_ALIAS_2;
2087 ErrorMsg(psp->filename,psp->tokenlineno,
2089 x,psp->rhs[psp->nrhs-1]->name);
2090 psp->errorcnt++;
2091 psp->state = RESYNC_AFTER_RULE_ERROR;
2096 psp->state = IN_RHS;
2098 ErrorMsg(psp->filename,psp->tokenlineno,
2099 "Missing \")\" following LHS alias name \"%s\".",psp->lhsalias);
2100 psp->errorcnt++;
2101 psp->state = RESYNC_AFTER_RULE_ERROR;
2106 psp->declkeyword = x;
2107 psp->declargslot = 0;
2108 psp->decllnslot = 0;
2109 psp->state = WAITING_FOR_DECL_ARG;
2111 psp->declargslot = &(psp->gp->name);
2113 psp->declargslot = &(psp->gp->include);
2114 psp->decllnslot = &psp->gp->includeln;
2116 psp->declargslot = &(psp->gp->extracode);
2117 psp->decllnslot = &psp->gp->extracodeln;
2119 psp->declargslot = &psp->gp->tokendest;
2120 psp->decllnslot = &psp->gp->tokendestln;
2122 psp->declargslot = &psp->gp->vardest;
2123 psp->decllnslot = &psp->gp->vardestln;
2125 psp->declargslot = &psp->gp->tokenprefix;
2127 psp->declargslot = &(psp->gp->error);
2128 psp->decllnslot = &psp->gp->errorln;
2130 psp->declargslot = &(psp->gp->accept);
2131 psp->decllnslot = &psp->gp->acceptln;
2133 psp->declargslot = &(psp->gp->failure);
2134 psp->decllnslot = &psp->gp->failureln;
2136 psp->declargslot = &(psp->gp->overflow);
2137 psp->decllnslot = &psp->gp->overflowln;
2139 psp->declargslot = &(psp->gp->arg);
2141 psp->declargslot = &(psp->gp->tokentype);
2143 psp->declargslot = &(psp->gp->vartype);
2145 psp->declargslot = &(psp->gp->stacksize);
2147 psp->declargslot = &(psp->gp->start);
2149 psp->preccounter++;
2150 psp->declassoc = LEFT;
2151 psp->state = WAITING_FOR_PRECEDENCE_SYMBOL;
2153 psp->preccounter++;
2154 psp->declassoc = RIGHT;
2155 psp->state = WAITING_FOR_PRECEDENCE_SYMBOL;
2157 psp->preccounter++;
2158 psp->declassoc = NONE;
2159 psp->state = WAITING_FOR_PRECEDENCE_SYMBOL;
2161 psp->state = WAITING_FOR_DESTRUCTOR_SYMBOL;
2163 psp->state = WAITING_FOR_DATATYPE_SYMBOL;
2165 psp->fallback = 0;
2166 psp->state = WAITING_FOR_FALLBACK_ID;
2168 ErrorMsg(psp->filename,psp->tokenlineno,
2170 psp->errorcnt++;
2171 psp->state = RESYNC_AFTER_DECL_ERROR;
2174 ErrorMsg(psp->filename,psp->tokenlineno,
2176 psp->errorcnt++;
2177 psp->state = RESYNC_AFTER_DECL_ERROR;
2182 ErrorMsg(psp->filename,psp->tokenlineno,
2184 psp->errorcnt++;
2185 psp->state = RESYNC_AFTER_DECL_ERROR;
2188 psp->declargslot = &sp->destructor;
2189 psp->decllnslot = &sp->destructorln;
2190 psp->state = WAITING_FOR_DECL_ARG;
2195 ErrorMsg(psp->filename,psp->tokenlineno,
2197 psp->errorcnt++;
2198 psp->state = RESYNC_AFTER_DECL_ERROR;
2201 psp->declargslot = &sp->datatype;
2202 psp->decllnslot = 0;
2203 psp->state = WAITING_FOR_DECL_ARG;
2208 psp->state = WAITING_FOR_DECL_OR_RULE;
2213 ErrorMsg(psp->filename,psp->tokenlineno,
2215 psp->errorcnt++;
2217 sp->prec = psp->preccounter;
2218 sp->assoc = psp->declassoc;
2221 ErrorMsg(psp->filename,psp->tokenlineno,
2223 psp->errorcnt++;
2228 if( *(psp->declargslot)!=0 ){
2229 ErrorMsg(psp->filename,psp->tokenlineno,
2231 x[0]=='\"' ? &x[1] : x,psp->declkeyword);
2232 psp->errorcnt++;
2233 psp->state = RESYNC_AFTER_DECL_ERROR;
2235 *(psp->declargslot) = (x[0]=='\"' || x[0]=='{') ? &x[1] : x;
2236 if( psp->decllnslot ) *psp->decllnslot = psp->tokenlineno;
2237 psp->state = WAITING_FOR_DECL_OR_RULE;
2240 ErrorMsg(psp->filename,psp->tokenlineno,
2241 "Illegal argument to %%%s: %s",psp->declkeyword,x);
2242 psp->errorcnt++;
2243 psp->state = RESYNC_AFTER_DECL_ERROR;
2248 psp->state = WAITING_FOR_DECL_OR_RULE;
2250 ErrorMsg(psp->filename, psp->tokenlineno,
2252 psp->errorcnt++;
2255 if( psp->fallback==0 ){
2256 psp->fallback = sp;
2258 ErrorMsg(psp->filename, psp->tokenlineno,
2260 psp->errorcnt++;
2262 sp->fallback = psp->fallback;
2263 psp->gp->has_fallback = 1;
2268 /* if( x[0]=='.' ) psp->state = WAITING_FOR_DECL_OR_RULE;
2271 if( x[0]=='.' ) psp->state = WAITING_FOR_DECL_OR_RULE;
2272 if( x[0]=='%' ) psp->state = WAITING_FOR_DECL_KEYWORD;