Mercurial > ~dholland > hg > ag > index.cgi
diff anagram/vaclgui/openfile.cpp @ 0:13d2b8934445
Import AnaGram (near-)release tree into Mercurial.
author | David A. Holland |
---|---|
date | Sat, 22 Dec 2007 17:52:45 -0500 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/anagram/vaclgui/openfile.cpp Sat Dec 22 17:52:45 2007 -0500 @@ -0,0 +1,81 @@ +/* + * AnaGram, A System for Syntax Directed Programming + * Copyright 1993-2002 Parsifal Software. All Rights Reserved. + * See the file COPYING for license and usage terms. + * + * openfile.cpp + */ + +#include <icritsec.hpp> + +#include "data.h" +#include "error.h" +#include "openfile.hpp" +#include "operations.h" +#include "vaclgui.hpp" + +//#define INCLUDE_LOGGING +#include "log.h" + + +int analyzeThreadActive = 0; + +/***********************************************************/ +/* Overriding run() method for the file open thread */ +/* function class. This function is called implicitly */ +/* when a thread to open a file is dispatched. */ +/***********************************************************/ +void AnalyzeGrammarFn::run() { + LOGSECTION("Analyzing input file"); + LOGV((int) &IThread::current()); + IThread::current().setVariable("Error Message", ""); + try { + { + ICritSec cookie; + analyzeThreadActive = 1; + } + errorList.reset(); + analyzeGrammar(inputFile.text, 1 /* has GUI */); + LOGS("Normal return from analyzeGrammar"); + } + catch(IException &ie) { + LOGSECTION("catch(IException &)"); + LOGV(ie.text()); + IThread::current().setVariable("Error Message", ie.text()); + } + catch(Problem &p) { + LOGSECTION("catch(Problem &)"); + LOGV(p.msg); + IThread::current().setVariable("Error Message", p.msg); + } + ICritSec cookie; + analyzeThreadActive = 0; +} + +void BuildParserFn::run() { + LOGSECTION("BuildParserFn::run"); + try { + { + ICritSec cookie; + analyzeThreadActive = 1; + } + if (syntax_state != syntax_analyzed) { + errorList.reset(); + analyzeGrammar(inputFile.text, 1 /* has GUI, will travel */); + } + buildParser(); + LOGS("returned from buildParser"); + } + catch(IException &ie) { + LOGV(ie.text()); + IThread::current().setVariable("Error Message", ie.text()); + } + catch(Problem &p) { + LOGV(p.msg); + IThread::current().setVariable("Error Message", p.msg); + } + ICritSec cookie; + analyzeThreadActive = 0; + LOGS("Ready to exit"); +} +