Commit 555034cb authored by Claes Sjofors's avatar Claes Sjofors

Wb wb_load-file parser antlr replaced

parent 2e705e5e
......@@ -173151,9 +173151,9 @@ OA2 = A4 + (OA1 - 5) / 90 * (A3 - A4);"
! Curve defined by a table with x and y values.
!
! @image orm_compcurvetab_og.png
!
!
! CompCurveTabValue is used to interpolate a value from the curve.
!
!
! @b See also
! @classlink CompCurveTabValue basecomponent_compcurvetabvalue.html
! @classlink CompCurveTabValueFo basecomponent_compcurvetabvaluefo.html
......@@ -173283,10 +173283,10 @@ OA2 = A4 + (OA1 - 5) / 90 * (A3 - A4);"
!
! The curve is defined with a CompCurveTab object. This object is specified in
! the CurveTabObject attribute.
!
!
! @b Object graph
! @image orm_compcurvetabvalue_og.png
!
!
! @b Plc coding
! For plc coding the function object CompCurveTabValueFo is used.
! @image orm_compcurvetabvaluefo_fo.png
......@@ -173296,7 +173296,7 @@ OA2 = A4 + (OA1 - 5) / 90 * (A3 - A4);"
! @b See also
! @classlink CompCurveTabValueFo basecomponent_compcurvetabvaluefo.html
! @classlink CompCurveTab basecomponent_compcurvetab.html
!
!
!*/
Object CompCurveTabValue $ClassDef 206 25-JAN-2017 09:26:12.53
Body SysBody 25-JAN-2017 09:26:03.08
......@@ -173499,9 +173499,9 @@ OA2 = A4 + (OA1 - 5) / 90 * (A3 - A4);"
! Curve defined by a polynomial function.
!
! @image orm_compcurvepol_og.png
!
!
! CompCurvePolValue is used to calculate a value from the curve.
!
!
! @b See also
! @classlink CompCurvePolValue basecomponent_compcurvepolvalue.html
! @classlink CompCurvePolValueFo basecomponent_compcurvepolvaluefo.html
......@@ -173663,10 +173663,10 @@ OA2 = A4 + (OA1 - 5) / 90 * (A3 - A4);"
!
! The curve is defined with a CompCurvePol object. This object is specified in
! the CurvePolObject attribute.
!
!
! @b Object graph
! @image orm_compcurvepolvalue_og.png
!
!
! @b Plc coding
! For plc coding the function object CompCurvePolValueFo is used.
! @image orm_compcurvepolvaluefo_fo.png
......@@ -173676,7 +173676,7 @@ OA2 = A4 + (OA1 - 5) / 90 * (A3 - A4);"
! @b See also
! @classlink CompCurvePolValueFo basecomponent_compcurvepolvaluefo.html
! @classlink CompCurvePol basecomponent_compcurvepol.html
!
!
!*/
Object CompCurvePolValue $ClassDef 208 27-JAN-2017 13:49:10.74
Body SysBody 27-JAN-2017 13:47:05.12
......@@ -14,7 +14,6 @@ libdb5.3-dev (Any Berkeley DB version > 4.3, on Fedora db4-devel)
libdb5.3++-dev
libasound2-dev (on Fedora alsa-lib-devel)
doxygen
libantlr-dev (version 2.7.7)
jdk
......@@ -40,7 +39,6 @@ libasound2-dev
libdb5.1-dev
libdb5.1++-dev
doxygen
libantlr-dev
Optional:
......@@ -274,9 +272,6 @@ Install BerkeleyDB 4.8 (pkg_add -r db48)
Install jdk (cd /usr/port/java/jdk16; make install clean)
Download and build source package antlr-2.7.7 from www.antlr.org
Hint: define MAKE to gmake before configure and build (export MAKE=gmake).
Install doxygen (cd /usr/devel/doxygen; make install clean)
Continue to build Proview following the instructions in section 2 or 3 above.
......
......@@ -46,6 +46,7 @@ extern_java_sources := \
GlowEventMenu.java,\
GlowEventToolbar.java,\
GlowEventTable.java,\
GlowEventSignal.java,\
GrowCtxIfc.java,\
GrowCmn.java,\
GrowAnnotIfc.java,\
......
......@@ -363,7 +363,6 @@ else
echo "Mandatory :"
pwre_config_check_lib gtk GTK gtk gtk 0 "/usr/lib/libgtk-x11-2.0.dll.a"
pwre_config_check_lib libantlr LIBANTLR lib wb 0 "/usr/local/lib/libantlr.a"
pwre_config_check_lib librpcsvc LIBRPCSVC lib lib 0 "/usr/lib/libtirpc.a"
pwre_config_check_lib libasound LIBASOUND lib lib 0 "/usr/lib/libasound.so:/usr/lib/libasound.a"
pwre_config_check_lib libpthread LIBPTHREAD lib lib 0 "/usr/lib/libpthread.so:/usr/lib/libpthread.a:/usr/lib/$hwpl-linux-gnu/libpthread.so"
......@@ -377,7 +376,6 @@ else
pwre_config_check_lib libiconv LIBICONV lib lib 0 "/usr/lib/libiconv.dll.a:/usr/lib/libiconv.a"
pwre_config_check_lib libX11 LIBX11 lib lib 0 "/usr/lib/libX11.a"
pwre_config_check_include antlr ANTLR 1 "/usr/local/include/antlr/CommonAST.hpp"
pwre_config_check_include gtk GTK 1 "/usr/local/include/gtk-2.0/gtk.h:/usr/local/include/gtk-2.0/gtk/gtk.h:/usr/include/gtk-2.0/gtk"
pwre_config_check_include jni JNI 1 "$jdk/include/jni.h"
pwre_config_check_include jni JNI 0 "$jdk/include/win32/jni_md.h"
......
......@@ -279,7 +279,6 @@ fi
echo "Mandatory :"
pwre_config_check_lib gtk GTK gtk gtk 0 /usr/local/lib/libgtk-x11-2.0.a
pwre_config_check_lib libantlr LIBANTLR lib lib 0 /usr/local/lib/libantlr.a
pwre_config_check_lib librpcsvc LIBRPCSVC lib lib 0 /usr/lib/librpcsvc.so:/usr/lib/librpcsvc.a
#pwre_config_check_lib libasound LIBASOUND lib lib 0 /usr/lib/libasound.so:/usr/lib/libasound.a
pwre_config_check_lib libpthread LIBPTHREAD lib lib 0 /usr/lib/libpthread.so:/usr/lib/libpthread.a
......@@ -291,7 +290,6 @@ pwre_config_check_lib librt LIBRT lib lib 0 /usr/lib/librt.dylib:/usr/lib/
pwre_config_check_lib libiconv LIBICONV lib lib 0 /usr/local/lib/libiconv.so:usr/local/lib/libiconv.a
pwre_config_check_lib libfl LIBFL lib lib 0 /usr/lib/libfl.os:/usr/lib/libfl.a
pwre_config_check_include antlr ANTLR 1 /usr/local/include/antlr/CommonAST.hpp
pwre_config_check_include gtk GTK 1 /usr/local/include/gtk-2.0/gtk/gtk.h
pwre_config_check_include jni JNI 1 /usr/local/jdk1.6.0/include/jni.h
pwre_config_check_include jni JNI 0 /usr/local/jdk1.6.0/include/freebsd/jni_md.h
......
......@@ -303,7 +303,6 @@ else
hwpl=i386
fi
fi
echo "hwpl $hwpl"
# Bash
if [ "$SHELL" != "/bin/bash" ] && [ "$SHELL" != "/usr/local/bin/bash" ]; then
......@@ -458,7 +457,6 @@ else
echo "Mandatory :"
pwre_config_check_lib gtk GTK gtk gtk 0 "/usr/lib/libgtk-x11-2.0.so:/usr/lib/$hwpl-linux-$gnu/libgtk-x11-2.0.so"
pwre_config_check_lib libantlr LIBANTLR lib wb 0 "/usr/lib/libantlr.a:/usr/local/lib/libantlr.a"
pwre_config_check_lib librpcsvc LIBRPCSVC lib lib 0 "/usr/lib/librpcsvc.so:/usr/lib/librpcsvc.a:/usr/lib/$hwpl-linux-$gnu/librpcsvc.a"
pwre_config_check_lib libasound LIBASOUND lib lib 0 "/usr/lib/libasound.so:/usr/lib/libasound.a:/usr/lib/$hwpl-linux-$gnu/libasound.so"
pwre_config_check_lib libpthread LIBPTHREAD lib lib 0 "/usr/lib/libpthread.so:/usr/lib/libpthread.a:/usr/lib/$hwpl-linux-$gnu/libpthread.so"
......@@ -471,7 +469,6 @@ else
pwre_config_check_lib libfl LIBFL lib lib 0 "/usr/lib/libfl.so:/usr/lib/libfl.a:/usr/lib/$hwpl-linux-$gnu/libfl.so"
pwre_config_check_lib libX11 LIBX11 lib lib 0 "/usr/lib/libX11.so:/usr/lib/$hwpl-linux-$gnu/libX11.so"
pwre_config_check_include antlr ANTLR 1 "/usr/include/antlr/CommonAST.hpp:/usr/local/include/antlr/CommonAST.hpp"
pwre_config_check_include gtk GTK 1 "/usr/local/include/gtk-2.0/gtk.h:/usr/local/include/gtk-2.0/gtk/gtk.h:/usr/include/gtk-2.0/gtk/gtk.h"
pwre_config_check_include alsa ALSA 1 "/usr/include/alsa/asoundlib.h"
......
......@@ -278,7 +278,6 @@ fi
echo "Mandatory :"
pwre_config_check_lib gtk GTK gtk gtk 0 /sw/lib/libgtk-x11-2.0.dylib
pwre_config_check_lib libantlr LIBANTLR lib lib 0 /usr/local/lib/libantlr.a
pwre_config_check_lib librpcsvc LIBRPCSVC lib lib 0 /usr/lib/librpcsvc.dylib:/usr/lib/librpcsvc.a
#pwre_config_check_lib libasound LIBASOUND lib lib 0 /usr/lib/libasound.dylib:/usr/lib/libasound.a
pwre_config_check_lib libpthread LIBPTHREAD lib lib 0 /usr/lib/libpthread.dylib:/usr/lib/libpthread.a
......@@ -290,7 +289,6 @@ pwre_config_check_lib libz LIBZ lib lib 0 /usr/lib/libz.dylib:/usr/lib/
pwre_config_check_lib libiconv LIBICONV lib lib 0 /usr/lib/libiconv.dylib
pwre_config_check_lib libfl LIBFL lib lib 0 /usr/lib/libfl.dylib:/usr/lib/libfl.a
pwre_config_check_include antlr ANTLR 1 /usr/local/include/antlr/CommonAST.hpp
pwre_config_check_include gtk GTK 1 /sw/include/gtk-2.0/gtk/gtk.h
pwre_config_check_include jni JNI 1 /Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/JavaVM.framework/Versions/A/Headers/jni.h:$jdk/include/jni.h
pwre_config_check_include jni JNI 0 $jdk/include/linux/jni_md.h
......
......@@ -282,7 +282,6 @@ fi
echo "Mandatory :"
pwre_config_check_lib gtk GTK gtk gtk 0 /sw/lib/libgtk-x11-2.0.dylib
pwre_config_check_lib libantlr LIBANTLR lib lib 0 /usr/local/lib/libantlr.a
pwre_config_check_lib librpcsvc LIBRPCSVC lib lib 0 /usr/lib/librpcsvc.dylib:/usr/lib/librpcsvc.a
#pwre_config_check_lib libasound LIBASOUND lib lib 0 /usr/lib/libasound.dylib:/usr/lib/libasound.a
pwre_config_check_lib libpthread LIBPTHREAD lib lib 0 /usr/lib/libpthread.dylib:/usr/lib/libpthread.a
......@@ -294,7 +293,6 @@ pwre_config_check_lib libz LIBZ lib lib 0 c:/mingw/lib/libz.ddl.a
pwre_config_check_lib libiconv LIBICONV lib lib 0 c:/mingw/lib/libiconv.a
pwre_config_check_lib libfl LIBFL lib lib 0 c:/mingw/msys/1.0/lib/libfl.a
pwre_config_check_include antlr ANTLR 1 /usr/local/include/antlr/CommonAST.hpp
pwre_config_check_include gtk GTK 1 /sw/include/gtk-2.0/gtk/gtk.h
pwre_config_check_include jni JNI 1 /Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/JavaVM.framework/Versions/A/Headers/jni.h:$jdk/include/jni.h
pwre_config_check_include jni JNI 0 $jdk/include/linux/jni_md.h
......
......@@ -280,7 +280,6 @@ fi
echo "Mandatory :"
pwre_config_check_lib gtk GTK gtk gtk 0 /usr/local/lib/libgtk-x11-2.0.a
pwre_config_check_lib libantlr LIBANTLR lib lib 0 /usr/local/lib/libantlr.a
pwre_config_check_lib librpcsvc LIBRPCSVC lib lib 0 /usr/lib/librpcsvc.so:/usr/lib/librpcsvc.a
#pwre_config_check_lib libasound LIBASOUND lib lib 0 /usr/lib/libasound.so:/usr/lib/libasound.a
pwre_config_check_lib libpthread LIBPTHREAD lib lib 0 /usr/lib/libpthread.so:/usr/lib/libpthread.a
......@@ -292,7 +291,6 @@ pwre_config_check_lib libz LIBZ lib lib 0 /usr/lib/libz.so:/usr/lib/lib
pwre_config_check_lib libiconv LIBICONV lib lib 0 /usr/local/lib/libiconv.so:/usr/local/lib/libiconv.a
pwre_config_check_lib libfl LIBFL lib lib 0 /usr/lib/libfl.os:/usr/lib/libfl.a
pwre_config_check_include antlr ANTLR 1 /usr/local/include/antlr/CommonAST.hpp
pwre_config_check_include gtk GTK 1 /usr/local/include/gtk-2.0/gtk/gtk.h
pwre_config_check_include iconv ICONV 1 /usr/local/include/iconv.h
pwre_config_check_include jni JNI 1 /usr/local/jdk-1.7.0/include/jni.h
......
......@@ -231,7 +231,6 @@ pwre_config_init
#Gtk
pwre_config_check_lib gtk GTK gtk gtk 0 /usr/lib/libgtk-x11-2.0.so
pwre_config_check_lib libantlr LIBANTLR lib lib 0 /usr/local/lib/libantlr.a
pwre_config_check_lib librpcsvc LIBRPCSVC lib lib 0 /usr/lib/librpcsvc.so:/usr/lib/librpcsvc.a
pwre_config_check_lib libasound LIBASOUND lib lib 0 /usr/lib/libasound.so:usr/lib/libasound.a
pwre_config_check_lib libpthread LIBPTHREAD lib lib 0 /usr/lib/libpthread.so:usr/lib/libpthread.a
......@@ -248,7 +247,6 @@ pwre_config_check_lib libfl LIBFL lib lib 0 /usr/lib/libfl.so:usr/lib/libf
#set -o xtrace
pwre_config_check_include antlr ANTLR 1 /usr/local/include/antlr/CommonAST.hpp
pwre_config_check_include gtk GTK 1 /usr/local/include/gtk-2.0/gtk.h:/usr/local/include/gtk-2.0/gtk/gtk.h
pwre_config_check_include jni JNI 1 $jdk/include/jni.h
pwre_config_check_include jni JNI 0 $jdk/include/linux/jni_md.h
......
......@@ -37,9 +37,7 @@
#include <iostream>
#include <fstream>
#include <sys/stat.h>
#include "antlr/AST.hpp"
#include "wb_wbllexer.hpp"
#include "wb_wblparser.hpp"
#include "wb_wbl_parser.h"
#include "wb_wblnode.h"
#include "wb_vrepwbl.h"
......@@ -62,7 +60,6 @@ wb_vrepwbl::~wb_vrepwbl()
{
for ( int i = 0; i < file_cnt; i++) {
delete file[i]->parser;
delete file[i]->lexer;
delete file[i];
}
......@@ -264,7 +261,6 @@ int wb_vrepwbl::load( const char *fname)
int file_cnt_sort = 0;
rsts = LDH__SUCCESS;
wblparser_error_cnt = 0;
MsgWindow::dset_nodraw();
......@@ -312,7 +308,7 @@ int wb_vrepwbl::load( const char *fname)
wbl_sort_files);
for ( i = 0; i < file_cnt; i++) {
for ( ref_wblnode n = file[i]->rootAST; n; n = n->getNextSibling())
for ( ref_wblnode n = (ref_wblnode)file[i]->rootAST; n; n = (ref_wblnode)n->getNextSibling())
n->registerNode( this);
}
for ( i = 0; i < file_cnt; i++) {
......@@ -337,10 +333,10 @@ int wb_vrepwbl::load( const char *fname)
error_cnt++;
}
if ( error_cnt || wblparser_error_cnt) {
if ( error_cnt) {
char str[80];
sprintf( str, "Errors when loading volume: %d error%s found",
error_cnt + wblparser_error_cnt, (error_cnt + wblparser_error_cnt == 1) ? "" : "s");
error_cnt, (error_cnt == 1) ? "" : "s");
MsgWindow::message( 'F', str);
}
else
......@@ -1364,6 +1360,7 @@ int wb_vrepwbl::load_files( const char *file_spec)
{
char found_file[200];
int sts;
wb_wbl_parser p;
sts = dcli_search_file( (char *)file_spec, found_file, DCLI_DIR_SEARCH_INIT);
while( ODD(sts)) {
......@@ -1379,23 +1376,11 @@ int wb_vrepwbl::load_files( const char *file_spec)
return LDH__MAXWBLFILES;
file[file_cnt] = new wb_wblfile();
file[file_cnt]->lexer = new wb_wbllexer(s);
file[file_cnt]->lexer->setFilename( found_file);
file[file_cnt]->parser = new wb_wblparser(*file[file_cnt]->lexer);
file[file_cnt]->parser->setFilename( found_file);
// Antlr 2.7.3 seems to want an ASTFactory here...
ASTFactory wblfactory("ref_wblnode", wb_wblnode::factory);
file[file_cnt]->parser->initializeASTFactory( wblfactory);
file[file_cnt]->parser->setASTNodeFactory( &wblfactory);
// file[file_cnt]->parser->setASTNodeFactory( wb_wblnode::factory);
file[file_cnt]->parser = new wb_wbl_parser();
try {
// Parse the input expression
file[file_cnt]->parser->unit();
AST *a = file[file_cnt]->parser->getAST();
file[file_cnt]->rootAST = (wb_wblnode *) a;
file[file_cnt]->parser->parse( found_file);
file[file_cnt]->rootAST = (ref_wblnode)file[file_cnt]->parser->get_root_ast();
if ( !file[file_cnt]->rootAST) {
error("File empty", found_file, 0);
file_cnt--;
......@@ -1412,16 +1397,9 @@ int wb_vrepwbl::load_files( const char *file_spec)
file[file_cnt]->rootAST->setFile( file[file_cnt]);
}
}
catch(exception& e) {
cout << "exception: " << e.what() << " " << found_file << " line: " <<
file[file_cnt]->lexer->getLine() << endl;
error_cnt++;
return LDH__WBLPARSE;
}
catch(ANTLRException& e) {
cout << "E Wbl parse error: " << " " << found_file << " line: " <<
file[file_cnt]->lexer->getLine() << endl;
cout << "F Wbl terminated" << endl;
catch(wb_error_str& e) {
cout << "Exception: " << e.what() << " " << found_file << " line: " <<
file[file_cnt]->parser->get_line() << endl;
error_cnt++;
return LDH__WBLPARSE;
}
......@@ -1747,7 +1725,6 @@ bool wb_vrepwbl::renameObject(pwr_tStatus *sts, wb_orep *orep, wb_name &name)
wb_wblnode *n = ((wb_orepwbl *) orep)->wblNode();
string sname( name.object());
n->setText( sname);
n->setText( name.object());
return true;
}
......@@ -41,9 +41,7 @@
#include "co_depend.h"
#include "wb_vrep.h"
#include "antlr/AST.hpp"
#include "wb_wbllexer.hpp"
#include "wb_wblparser.hpp"
#include "wb_wbl_parser.h"
#include "wb_wblnode.h"
#include "wb_wblfile.h"
#include "wb_erep.h"
......
This diff is collapsed.
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2017 SSAB EMEA AB.
*
* This file is part of Proview.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
**/
#ifndef wb_wbl_parser_h
#define wb_wbl_parser_h
#include <stdlib.h>
#include <string.h>
#include "wb_error.h"
typedef enum {
wbl_mState_InDocBlock = 1 << 0,
wbl_mState_InVolume = 1 << 1,
wbl_mState_InSObject = 1 << 2,
wbl_mState_InObject = 1 << 3,
wbl_mState_InBody = 1 << 4,
wbl_mState_InBuffer = 1 << 5
} wbl_mState;
typedef enum {
wbl_eToken_DocBlock,
wbl_eToken_Volume,
wbl_eToken_SObject,
wbl_eToken_Object,
wbl_eToken_Body,
wbl_eToken_Attr,
wbl_eToken_Name,
wbl_eToken_Value,
wbl_eToken_Index,
wbl_eToken_String,
wbl_eToken_Char,
wbl_eToken_Operator,
wbl_eToken_Operator_eq,
wbl_eToken_Operator_oreq,
wbl_eToken_Date,
wbl_eToken_Buffer
} wbl_eToken;
class wbl_ast_node {
public:
wbl_ast_node() : size(0), line_number(0), fws(0), fch(0), lch(0), fth(0), text(0) {}
~wbl_ast_node() {
if ( text) free( text);
wbl_ast_node *next;
for ( wbl_ast_node *n = fch; n;) {
next = n->fws;
delete n;
n = next;
}
}
void setType( int type) { token = type;}
unsigned int getType() { return token;}
char *getText() { return text;}
void setText( char *t) {
free( text);
text = (char *)malloc( strlen(t)+1);
strcpy( text, t);
}
//wbl_ast_node *getFirstChild() { return fch;}
//wbl_ast_node *getNextSibling() { return fws;}
int token;
int size;
unsigned int line_number;
wbl_ast_node *fws;
wbl_ast_node *fch;
wbl_ast_node *lch;
wbl_ast_node *fth;
char *text;
};
class wb_wbl_parser {
public:
wb_wbl_parser();
~wb_wbl_parser();
void parse( const char *filename);
void print();
void print_node( wbl_ast_node *n, int level);
void print_error( wb_error_str& e);
wbl_ast_node *new_ast_node( wbl_eToken token, char *text, unsigned int len,
unsigned int line, int allocated);
int next_token( ifstream& is, char *line, const char *start_delim,
const char *end_delim, wbl_eToken type, char **start,
unsigned int *len, int *allocated);
int read_docblock( ifstream& is, char *line,
char **start, unsigned int *len);
void ast_node_insert_lch( wbl_ast_node *fth, wbl_ast_node *n);
wbl_ast_node *get_root_ast() { return m_tree;}
unsigned int get_line() { return m_line_cnt;}
void print_line();
int check_operator( wbl_ast_node *n);
private:
pwr_tFileName m_fname;
unsigned int m_line_cnt;
unsigned int m_state;
wbl_ast_node *m_tree;
wbl_ast_node *m_current;
int m_object_level;
int m_buffer_level;
};
#endif
......@@ -43,14 +43,12 @@
// #include "wb_wbllexer.hpp"
// #include "wb_wblparser.hpp"
class wb_wblparser;
class wb_wbllexer;
class wb_wbl_parser;
class wb_wblnode;
class wb_wblfile {
public:
wb_wbllexer *lexer;
wb_wblparser *parser;
wb_wbl_parser *parser;
wb_wblnode *rootAST;
char file_name[200];
pwr_tTime time;
......
This diff is collapsed.
......@@ -38,16 +38,12 @@
#define wb_wblnode_h
#include <iostream>
#include "antlr/CommonAST.hpp"
#include "antlr/ASTFactory.hpp"
#include "pwr.h"
#include "wb_name.h"
#include "wb_wbl_parser.h"
#include "wb_wblfile.h"
ANTLR_USING_NAMESPACE(std)
ANTLR_USING_NAMESPACE(antlr)
class wb_wblnode;
class wb_vrepwbl;
class wb_vrep;
......@@ -70,7 +66,7 @@ typedef enum {
wbl_eNodeType_Code
} wbl_eNodeType;
typedef antlr::ASTRefCount<wb_wblnode> ref_wblnode;
typedef wb_wblnode *ref_wblnode;
typedef struct {
const char *sym;
......@@ -142,6 +138,7 @@ class wbl_object {
if ( rbody_size) free( rbody);
if ( dbody_size) free( dbody);
}
size_t rbody_size;
size_t dbody_size;
void *rbody;
......@@ -169,22 +166,15 @@ class wbl_object {
};
class wb_wblnode : public CommonAST {
class wb_wblnode : public wbl_ast_node {
friend class wb_vrepwbl;
public:
wb_wblnode() :
node_type(wbl_eNodeType_No),
line_number(0), file(0), o(0)
{
}
wb_wblnode(antlr::RefToken t) :
node_type(wbl_eNodeType_No),
line_number(0), file(0), o(0)
file(0), o(0)
{
CommonAST::setType(t->getType());
CommonAST::setText(t->getText());
}
~wb_wblnode()
{
......@@ -192,69 +182,33 @@ public:
delete o;
}
void initialize(int t, const std::string& txt)
{
CommonAST::setType(t);
CommonAST::setText(txt);
}
void initialize( ref_wblnode t)
{
CommonAST::setType(t->getType());
CommonAST::setText(t->getText());
}
void initialize( RefAST t )
{
CommonAST::initialize(t);
}
void initialize( antlr::RefToken t);
void setText(const std::string& txt)
{
CommonAST::setText(txt);
}
void setType(int type)
{
CommonAST::setType(type);
}
void addChild( ref_wblnode c )
{
BaseAST::addChild( RefAST(c));
}
static antlr::RefAST factory( void )
{
antlr::RefAST ret = RefAST(new wb_wblnode);
return ret;
}
ref_wblnode getFirstChild()
{
return ref_wblnode(BaseAST::getFirstChild());
}
ref_wblnode getNextSibling()
{
return ref_wblnode(BaseAST::getNextSibling());
}
// Heterogeneous part
void info( int level) {
for ( int i = 0; i < level; i++)
cout << " ";
cout << getType() << " " << getText() << endl;
ref_wblnode t = getFirstChild();
wb_wblnode *t = (wb_wblnode *)getFirstChild();
if ( t)
t->info( level + 1);
t = getNextSibling();
t = (wb_wblnode *)getNextSibling();
if ( t)
t->info( level);
}
wb_wblnode *getFirstChild() { return (wb_wblnode *)fch;}
wb_wblnode *getNextSibling() { return (wb_wblnode *)fws;}
void setNextSibling( wb_wblnode *n) {
n->fws = fws;
fws = n;
if ( fth->lch == this)
fth->lch = n;
}
void setFirstChild( wb_wblnode *c) {
if ( fch)
c->fws = fch;
else
lch = c;
fch = c;
}
bool isType() { return (node_type == wbl_eNodeType_Type);}
bool isTypeDef() { return (node_type == wbl_eNodeType_TypeDef);}
bool isClassDef() { return (node_type == wbl_eNodeType_ClassDef);}
......@@ -308,12 +262,11 @@ public:
static int lookup( int *type, const char *keyword, wbl_sSym *table);
static int convconst( int *val, char *str);
const char *name() { return getText().c_str();}
const char *name() { return getText();}
bool docBlock( char **block, int *size) const;
wbl_eNodeType node_type;
wb_vrepwbl *m_vrep;
int line_number;
wb_wblfile *file;
wbl_object *o;
......
This diff is collapsed.
/*
* Make sure to run antlr.Tool on the lexer.g file first!
*/
header {
#include "wb_wblnode.h"
}
header "post_include_hpp" {
extern int wblparser_error_cnt;
# This_declarations_should_be_moved_inside_parser_class_in_wb_wblparser_hpp_!!
void reportError(const RecognitionException& ex);
}
header "post_include_cpp" {
#include "co_msgwindow.h"
int wblparser_error_cnt = 0;
void wb_wblparser::reportError(const RecognitionException& ex)
{
MsgWindow::message( 'E', ex.toString().c_str());
wblparser_error_cnt++;
ANTLR_USE_NAMESPACE(std)cerr << ex.toString().c_str() << ANTLR_USE_NAMESPACE(std)endl;
}
}
options {
mangleLiteralPrefix = "t_";
language="Cpp";
}
class wb_wblparser extends Parser;
options {
importVocab=wb_wblvocab; // use vocab generated by lexer
buildAST=true;
ASTLabelType="ref_wblnode";
}
unit
: (volume | sobject | object)+
;
volume
: VOLUME^ cid OID (body)* ((DOCBLOCK)? object)* ENDVOLUME
;
sobject
: SOBJECT^ ((DOCBLOCK)? object)* ENDSOBJECT
;
object
: OBJECT^ cid (oix)? (ASC_TIME)? (body)* ((DOCBLOCK)? object)* ENDOBJECT
;
body
: BODY^ (ASC_TIME)? (attribute)* ENDBODY
;
attribute
: ATTRIBUTE^ (EQ | OREQ) value
| BUFFER^ (INDEX)? (attribute)* ENDBUFFER
;
cid
: VALUE
| STRING_LITERAL
;
oix
: VALUE
| INT
;
value
: VALUE
| STRING_LITERAL
| NUM_FLOAT
| INT
;
oname
: VALUE
;
#ifndef INC_wb_wblparser_hpp_
#define INC_wb_wblparser_hpp_
#include <antlr/config.hpp>
/* $ANTLR 2.7.6 (20060211): "wb_wblparser.g" -> "wb_wblparser.hpp"$ */
#include <antlr/TokenStream.hpp>
#include <antlr/TokenBuffer.hpp>
#include "wb_wblparserTokenTypes.hpp"
#include <antlr/LLkParser.hpp>
#line 8 "wb_wblparser.g"
extern int wblparser_error_cnt;
#line 19 "wb_wblparser.hpp"
#line 4 "wb_wblparser.g"
#include "wb_wblnode.h"
#line 24 "wb_wblparser.hpp"
class CUSTOM_API wb_wblparser : public ANTLR_USE_NAMESPACE(antlr)LLkParser, public wb_wblparserTokenTypes
{
void reportError(const RecognitionException& ex);
#line 1 "wb_wblparser.g"
#line 28 "wb_wblparser.hpp"
public:
void initializeASTFactory( ANTLR_USE_NAMESPACE(antlr)ASTFactory& factory );
protected:
wb_wblparser(ANTLR_USE_NAMESPACE(antlr)TokenBuffer& tokenBuf, int k);
public:
wb_wblparser(ANTLR_USE_NAMESPACE(antlr)TokenBuffer& tokenBuf);
protected:
wb_wblparser(ANTLR_USE_NAMESPACE(antlr)TokenStream& lexer, int k);
public:
wb_wblparser(ANTLR_USE_NAMESPACE(antlr)TokenStream& lexer);
wb_wblparser(const ANTLR_USE_NAMESPACE(antlr)ParserSharedInputState& state);
int getNumTokens() const
{
return wb_wblparser::NUM_TOKENS;
}
const char* getTokenName( int type ) const
{
if( type > getNumTokens() ) return 0;
return wb_wblparser::tokenNames[type];
}
const char* const* getTokenNames() const
{
return wb_wblparser::tokenNames;
}
public: void unit();
public: void volume();
public: void sobject();
public: void object();
public: void cid();
public: void body();
public: void oix();
public: void attribute();
public: void value();
public: void oname();
public:
ANTLR_USE_NAMESPACE(antlr)RefAST getAST()
{
return ANTLR_USE_NAMESPACE(antlr)RefAST(returnAST);
}
protected:
ref_wblnode returnAST;
private:
static const char* tokenNames[];
#ifndef NO_STATIC_CONSTS
static const int NUM_TOKENS = 36;
#else
enum {
NUM_TOKENS = 36
};
#endif
static const unsigned long _tokenSet_0_data_[];
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_0;
static const unsigned long _tokenSet_1_data_[];
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_1;
static const unsigned long _tokenSet_2_data_[];
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_2;
static const unsigned long _tokenSet_3_data_[];
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_3;
static const unsigned long _tokenSet_4_data_[];
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_4;
static const unsigned long _tokenSet_5_data_[];
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_5;
static const unsigned long _tokenSet_6_data_[];
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_6;
};
#endif /*INC_wb_wblparser_hpp_*/
#ifndef INC_wb_wblparserTokenTypes_hpp_
#define INC_wb_wblparserTokenTypes_hpp_
/* $ANTLR 2.7.6 (20060211): "wb_wblparser.g" -> "wb_wblparserTokenTypes.hpp"$ */
#ifndef CUSTOM_API
# define CUSTOM_API
#endif
#ifdef __cplusplus
struct CUSTOM_API wb_wblparserTokenTypes {
#endif
enum {
EOF_ = 1,
OBJECT = 4,
ENDOBJECT = 5,
VOLUME = 6,
ENDVOLUME = 7,
SOBJECT = 8,
ENDSOBJECT = 9,
BODY = 10,
ENDBODY = 11,
ATTRIBUTE = 12,
BUFFER = 13,
ENDBUFFER = 14,
DOBJECT = 15,
ENDDOBJECT = 16,
DBUFFER = 17,
ENDDBUFFER = 18,
DATTRIBUTE = 19,
NUM_FLOAT = 20,
INT = 21,
OID = 22,
DOCBLOCK = 23,
ASC_TIME = 24,
EQ = 25,
OREQ = 26,
WS = 27,
COMMENT = 28,
INDEX = 29,
VALUE = 30,
CHAR_LITERAL = 31,
STRING_LITERAL = 32,
DIGITS = 33,
ESC = 34,
SWEC = 35,
NULL_TREE_LOOKAHEAD = 3
};
#ifdef __cplusplus
};
#endif
#endif /*INC_wb_wblparserTokenTypes_hpp_*/
// $ANTLR 2.7.6 (20060211): wb_wblparser.g -> wb_wblparserTokenTypes.txt$
wb_wblparser // output token vocab name
OBJECT=4
ENDOBJECT=5
VOLUME=6
ENDVOLUME=7
SOBJECT=8
ENDSOBJECT=9
BODY=10
ENDBODY=11
ATTRIBUTE=12
BUFFER=13
ENDBUFFER=14
DOBJECT=15
ENDDOBJECT=16
DBUFFER=17
ENDDBUFFER=18
DATTRIBUTE=19
NUM_FLOAT=20
INT=21
OID=22
DOCBLOCK=23
ASC_TIME=24
EQ=25
OREQ=26
WS=27
COMMENT=28
INDEX("an index")=29
VALUE("an identifer")=30
CHAR_LITERAL=31
STRING_LITERAL=32
DIGITS=33
ESC=34
SWEC=35
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment