view anagram/vaclgui/openfile.cpp @ 8:ec2b657edf13

Add explicit lint-comment-style fallthrough annotations. GCC now assumes that if you don't have these you're making a mistake, which is annoying. XXX: This changeset updates the AG output files only (by hand) and is XXX: abusive - rebuilding them will erase the change. However, I need XXX: to get things to build before I can try to get AG to issue the XXX: annotations itself, so this seems like a reasonable expedient.
author David A. Holland
date Mon, 30 May 2022 23:51:43 -0400
parents 13d2b8934445
children
line wrap: on
line source

/*
 * 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");
}