int FindSymbol(char str[],int pos) /*找到一个符号或括号,进行相应的处理*/ { int h,k; char word[MAXTOKEN]; word[0]=str[pos]; word[1]='\0'; pos++; if ((h=hashtable[Hash(word)])==-1) /*在lexicon中找不到该符号*/ { printf("表达式中存在不能识别的符号\n"); return -1; } else if (Leading()==1) /*若之前有"("、一元或二元运算符*/ { if (Kind(h)==RIGHTPAREN) /*当前符号为")"*/ { printf("不应为右括号\n"); return -1; } else if (Kind(h)!=BINARYOP) /*当前符号不为二元运算符,将其添加到infix中*/ PutToken(h); else /*当前符号为二元运算符*/ { if (strcmp(word,"+")==0); /*为"+"时,应是一元"+",不做任何事件*/ else if (strcmp(word,"-")==0) /*为"-"时,应是一元"-",将"~"添加到infix中*/ PutToken(hashtable[Hash("~")]); else /*其他二元运算符为非法*/ { printf(" >>二元运算符不正确\n"); return -1; } } } else /*Leading()=0时*/ { if (Kind(h)==BINARYOP || Kind(h)==RIGHTPAREN) /*将二元运算符或")"添加到infix中*/ PutToken(h); else { printf("二元运算符不正确\n"); return -1; } } if ((k=Kind(h))==LEFTPAREN) parencount++; else if (k==RIGHTPAREN) if (--parencount<0) /*左、右括号不匹配*/ { printf("太多的右括号\n"); return -1; } return pos; }
int FindNumber(char str[],int pos) /*找到一个操作数,进行相应的处理*/ { if (Leading()==0) { printf("常量位置不正确\n"); return -1; } else /*将当前识别的操作数添加到lexicon表中*/ { lexicon[++tokencount].kind=OPERAND; lexicon[tokencount].info.val=atof(&str[pos]); /*将该操作数串转换成数值*/ strcpy(lexicon[tokencount].name,"number"); PutToken(tokencount); /*将lexicon中对应的下标添加到infix中*/ for (;isdigit(str[pos]) || str[pos]=='.';pos++); /*扫描完该操作数*/ return pos; } }
int FindWord(char str[],int pos) /*找到一个单词,进行相应的处理*/ { int h; char word[MAXTOKEN]; pos=ExtractWord(str,pos,word); h=hashtable[Hash(word)]; if (h!=-1) /*在哈希表中找到时*/ { if (Leading()==1) { if (Kind(h)==BINARYOP) { printf("二元运算符位置不正确\n"); return -1; } else PutToken(h); } else { if (Kind(h)!=BINARYOP) { printf("应为二元运算符\n"); return -1; } else PutToken(h); } return pos; } else /*h==-1时*/ { printf(" >>不正确的标识符\n"); return -1; } }
void CTextStyle::FromOldStyle(const TextStyle& style) { // Set some defaults. SetDefault(); // Copy the style information over. Font(style.get_face()); Size(MakeFixed(style.get_size(), style.get_size_fraction())); BaseSize(MakeFixed(style.get_base_size(), style.get_base_size_fraction())); Expansion(DivFixed(MakeFixed(style.get_base_size(), style.get_base_size_fraction()), MakeFixed(FONT_EXPANSION_UNIT))); Fill(style.get_pattern(), style.get_color()); Outline(style.get_outline(), style.get_color()); Shadow(style.get_shadow(), style.get_color()); m_Character.m_nEffectsVersion = 1; XFlipped(style.get_xflipped()); YFlipped(style.get_yflipped()); // Color(style.get_color()); Alignment(style.get_line_alignment()); VerticalAlignment(style.get_vertical_alignment()); // Left and right margin should be zero (default) unless set by user. // This fixes a problem converting old warp text boxes - they should // always have zero margins! LeftMargin(0); RightMargin(0); // LeftMargin(PageToInches(style.get_left_margin())); // RightMargin(PageToInches(style.get_right_margin())); LeadingType(LEADING_lines); Leading(MakeFixed(0.875)); Underline(style.UnderlineStyle()); // Update our metrics. UpdateFontMetrics(); }