1 / 7

مولد تحلیلگر نحوی

مولد تحلیلگر نحوی. مولد تحلیلگر نحوی. void main() { int NoRules, len; char **Rules, *statement; NoRules = ReadGrammar(&rules, statement); len = TopDownParse(rules, statement, 0, NoRules, 0); if(len != strlen(statement)) { clrscr(); puts("ERROR"); } }.

onaona
Download Presentation

مولد تحلیلگر نحوی

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. مولد تحلیلگر نحوی

  2. مولد تحلیلگر نحوی

  3. void main() { int NoRules, len; char **Rules, *statement; NoRules = ReadGrammar(&rules, statement); len = TopDownParse(rules, statement, 0, NoRules, 0); if(len != strlen(statement)) { clrscr(); puts("ERROR"); } }

  4. int TopDownParse(char **rules, char *statement, int start, int NoRules, int ix) { int i, j, k, m, NewK; char leftterm, input; input = statement[ix]; i= StartWhichRule(rules, input, start, NoRules); if(i < 0)return ix; for(j=1,k=ix; rules[i][j] && statement[k] && i< NoRules; j++) if(isupper(rules[i][j])) { for(m = 0; rules[m][0] != rules[i][j] && m < NoRules; m++); Newk = TopDownParse(rules, statement, m, NoRules, k); if(k==NewK) return 0; else k = NewK; } else if(rules[i][j] == statement[k]) k++; return k }

  5. int StartWhichRule(char **rules, char input, int start, int NoRules) { int success, i, k; char LeftNonTerm; LeftNonTerm = rules[start][0]; i= start; while((rules[i][1] !=input) && rules[i][0] == LeftNonTerm)) i++; if(rules[i][1] == input) return i; for(i = start, success = -1; rules[i][0] == LeftNonTerm && success < 0; i++) if(isupper(rules[i][1])) { for(k = 0; rules[k][0] != rules[i][1] && k < NoRules; k++); success = StartWhicnRule(rules, input, k, NoRules); } if (success <0) return success; retum i; }

  6. int StartWhichRule(char **rules, char input, int start, int NoRules) { int success, i, k; char LeftNonTerm; LeftNonTerm = rules[start][0]; i= start; while((rules[i][1] !=input) && rules[i][0] == LeftNonTerm)) i++; if((rules[i][1] == input) && rules[i][0] == LeftNonTerm)) return i; for(i = start, success = -1; rules[i][0] == LeftNonTerm && success < 0; i++) if(isupper(rules[i][1])) { for(k = 0; rules[k][0] != rules[i][1] && k < NoRules; k++); success = StartWhicnRule(rules, input, k, NoRules); } if (success <0) return success; retum i; }

More Related