Added wxExpr parser/lexer files which had somehow got lost;
added some pragmas. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@175 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
ca7731b7c8
commit
cfe780fb99
@ -10,6 +10,10 @@
|
||||
// Licence: wxWindows license
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "fileconf.h"
|
||||
#endif
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
195
src/common/lexer.l
Normal file
195
src/common/lexer.l
Normal file
@ -0,0 +1,195 @@
|
||||
SIGN [+-]
|
||||
DIGIT [0-9]
|
||||
ALPHA [a-zA-Z_]
|
||||
ALPHADIGIT [a-zA-Z_0-9]
|
||||
STRINGCHAR [^"\\]
|
||||
WORDCHAR [^'\\]
|
||||
|
||||
%{
|
||||
/*
|
||||
* File: lexer.l
|
||||
* Description: Lexical analyser for PROLOGIO; can be used with
|
||||
* either lex and flex.
|
||||
*/
|
||||
#include <string.h>
|
||||
|
||||
/* +++steve162e: added, otherwise, PROIO_input will be undefined (at least under LINUX)
|
||||
please check, if this is also TRUE under other UNIXes.
|
||||
*/
|
||||
|
||||
#if defined(FLEX_SCANNER) && defined(_LINUX)
|
||||
#define PROIO_input my_input
|
||||
#endif
|
||||
/* ---steve162e */
|
||||
|
||||
#include "wx/expr.h"
|
||||
|
||||
#ifdef wx_x
|
||||
extern char *malloc();
|
||||
#endif
|
||||
#define Return(x) return x;
|
||||
|
||||
#if defined(VMS) && !defined(strdup)
|
||||
#define strdup(s) (strcpy((char *)malloc(strlen(s)+1), s));
|
||||
#endif
|
||||
|
||||
static size_t lex_buffer_length = 0;
|
||||
static const char *lex_buffer = NULL;
|
||||
static size_t lex_string_ptr = 0;
|
||||
static int lex_read_from_string = 0;
|
||||
|
||||
static int my_input(void);
|
||||
static int my_unput(char);
|
||||
|
||||
#ifdef FLEX_SCANNER
|
||||
#undef YY_INPUT
|
||||
# define YY_INPUT(buf,result,max_size) \
|
||||
if (lex_read_from_string) \
|
||||
{ int c = my_input(); result = (c == 0) ? YY_NULL : ((buf)[0]=(c), 1); } \
|
||||
else \
|
||||
if ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \
|
||||
YY_FATAL_ERROR( "read() in flex scanner failed" );
|
||||
#else
|
||||
# undef unput
|
||||
# define unput(_c) my_unput(_c)
|
||||
#endif
|
||||
|
||||
%}
|
||||
|
||||
%%
|
||||
|
||||
{SIGN}?{DIGIT}+ {yylval.s = strdup(yytext); Return(INTEGER);}
|
||||
|
||||
"e" Return(EXP);
|
||||
|
||||
{ALPHA}{ALPHADIGIT}* {yylval.s = strdup(yytext); Return(WORD);}
|
||||
|
||||
"'"{WORDCHAR}*"'" {int len = strlen(yytext);
|
||||
yytext[len-1] = 0;
|
||||
yylval.s = strdup(yytext+1);
|
||||
Return(WORD);}
|
||||
|
||||
\"({STRINGCHAR}|\\\"|\|\\\\|\\)*\" {yylval.s = strdup(yytext); Return(STRING);}
|
||||
|
||||
"(" Return(OPEN);
|
||||
|
||||
")" Return(CLOSE);
|
||||
|
||||
"," Return(COMMA);
|
||||
|
||||
"[" Return(OPEN_SQUARE);
|
||||
|
||||
"]" Return(CLOSE_SQUARE);
|
||||
|
||||
"=" Return(EQUALS);
|
||||
|
||||
"." Return(PERIOD);
|
||||
|
||||
[ \t] ;
|
||||
|
||||
\n ;
|
||||
|
||||
"/*" { loop:
|
||||
#ifdef __cplusplus
|
||||
while (yyinput() != '*');
|
||||
switch (yyinput())
|
||||
#else
|
||||
while (input() != '*');
|
||||
switch (input())
|
||||
#endif
|
||||
{
|
||||
case '/': break;
|
||||
case '*': unput('*');
|
||||
default: goto loop;
|
||||
}
|
||||
}
|
||||
|
||||
. Return(ERROR);
|
||||
|
||||
%%
|
||||
|
||||
|
||||
#ifdef FLEX_SCANNER
|
||||
static int lex_input() {
|
||||
return input();
|
||||
}
|
||||
#else /* BSD/AT&T lex */
|
||||
#ifndef input
|
||||
# error "Sorry, but need either flex or AT&T lex"
|
||||
#endif
|
||||
static int lex_input() {
|
||||
return input();
|
||||
}
|
||||
/* # undef unput
|
||||
# define unput(_c) my_unput(_c)
|
||||
*/
|
||||
|
||||
# undef input
|
||||
# define input() my_input()
|
||||
static int my_unput(char c)
|
||||
{
|
||||
if (lex_read_from_string) {
|
||||
/* Make sure we have something */
|
||||
if (lex_string_ptr) {
|
||||
if (c == '\n') yylineno--;
|
||||
lex_string_ptr--;
|
||||
}
|
||||
} else {
|
||||
yytchar= (c);if(yytchar=='\n')yylineno--;*yysptr++=yytchar;
|
||||
/* unput(c); Causes infinite recursion! */
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* Public */
|
||||
void LexFromFile(FILE *fd)
|
||||
{
|
||||
lex_read_from_string = 0;
|
||||
yyin = fd;
|
||||
/* Don't know why this is necessary, but otherwise
|
||||
* lex only works _once_!
|
||||
*/
|
||||
#ifdef FLEX_SCANNER
|
||||
yyrestart(fd);
|
||||
yy_init = 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
void LexFromString(char *buffer)
|
||||
{
|
||||
lex_read_from_string = 1;
|
||||
lex_buffer = buffer;
|
||||
lex_buffer_length = strlen(buffer);
|
||||
lex_string_ptr = 0;
|
||||
/* Don't know why this is necessary, but otherwise
|
||||
* lex only works _once_!
|
||||
*/
|
||||
#ifdef FLEX_SCANNER
|
||||
yy_init = 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int my_input( void )
|
||||
{
|
||||
if (lex_read_from_string) {
|
||||
if (lex_string_ptr == lex_buffer_length)
|
||||
return 0;
|
||||
else {
|
||||
char c = lex_buffer[lex_string_ptr++];
|
||||
#ifndef FLEX_SCANNER
|
||||
if (c == '\n') yylineno++;
|
||||
#endif
|
||||
return c;
|
||||
}
|
||||
} else {
|
||||
return lex_input();
|
||||
}
|
||||
}
|
||||
|
||||
void wxExprCleanUp()
|
||||
{
|
||||
if (yy_current_buffer)
|
||||
yy_delete_buffer(yy_current_buffer);
|
||||
}
|
157
src/common/parser.y
Normal file
157
src/common/parser.y
Normal file
@ -0,0 +1,157 @@
|
||||
%{
|
||||
#include <string.h>
|
||||
#include "wx/expr.h"
|
||||
|
||||
#ifndef __EXTERN_C__
|
||||
#define __EXTERN_C__ 1
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus) || defined(__STDC__)
|
||||
#if defined(__cplusplus) && defined(__EXTERN_C__)
|
||||
extern "C" {
|
||||
#endif
|
||||
#endif
|
||||
int yylex(void);
|
||||
int yylook(void);
|
||||
int yywrap(void);
|
||||
int yyback(int *, int);
|
||||
void yyerror(char *);
|
||||
|
||||
/* You may need to put /DLEX_SCANNER in your makefile
|
||||
* if you're using LEX!
|
||||
*/
|
||||
#ifdef LEX_SCANNER
|
||||
/* int yyoutput(int); */
|
||||
void yyoutput(int);
|
||||
#else
|
||||
void yyoutput(int);
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus) || defined(__STDC__)
|
||||
#if defined(__cplusplus) && defined(__EXTERN_C__)
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
%}
|
||||
|
||||
%union {
|
||||
char *s;
|
||||
/* struct pexpr *expr; */
|
||||
}
|
||||
|
||||
|
||||
%start commands
|
||||
|
||||
%token <s> INTEGER 1
|
||||
%token <s> WORD 2
|
||||
%token <s> STRING 3
|
||||
%token <s> PERIOD 13
|
||||
%token OPEN 4
|
||||
%token CLOSE 5
|
||||
%token COMMA 6
|
||||
%token NEWLINE 7
|
||||
%token ERROR 8
|
||||
%token OPEN_SQUARE 9
|
||||
%token CLOSE_SQUARE 10
|
||||
%token EQUALS 11
|
||||
%token EXP 14
|
||||
|
||||
/* %type <expr> command expr arglist arg arg1 */
|
||||
%type <s> command expr arglist arg arg1
|
||||
|
||||
%%
|
||||
|
||||
commands : /* empty */
|
||||
| commands command
|
||||
;
|
||||
|
||||
command : WORD PERIOD
|
||||
{process_command(proio_cons(make_word($1), NULL)); free($1);}
|
||||
| expr PERIOD
|
||||
{process_command($1);}
|
||||
| error PERIOD
|
||||
{syntax_error("Unrecognized command.");}
|
||||
;
|
||||
|
||||
expr : WORD OPEN arglist CLOSE
|
||||
{$$ = proio_cons(make_word($1), $3); free($1);}
|
||||
| OPEN_SQUARE CLOSE_SQUARE
|
||||
{$$ = proio_cons(NULL, NULL);}
|
||||
| OPEN_SQUARE arglist CLOSE_SQUARE
|
||||
{$$ = $2; }
|
||||
;
|
||||
|
||||
arglist :
|
||||
{$$ = NULL;}
|
||||
| arg
|
||||
{$$ = proio_cons($1, NULL);}
|
||||
|
|
||||
arg COMMA arglist
|
||||
{$$ = proio_cons($1, $3);}
|
||||
;
|
||||
|
||||
arg : WORD EQUALS arg1
|
||||
{$$ = proio_cons(make_word("="), proio_cons(make_word($1), proio_cons($3, NULL)));
|
||||
free($1); }
|
||||
| arg1
|
||||
{$$ = $1; }
|
||||
|
||||
arg1 : WORD
|
||||
{$$ = make_word($1); free($1);}
|
||||
| STRING
|
||||
{$$ = make_string($1); free($1);}
|
||||
| INTEGER
|
||||
{$$ = make_integer($1); free($1);}
|
||||
| INTEGER PERIOD INTEGER
|
||||
{$$ = make_real($1, $3); free($1); free($3); }
|
||||
| INTEGER EXP INTEGER
|
||||
{$$ = make_exp($1, $3); free($1); free($3); }
|
||||
|
|
||||
INTEGER PERIOD INTEGER EXP INTEGER
|
||||
{$$ = make_exp2($1, $3, $5); free($1); free($3);
|
||||
free($5); }
|
||||
|
||||
| expr
|
||||
{$$ = $1;}
|
||||
;
|
||||
|
||||
%%
|
||||
|
||||
#include "../common/lex_yy.c"
|
||||
|
||||
/*
|
||||
void yyerror(s)
|
||||
char *s;
|
||||
{
|
||||
syntax_error(s);
|
||||
}
|
||||
*/
|
||||
|
||||
/* Ansi prototype. If this doesn't work for you... uncomment
|
||||
the above instead.
|
||||
*/
|
||||
|
||||
void yyerror(char *s)
|
||||
{
|
||||
syntax_error(s);
|
||||
}
|
||||
|
||||
/*
|
||||
* Unfortunately, my DOS version of FLEX
|
||||
* requires yywrap to be #def'ed, whereas
|
||||
* the UNIX flex expects a proper function.
|
||||
*/
|
||||
|
||||
/* Not sure if __SC__ is the appropriate thing
|
||||
* to test
|
||||
*/
|
||||
|
||||
#ifndef __SC__
|
||||
#ifdef USE_DEFINE
|
||||
#ifndef yywrap
|
||||
#define yywrap() 1
|
||||
#endif
|
||||
#else if !defined(__alpha) && !defined(__ultrix)
|
||||
int yywrap() { return 1; }
|
||||
#endif
|
||||
#endif
|
@ -10,7 +10,7 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "utils.h"
|
||||
#pragma implementation "utilscmn.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
|
@ -59,12 +59,12 @@ RESFLAGS=--include-dir $(WXDIR)/include --define __WIN32__ --define __WIN95__ --
|
||||
# Data General: -DDG
|
||||
# HP: -D_HPUX_SOURCE +a1 -Aa +d -z
|
||||
# IRIX: -mips2
|
||||
OPTIONS= -D__MINGW32__ # -D__EGCS__
|
||||
OPTIONS= # -D__MINGW32__ # -D__EGCS__
|
||||
|
||||
# Debugging information
|
||||
# AIX: comment out.
|
||||
# IRIX: -g3
|
||||
DEBUGFLAGS = -ggdb -D__DEBUG__ -DDEBUG=1
|
||||
DEBUGFLAGS = -ggdb -D__DEBUG__
|
||||
|
||||
# Debug/trace mode. 1 or more for debugging.
|
||||
DEBUG=0
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "menu.h"
|
||||
#pragma implementation "menuitem.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
@ -158,7 +159,7 @@ void wxMenu::Append(wxMenuItem *pItem)
|
||||
UINT id;
|
||||
wxMenu *SubMenu = pItem->GetSubMenu();
|
||||
if ( SubMenu != NULL ) {
|
||||
wxASSERT( SubMenu->m_hMenu != NULL );
|
||||
wxASSERT( SubMenu->m_hMenu != (WXHMENU) NULL );
|
||||
|
||||
id = (UINT)SubMenu->m_hMenu;
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
|
||||
#include <wx/defs.h>
|
||||
|
||||
#ifdef __WIN32__
|
||||
#if defined(__WIN32__) && !defined(__GNUWIN32__)
|
||||
|
||||
#include <wx/log.h>
|
||||
#include <wx/msw/ole/oleutils.h>
|
||||
|
@ -9,6 +9,10 @@
|
||||
// Licence: wxWindows license
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "regconf.h"
|
||||
#endif
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
@ -9,6 +9,10 @@
|
||||
// Licence: wxWindows license
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "statbr95.h"
|
||||
#endif
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
@ -10,7 +10,7 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "utils.h"
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
@ -134,10 +134,8 @@ long wxExecute(const wxString& command, bool sync, wxProcess *handler)
|
||||
*argp++ = '\0';
|
||||
|
||||
#ifdef __GNUWIN32__
|
||||
result = ShellExecute((HWND) (wxTheApp->GetTopWindow() ? (HWND) wxTheApp->GetT
|
||||
opWindow()->GetHWND() : NULL),
|
||||
(const wchar_t) "open", (const wchar_t) cl, (const wchar_t) arg
|
||||
p,i
|
||||
result = ShellExecute((HWND) (wxTheApp->GetTopWindow() ? (HWND) wxTheApp->GetTopWindow()->GetHWND() : NULL),
|
||||
(const wchar_t) "open", (const wchar_t) cl, (const wchar_t) argp,
|
||||
(const wchar_t) NULL, SW_SHOWNORMAL);
|
||||
#else
|
||||
result = ShellExecute( (HWND) (wxTheApp->GetTopWindow() ? wxTheApp->GetTopWindow()->GetHWND() : NULL),
|
||||
|
Loading…
Reference in New Issue
Block a user