view anagram/guisupport/profile.syn @ 18:562c313f14f4

some minor updates for 2022
author David A. Holland
date Tue, 31 May 2022 02:03:50 -0400
parents 13d2b8934445
children
line wrap: on
line source

{
/*
 * AnaGram, A System for Syntax Directed Programming
 * Copyright 1993-2002 Parsifal Software. All Rights Reserved.
 * Copyright 2006 David A. Holland. All Rights Reserved.
 * See the file COPYING for license and usage terms.
 *
 * profile.syn - parse the "profile" (Windows registry entry / .AnaGram file)
 */

#include "port.h"

#include "agcstack.h"
#include "cint.h"
#include "ctrlpanel.hpp"
#include "dspar.hpp"
#include "profile-defs.h"
#include "version.h"

//#define INCLUDE_LOGGING
#include "log.h"
}

registry data $
 -> registry entry?..., "endInitializationData"?, eof

eof = 0

sep = '/' + '-'
name char = ~eof - '\n' - '\r' - '=' - '.'
file name char = ~eof - '\n' -'\r'
digit = '0-9'
letter = 'a-z' + 'A-Z'
byte = 0..255

[
  test file mask = "*.prf"
  //pointer input
  event driven
  parser name = parseRegEntry
  parser file name = "#.cpp"
  line numbers path = "regent.syn"
]

(void) registry entry
 -> qualified registry entry
 -> pure registry entry

(void) qualified registry entry
 -> accepted qualifier, pure registry entry
 -> unaccepted qualifier, file name char..., '\n'

(void) pure registry entry
 -> ag201 registry entry
//-> ag240 registry entry  // none yet

(void) ag201 registry entry
 -> "Color:", name, '=', color pair:p, '\n' = 
	ColorDialog::initColor(charStack.popString(), p);
 -> "Font:", field id:id, '=',
     font flags:f, integer:p, '.',
     name, '\n'                             =
	FontDialog::initFont(id, f,p, charStack.popString());
 -> "Autobuild=", integer:i, '\n'           = controlPanel->autobuildFlag = i;
 -> "ShowStatistics=", integer:i, '\n'      = controlPanel->showStatsFlag = i;
 -> "ShowSyntax=", integer:i, '\n'          = controlPanel->showSyntaxFlag = i;
 -> "StayOnTop=", integer:i, '\n'           = controlPanel->stayOnTopFlag = i;
 -> "cpLoc=", point:p,'\n'                  = controlPanelLocation = p;
 -> "sfRect=", rectangle:r,'\n'             = syntaxFileRect = r;
 -> "Version=", integer:i,'\n'              = lastVersion = i;
 -> "RecentFile:", file name,'\n'          =
{
  LOGSECTION("RecentFile");
  LOGV(controlPanel->recentFiles.size());
  //controlPanel->recentFiles << charStack.popString();
  controlPanel->recentFiles.push(charStack.popString());
  LOGV(controlPanel->recentFiles.size());
}

(void) accepted qualifier, unaccepted qualifier
 -> '(', qual expr:t, ')' = { if (!t) CHANGE_REDUCTION(unaccepted_qualifier); }

(int) qual expr
 -> integer:v1                  = (INTVERSION == v1);
 -> integer:v1, '-'             = (INTVERSION >= v1);
 -> integer:v1, '-', integer:v2 = (INTVERSION >= v1 && INTVERSION <= v2);

(int) font flags
 ->                        = 0;
 -> font flags:f, 'B'      = f|FontSpec::bold;
 -> font flags:f, 'I'      = f|FontSpec::italic;
 -> font flags:f, 'S'      = f|FontSpec::strikeout;
 -> font flags:f, 'U'      = f|FontSpec::underscore;

name
 -> name char:c                  = charStack.discardData().push(c);
 -> name, name char:c            = charStack.push(c);

(int) field id
 -> name                         = FontDialog::idField(charStack.popString());

(int) integer
 -> digit:d                      = d - '0';
 -> integer:i, digit:d           = 10*i + d - '0';

(int) signed integer
 -> integer
 -> '-', integer:i               = -i;

(int) hex integer
 -> hex digit:d                  = d;
 -> hex integer:i, hex digit:d   = 16*i + d;

(int) hex digit
 -> digit:d                      = d-'0';
 -> 'a-f' + 'A-F':d              = (d&7) + 9;

(cint) color pair
 -> '(', hex integer:f, ',', hex integer:g, ')'   = cint(f, g);

(IPoint) point
 -> '(', signed integer:f, ',', signed integer:g, ')'   = IPoint(f, g);

(IRectangle) rectangle
 -> '(', integer:a,',', integer:b,',', integer:c,',', integer:d, ')' =
	IRectangle(a, b, c, d);


file name
 -> file name char:c                = charStack.discardData().push(c);
 -> file name, file name char:c     = charStack.push(c);

{

  int lastVersion = 200;

  static AgCharStack charStack;

#ifndef SYNTAX_ERROR
#define SYNTAX_ERROR {\
  char buf[500];\
  sprintf(buf,"%s, line %d, column %d\n", \
  (PCB).error_message, (PCB).line, (PCB).column);\
  LOGV(buf);\
}
#endif

  int initializeFrom(const char *pointer) {
    LOGSECTION("initializeFrom");

    if (pointer == 0) {
      return 1;
    }
    init_parseRegEntry();
    do {
      PCB.input_code = (unsigned char) *pointer;
      parseRegEntry();
    }
    while (*pointer++ && PCB.exit_flag == AG_RUNNING_CODE);
    return PCB.exit_flag != AG_SUCCESS_CODE;
  }
}