The Meta-Environment API
00001 #ifndef __PARSE_FOCUSES__ 00002 #define __PARSE_FOCUSES__ 00003 00004 #include <sglr.idef> 00005 #include <unparser.idef> 00006 #include <position-annotator.idef> 00007 #include <error-support.idef> 00008 #include <restorebrackets.idef> 00009 #include <ambiguity-reporter.idef> 00010 00011 process AnnotateTree(Tree: term, File: str, AnnotatedTree: term?) is 00012 AddJob("Adding position information") 00013 . snd-msg(add-posinfo-packed(File, Tree)) 00014 . rec-msg(tree-with-pos-info(AnnotatedTree?)) 00015 . JobDone("Adding position information") 00016 00017 process ReportAmbs(Tree: term, File: str, Summary: summary?) is 00018 AddJob("Computing ambiguity report") 00019 . snd-msg(ar-report-ambiguities(Tree, File)) 00020 . rec-msg(ar-ambiguity-report(Summary?, File)) 00021 . JobDone("Computing ambiguity report") 00022 00023 process HasTextChanged(Sid: session-id, TextChanged: bool?) is 00024 snd-msg(te-is-modified(Sid)) 00025 . rec-msg(te-is-modified(Sid, TextChanged?)) 00026 00027 process AddFilenameToParseError(Error: term, Filename: str, Result: term?) is 00028 snd-msg(es-add-filename-in-error(Filename, Error)) 00029 . rec-msg(es-filename-in-error(Filename, Result?)) 00030 00031 process ParseText(Pid: int, Text: str, Table: term, Nonterminal: term, Heuristics: term) is 00032 let 00033 ErrorSummary: term, 00034 ParseResult: term 00035 in 00036 snd-msg(sglr-parse(Text, Table, Nonterminal, Heuristics)) 00037 . AddJob("Parsing") 00038 . 00039 ( 00040 rec-msg(sglr-parse-tree(ParseResult?, ErrorSummary?)) 00041 . snd-msg(sglr-parse-tree(Pid, ParseResult, ErrorSummary)) 00042 + 00043 rec-msg(sglr-parse-error(ErrorSummary?)) 00044 . snd-msg(sglr-parse-error(Pid, ErrorSummary)) 00045 ) 00046 . JobDone("Parsing") 00047 endlet 00048 00049 process AmbiguityHandler(ParseResult: term, Path: str) is 00050 let 00051 Summary : summary 00052 in 00053 RemoveAmbiguitySummary(Path) 00054 . ReportAmbs(ParseResult, Path, Summary?) 00055 . DisplaySummary(Summary) 00056 endlet 00057 00058 process RemoveAmbiguitySummary(Path: str) is 00059 RemoveSummary("ambtracker", Path) 00060 00061 process ParseTreeHandler(ModuleId: module-id, Path: str) is 00062 let 00063 ParseSummary: term, 00064 ParseResult: term, 00065 Pid: int, 00066 Summary: summary, 00067 P : int 00068 in 00069 Pid := process-id 00070 . RemoveSummary("parser", Path) 00071 . 00072 ( 00073 ( 00074 rec-msg(sglr-parse-tree(Pid, ParseResult?, ParseSummary?)) 00075 . 00076 if not-equal(ParseSummary, UNDEFINED) then 00077 snd-msg(es-set-summary-id(ParseSummary, Path)) 00078 . rec-msg(es-summary(Summary?)) 00079 . AddFilenameToSummary(Summary, Path, Summary?) 00080 . DisplaySummary(Summary) 00081 else 00082 tau 00083 fi 00084 ) 00085 . snd-msg(parse-handler-done(Pid, ModuleId, ParseResult)) 00086 + 00087 rec-msg(sglr-parse-error(Pid, ParseSummary?)) 00088 . snd-msg(es-set-summary-id(ParseSummary, Path)) 00089 . rec-msg(es-summary(Summary?)) 00090 . AddFilenameToSummary(Summary, Path, Summary?) 00091 . DisplaySummary(Summary) 00092 . snd-msg(parse-handler-done(Pid)) 00093 ) 00094 endlet 00095 00096 process UnParseTerm(Tree: term, Text: str?) is 00097 snd-msg(unparse(Tree)) 00098 . rec-msg(unparsed-text(Text?)) 00099 00100 process AddFilenameToSummary(ParseSummary: summary, Path: str, Summary: summary?) is 00101 let 00102 Error: term, 00103 Errors: list, 00104 Id: str, 00105 NewErrors: list, 00106 Producer: str 00107 in 00108 snd-msg(get-summary-errors(ParseSummary)) 00109 . rec-msg(summary-errors(Errors?)) 00110 . NewErrors := [] 00111 . 00112 if not-equal(Errors, []) then 00113 Error := first(Errors) 00114 . Errors := next(Errors) 00115 . snd-msg(es-add-filename-in-error(Path, Error)) 00116 . rec-msg(es-filename-in-error(Path, Error?)) 00117 . NewErrors := join(NewErrors, [Error]) 00118 fi 00119 * 00120 if equal(Errors, []) then 00121 snd-msg(get-feedback-producer(ParseSummary)) 00122 . rec-msg(producer(Producer?)) 00123 . snd-msg(get-feedback-identification(ParseSummary)) 00124 . rec-msg(identification(Id?)) 00125 . snd-msg(es-make-summary(Producer, Id, NewErrors)) 00126 . rec-msg(es-summary(Summary?)) 00127 fi 00128 endlet 00129 00130 process RestoreTermBrackets(ModuleId: module-id, Tree: term, Result: term?) is 00131 let 00132 Table: term 00133 in 00134 GetParseTable(ModuleId, trm, Table?) 00135 . 00136 if not-equal(Table, UNDEFINED) then 00137 snd-msg(restore-brackets(Tree, Table)) 00138 . rec-msg(brackets-restored(Result?)) 00139 else 00140 Result := UNDEFINED 00141 fi 00142 endlet 00143 00144 process AddTermBrackets(ModuleId: module-id, Tree: term, Result: term?) is 00145 let 00146 Table: term 00147 in 00148 GetParseTable(ModuleId, trm, Table?) 00149 . 00150 if not-equal(Table, UNDEFINED) then 00151 snd-msg(add-brackets(Tree, Table)) 00152 . rec-msg(brackets-added(Result?)) 00153 else 00154 Result := UNDEFINED 00155 fi 00156 endlet 00157 00158 00159 00160 #endif /*__PARSE_FOCUSES__*/