Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Esteban Blanc
proview
Commits
555034cb
Commit
555034cb
authored
Feb 10, 2017
by
Claes Sjofors
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Wb wb_load-file parser antlr replaced
parent
2e705e5e
Changes
22
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
842 additions
and
1216 deletions
+842
-1216
bcomp/wbl/bcomp/src/basecomponent.wb_load
bcomp/wbl/bcomp/src/basecomponent.wb_load
+10
-10
build-howto.info
build-howto.info
+0
-5
java/aapp/jopg/src/os_templ/hw_templ/makefile
java/aapp/jopg/src/os_templ/hw_templ/makefile
+1
-0
src/tools/pwre/src/os_cygwin/pwre_configure.sh
src/tools/pwre/src/os_cygwin/pwre_configure.sh
+0
-2
src/tools/pwre/src/os_freebsd/pwre_configure.sh
src/tools/pwre/src/os_freebsd/pwre_configure.sh
+0
-2
src/tools/pwre/src/os_linux/pwre_configure.sh
src/tools/pwre/src/os_linux/pwre_configure.sh
+0
-3
src/tools/pwre/src/os_macos/pwre_configure.sh
src/tools/pwre/src/os_macos/pwre_configure.sh
+0
-2
src/tools/pwre/src/os_mingw/pwre_configure.sh
src/tools/pwre/src/os_mingw/pwre_configure.sh
+0
-2
src/tools/pwre/src/os_openbsd/pwre_configure.sh
src/tools/pwre/src/os_openbsd/pwre_configure.sh
+0
-2
src/tools/pwre/src/os_templ/pwre_configure.sh
src/tools/pwre/src/os_templ/pwre_configure.sh
+0
-2
wb/lib/wb/src/wb_vrepwbl.cpp
wb/lib/wb/src/wb_vrepwbl.cpp
+12
-35
wb/lib/wb/src/wb_vrepwbl.h
wb/lib/wb/src/wb_vrepwbl.h
+1
-3
wb/lib/wb/src/wb_wbl_parser.cpp
wb/lib/wb/src/wb_wbl_parser.cpp
+583
-0
wb/lib/wb/src/wb_wbl_parser.h
wb/lib/wb/src/wb_wbl_parser.h
+140
-0
wb/lib/wb/src/wb_wblfile.h
wb/lib/wb/src/wb_wblfile.h
+2
-4
wb/lib/wb/src/wb_wblnode.cpp
wb/lib/wb/src/wb_wblnode.cpp
+70
-81
wb/lib/wb/src/wb_wblnode.h
wb/lib/wb/src/wb_wblnode.h
+23
-70
wb/lib/wb/src/wb_wblparser.cpp
wb/lib/wb/src/wb_wblparser.cpp
+0
-718
wb/lib/wb/src/wb_wblparser.g
wb/lib/wb/src/wb_wblparser.g
+0
-94
wb/lib/wb/src/wb_wblparser.hpp
wb/lib/wb/src/wb_wblparser.hpp
+0
-95
wb/lib/wb/src/wb_wblparserTokenTypes.hpp
wb/lib/wb/src/wb_wblparserTokenTypes.hpp
+0
-52
wb/lib/wb/src/wb_wblparserTokenTypes.txt
wb/lib/wb/src/wb_wblparserTokenTypes.txt
+0
-34
No files found.
bcomp/wbl/bcomp/src/basecomponent.wb_load
View file @
555034cb
...
...
@@ -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
build-howto.info
View file @
555034cb
...
...
@@ -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.
...
...
java/aapp/jopg/src/os_templ/hw_templ/makefile
View file @
555034cb
...
...
@@ -46,6 +46,7 @@ extern_java_sources := \
GlowEventMenu.java,
\
GlowEventToolbar.java,
\
GlowEventTable.java,
\
GlowEventSignal.java,
\
GrowCtxIfc.java,
\
GrowCmn.java,
\
GrowAnnotIfc.java,
\
...
...
src/tools/pwre/src/os_cygwin/pwre_configure.sh
View file @
555034cb
...
...
@@ -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"
...
...
src/tools/pwre/src/os_freebsd/pwre_configure.sh
View file @
555034cb
...
...
@@ -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
...
...
src/tools/pwre/src/os_linux/pwre_configure.sh
View file @
555034cb
...
...
@@ -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"
...
...
src/tools/pwre/src/os_macos/pwre_configure.sh
View file @
555034cb
...
...
@@ -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
...
...
src/tools/pwre/src/os_mingw/pwre_configure.sh
View file @
555034cb
...
...
@@ -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
...
...
src/tools/pwre/src/os_openbsd/pwre_configure.sh
View file @
555034cb
...
...
@@ -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
...
...
src/tools/pwre/src/os_templ/pwre_configure.sh
View file @
555034cb
...
...
@@ -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
...
...
wb/lib/wb/src/wb_vrepwbl.cpp
View file @
555034cb
...
...
@@ -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
;
}
wb/lib/wb/src/wb_vrepwbl.h
View file @
555034cb
...
...
@@ -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"
...
...
wb/lib/wb/src/wb_wbl_parser.cpp
0 → 100644
View file @
555034cb
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <string.h>
#include "pwr.h"
#include "co_dcli.h"
#include "wb_error.h"
#include "wb_wbl_parser.h"
#include "wb_wblnode.h"
using
namespace
std
;
#define WS " "
#define WSEOL "$ "
typedef
enum
{
eState_StartDelim
,
eState_StartDelimFound
,
eState_InToken
,
eState_EndDelimFound
}
eState
;
#if 0
int main()
{
wb_wbl_parser p;
try {
// p.parse( "/home/claes/test/pwrb_c_and.wb_load");
p.parse( "/home/claes/test/directory.wb_load");
}
catch ( wb_error_str e) {
p.print_error( e);
}
p.print();
}
#endif
wb_wbl_parser
::
wb_wbl_parser
()
:
m_line_cnt
(
0
),
m_state
(
0
),
m_tree
(
0
),
m_current
(
0
),
m_object_level
(
0
),
m_buffer_level
(
0
)
{
}
wb_wbl_parser
::~
wb_wbl_parser
()
{
if
(
m_tree
)
delete
m_tree
;
}
void
wb_wbl_parser
::
print_error
(
wb_error_str
&
e
)
{
cout
<<
"** Error "
<<
m_fname
<<
" line "
<<
m_line_cnt
<<
", "
<<
e
.
what
()
<<
endl
;
}
void
wb_wbl_parser
::
print
()
{
printf
(
"Parsing file %s
\n
"
,
m_fname
);
print_node
(
m_tree
,
0
);
}
void
wb_wbl_parser
::
print_node
(
wbl_ast_node
*
n
,
int
level
)
{
wbl_ast_node
*
nc
;
for
(
int
i
=
0
;
i
<
level
;
i
++
)
printf
(
" "
);
printf
(
"%d %s
\n
"
,
n
->
token
,
n
->
text
);
for
(
nc
=
n
->
fch
;
nc
;
nc
=
nc
->
fws
)
{
print_node
(
nc
,
level
+
1
);
}
}
//
// Return 1 if token is found, 0 if no more token is found.
//
int
wb_wbl_parser
::
next_token
(
ifstream
&
is
,
char
*
line
,
const
char
*
start_delim
,
const
char
*
end_delim
,
wbl_eToken
type
,
char
**
start
,
unsigned
int
*
len
,
int
*
allocated
)
{
char
*
s
,
*
token
;
const
char
*
d
;
int
state
=
eState_StartDelim
;
bool
in_string
=
false
;
for
(
s
=
line
;
*
s
;
s
++
)
{
if
(
in_string
)
{
if
(
*
s
==
'\"'
&&
*
(
s
-
1
)
!=
'\\'
)
in_string
=
false
;
else
continue
;
}
switch
(
state
)
{
case
eState_StartDelim
:
for
(
d
=
start_delim
;
*
d
;
d
++
)
{
if
(
*
s
==
*
d
)
{
state
=
eState_StartDelimFound
;
break
;
}
}
if
(
state
!=
eState_StartDelimFound
)
throw
wb_error_str
(
"Unexpected end of token"
);
break
;
case
eState_StartDelimFound
:
{
bool
found
=
false
;
for
(
d
=
start_delim
;
*
d
;
d
++
)
{
if
(
*
s
==
*
d
)
{
found
=
true
;
break
;
}
}
if
(
!
found
)
{
state
=
eState_InToken
;
token
=
s
;
if
(
*
s
==
'\"'
)
in_string
=
true
;
}
break
;
}
case
eState_InToken
:
for
(
d
=
end_delim
;
*
d
;
d
++
)
{
if
(
*
s
==
*
d
)
{
if
(
type
==
wbl_eToken_Date
&&
*
s
==
' '
&&
(
s
-
token
)
<
14
)
{
// Space in date is Ok
}
else
{
state
=
eState_EndDelimFound
;
break
;
}
}
}
break
;
}
if
(
state
==
eState_EndDelimFound
)
break
;
}
if
(
*
s
==
0
&&
state
==
eState_InToken
)
{
for
(
d
=
end_delim
;
*
d
;
d
++
)
{
if
(
*
d
==
'$'
)
{
state
=
eState_EndDelimFound
;
break
;
}
}
}
if
(
state
==
eState_StartDelim
||
state
==
eState_StartDelimFound
)
return
0
;
if
(
state
!=
eState_EndDelimFound
)
throw
wb_error_str
(
"Syntax error"
);
*
allocated
=
0
;
if
(
in_string
)
{
// Find end of string on next lines
bool
found
=
false
;
char
c
,
cold
;
// Get size of string
streampos
fend
,
fstart
=
is
.
tellg
();
cold
=
0
;
while
(
is
.
get
(
c
))
{
if
(
c
==
'\"'
&&
cold
!=
'\\'
)
{
fend
=
is
.
tellg
();
found
=
true
;
break
;
}
cold
=
c
;
}
if
(
!
found
)
throw
wb_error_str
(
"Unterminated string"
);
int
size
=
s
-
token
+
(
fend
-
fstart
)
+
1
;
char
*
tp
=
(
char
*
)
malloc
(
size
+
1
);
if
(
!
tp
)
throw
wb_error_str
(
"Out of memory"
);
strncpy
(
tp
,
token
,
s
-
token
);
tp
[
s
-
token
]
=
'\n'
;
is
.
seekg
(
fstart
);
m_line_cnt
++
;
cold
=
0
;
int
i
=
s
-
token
+
1
;
while
(
is
.
get
(
c
))
{
tp
[
i
]
=
c
;
i
++
;
if
(
c
==
'\"'
&&
cold
!=
'\\'
)
break
;
if
(
c
==
'\n'
)
m_line_cnt
++
;
cold
=
c
;
}
tp
[
size
]
=
0
;
// Read to end of line
while
(
is
.
get
(
c
))
{
if
(
c
==
'\n'
)
break
;
}
// m_line_cnt++;
*
allocated
=
1
;
*
start
=
tp
;
*
len
=
size
;
}
else
{
*
start
=
token
;
*
len
=
s
-
token
;
}
return
1
;
}
int
wb_wbl_parser
::
read_docblock
(
ifstream
&
is
,
char
*
line
,
char
**
start
,
unsigned
int
*
len
)
{
bool
found
=
false
;
char
c
,
c1
,
c2
;
streampos
fend
,
fstart
=
is
.
tellg
();
// Get size of docblock
c1
=
c2
=
0
;
while
(
is
.
get
(
c
))
{
if
(
c
==
'/'
&&
c1
==
'*'
&&
c2
==
'!'
)
{
fend
=
is
.
tellg
();
found
=
true
;
break
;
}
c2
=
c1
;
c1
=
c
;
}
if
(
!
found
)
throw
wb_error_str
(
"Unterminated documentation block"
);
int
line_len
=
strlen
(
line
);
int
size
=
line_len
+
(
fend
-
fstart
);
char
*
tp
=
(
char
*
)
malloc
(
size
+
2
);
strncpy
(
tp
,
line
,
line_len
);
tp
[
line_len
]
=
'\n'
;
is
.
seekg
(
fstart
);
m_line_cnt
++
;
c1
=
c2
=
0
;
int
i
=
line_len
+
1
;
while
(
is
.
get
(
c
))
{
tp
[
i
]
=
c
;
i
++
;
if
(
c
==
'/'
&&
c1
==
'*'
&&
c2
==
'!'
)
{
m_state
&=
~
wbl_mState_InDocBlock
;
break
;
}
if
(
c
==
'\n'
)
m_line_cnt
++
;
c2
=
c1
;
c1
=
c
;
}
tp
[
size
+
1
]
=
0
;
// printf( "Docblock: %s\n", tp);
// Read to end of line
while
(
is
.
get
(
c
))
{
if
(
c
==
'\n'
)
break
;
}
m_line_cnt
++
;
*
start
=
tp
;
*
len
=
size
;
return
1
;
}
void
wb_wbl_parser
::
ast_node_insert_lch
(
wbl_ast_node
*
fth
,
wbl_ast_node
*
n
)
{
if
(
!
fth
->
fch
)
{
fth
->
fch
=
n
;
fth
->
lch
=
n
;
n
->
fth
=
fth
;
}
else
{
fth
->
lch
->
fws
=
n
;
fth
->
lch
=
n
;
n
->
fth
=
fth
;
}
}
wbl_ast_node
*
wb_wbl_parser
::
new_ast_node
(
wbl_eToken
token
,
char
*
text
,
unsigned
int
len
,
unsigned
int
line
,
int
allocated
)
{
wbl_ast_node
*
n
=
(
wbl_ast_node
*
)
new
wb_wblnode
();
if
(
!
n
)
throw
wb_error_str
(
"Out of memory"
);
if
(
allocated
)
n
->
text
=
text
;
else
{
n
->
text
=
(
char
*
)
malloc
(
len
+
1
);
if
(
!
n
->
text
)
throw
wb_error_str
(
"Out of memory"
);
n
->
token
=
token
;
strncpy
(
n
->
text
,
text
,
len
);
n
->
text
[
len
]
=
0
;
}
n
->
size
=
len
;
n
->
token
=
token
;
n
->
line_number
=
line
;
return
n
;
}
void
wb_wbl_parser
::
print_line
()
{
printf
(
"-- Processing line: %d
\r
"
,
m_line_cnt
);
fflush
(
stdout
);
}
int
wb_wbl_parser
::
check_operator
(
wbl_ast_node
*
n
)
{
if
(
strcmp
(
n
->
text
,
"="
)
==
0
)
{
n
->
token
=
wbl_eToken_Operator_eq
;
return
1
;
}
else
if
(
strcmp
(
n
->
text
,
"|="
)
==
0
)
{
n
->
token
=
wbl_eToken_Operator_oreq
;
return
1
;
}
return
0
;
}
void
wb_wbl_parser
::
parse
(
const
char
*
filename
)
{
char
line
[
400
];
char
*
token
;
unsigned
int
len
;
wbl_ast_node
*
t1
,
*
t2
,
*
t3
,
*
t4
;
int
sts
;
int
alloc
;
static
unsigned
int
last
=
0
;
dcli_translate_filename
(
m_fname
,
filename
);
ifstream
is
(
m_fname
);
if
(
!
is
)
throw
wb_error_str
(
"No such file"
);
while
(
is
.
getline
(
line
,
sizeof
(
line
)))
{
m_line_cnt
++
;
if
(
(
m_line_cnt
%
1000
)
==
0
&&
m_line_cnt
!=
last
)
{
print_line
();
last
=
m_line_cnt
;
}
dcli_trim
(
line
,
line
);
if
(
strcmp
(
line
,
""
)
==
0
)
continue
;
if
(
strncmp
(
line
,
"!/**"
,
4
)
==
0
)
{
if
(
m_state
&
wbl_mState_InDocBlock
)
throw
wb_error_str
(
"Already in documentation block"
);
m_state
|=
wbl_mState_InDocBlock
;
read_docblock
(
is
,
line
,
&
token
,
&
len
);
t1
=
new_ast_node
(
wbl_eToken_DocBlock
,
token
,
len
,
m_line_cnt
,
1
);
ast_node_insert_lch
(
m_current
,
t1
);
}
else
if
(
line
[
0
]
==
'!'
)
{
// Comment
continue
;
}
else
if
(
strncmp
(
line
,
"Volume"
,
6
)
==
0
)
{
if
(
m_state
&
wbl_mState_InVolume
)
throw
wb_error_str
(
"Volume already defined"
);
if
(
m_tree
)
throw
wb_error_str
(
"Volume is not first"
);
m_state
|=
wbl_mState_InVolume
;
sts
=
next_token
(
is
,
&
line
[
6
],
WS
,
WS
,
wbl_eToken_Volume
,
&
token
,
&
len
,
&
alloc
);
if
(
!
sts
)
throw
wb_error_str
(
"Volume name is missing"
);
t1
=
new_ast_node
(
wbl_eToken_Volume
,
token
,
len
,
m_line_cnt
,
0
);
m_tree
=
t1
;
m_current
=
t1
;
// Volume class
sts
=
next_token
(
is
,
token
+
len
,
WS
,
WS
,
wbl_eToken_Name
,
&
token
,
&
len
,
&
alloc
);
if
(
!
sts
)
throw
wb_error_str
(
"Volume class is missing"
);
t2
=
new_ast_node
(
wbl_eToken_Name
,
token
,
len
,
m_line_cnt
,
0
);
ast_node_insert_lch
(
m_current
,
t2
);
// Volumeid
sts
=
next_token
(
is
,
token
+
len
,
WS
,
WSEOL
,
wbl_eToken_Index
,
&
token
,
&
len
,
&
alloc
);
if
(
!
sts
)
throw
wb_error_str
(
"Volume id is missing"
);
t3
=
new_ast_node
(
wbl_eToken_Index
,
token
,
len
,
m_line_cnt
,
0
);
ast_node_insert_lch
(
m_current
,
t3
);
}
else
if
(
strncmp
(
line
,
"EndVolume"
,
9
)
==
0
)
{
if
(
!
(
m_state
&
wbl_mState_InVolume
))
throw
wb_error_str
(
"Volume - EndVolume mismatch"
);
if
(
m_state
&
wbl_mState_InBody
)
throw
wb_error_str
(
"Body not terminated"
);
if
(
m_state
&
wbl_mState_InObject
)
throw
wb_error_str
(
"Body not terminated"
);
m_state
&=
~
wbl_mState_InVolume
;
}
else
if
(
strncmp
(
line
,
"SObject"
,
7
)
==
0
)
{
if
(
m_state
&
wbl_mState_InSObject
)
throw
wb_error_str
(
"SObject already defined"
);
m_state
|=
wbl_mState_InSObject
;
// SObject name
next_token
(
is
,
&
line
[
7
],
WS
,
WSEOL
,
wbl_eToken_Name
,
&
token
,
&
len
,
&
alloc
);
t1
=
new_ast_node
(
wbl_eToken_SObject
,
token
,
len
,
m_line_cnt
,
0
);
if
(
!
m_tree
)
{
m_tree
=
t1
;
m_current
=
t1
;
}
else
{
// Insert as last sibling to m_tree
wbl_ast_node
*
n
;
for
(
n
=
m_tree
;
n
->
fws
;
n
=
n
->
fws
)
;
n
->
fws
=
t1
;
m_current
=
t1
;
}
}
else
if
(
strncmp
(
line
,
"EndSObject"
,
10
)
==
0
)
{
if
(
!
(
m_state
&
wbl_mState_InSObject
))
throw
wb_error_str
(
"SObject - EndSObject mismatch"
);
if
(
m_state
&
wbl_mState_InBody
)
throw
wb_error_str
(
"Body not terminated"
);
if
(
m_state
&
wbl_mState_InObject
)
throw
wb_error_str
(
"Object not terminated"
);
if
(
m_state
&
wbl_mState_InBuffer
)
throw
wb_error_str
(
"Buffer not terminated"
);
m_state
&=
~
wbl_mState_InSObject
;
}
else
if
(
strncmp
(
line
,
"Object"
,
6
)
==
0
)
{
if
(
!
(
m_state
&
wbl_mState_InVolume
||
m_state
&
wbl_mState_InSObject
))
throw
wb_error_str
(
"Object defined outside volume"
);
m_object_level
++
;
m_state
|=
wbl_mState_InObject
;
// Object name
sts
=
next_token
(
is
,
&
line
[
6
],
WS
,
WS
,
wbl_eToken_Name
,
&
token
,
&
len
,
&
alloc
);
if
(
!
sts
)
throw
wb_error_str
(
"Object syntax error"
);
t1
=
new_ast_node
(
wbl_eToken_Object
,
token
,
len
,
m_line_cnt
,
0
);
ast_node_insert_lch
(
m_current
,
t1
);
m_current
=
t1
;
// Object class
sts
=
next_token
(
is
,
token
+
len
,
WS
,
WSEOL
,
wbl_eToken_Name
,
&
token
,
&
len
,
&
alloc
);
if
(
sts
)
{
t2
=
new_ast_node
(
wbl_eToken_Name
,
token
,
len
,
m_line_cnt
,
0
);
ast_node_insert_lch
(
m_current
,
t2
);
}
// Object identity
sts
=
next_token
(
is
,
token
+
len
,
WS
,
WSEOL
,
wbl_eToken_Index
,
&
token
,
&
len
,
&
alloc
);
if
(
sts
)
{
t3
=
new_ast_node
(
wbl_eToken_Index
,
token
,
len
,
m_line_cnt
,
0
);
ast_node_insert_lch
(
m_current
,
t3
);
}
// Object time
sts
=
next_token
(
is
,
token
+
len
,
WS
,
WSEOL
,
wbl_eToken_Date
,
&
token
,
&
len
,
&
alloc
);
if
(
sts
)
{
t4
=
new_ast_node
(
wbl_eToken_Date
,
token
,
len
,
m_line_cnt
,
0
);
ast_node_insert_lch
(
m_current
,
t4
);
}
}
else
if
(
strncmp
(
line
,
"EndObject"
,
9
)
==
0
)
{
if
(
!
(
m_state
&
wbl_mState_InObject
))
throw
wb_error_str
(
"Object - EndObject mismatch"
);
if
(
m_state
&
wbl_mState_InBody
)
throw
wb_error_str
(
"Body not terminated"
);
if
(
m_state
&
wbl_mState_InBuffer
)
throw
wb_error_str
(
"Buffer not terminated"
);
if
(
m_object_level
<=
0
)
throw
wb_error_str
(
"Object - EndObject mismatch"
);
m_object_level
--
;
if
(
m_object_level
==
0
)
m_state
&=
~
wbl_mState_InObject
;
m_current
=
m_current
->
fth
;
}
else
if
(
strncmp
(
line
,
"Body"
,
4
)
==
0
)
{
if
(
m_state
&
wbl_mState_InBody
)
throw
wb_error_str
(
"Body already defined"
);
if
(
!
(
m_state
&
wbl_mState_InVolume
||
m_state
&
wbl_mState_InObject
))
throw
wb_error_str
(
"Body defined outside object"
);
m_state
|=
wbl_mState_InBody
;
// Body name
sts
=
next_token
(
is
,
&
line
[
4
],
WS
,
WSEOL
,
wbl_eToken_Name
,
&
token
,
&
len
,
&
alloc
);
if
(
!
sts
)
throw
wb_error_str
(
"Body syntax error"
);
t1
=
new_ast_node
(
wbl_eToken_Body
,
token
,
len
,
m_line_cnt
,
0
);
ast_node_insert_lch
(
m_current
,
t1
);
m_current
=
t1
;
// Body time
sts
=
next_token
(
is
,
token
+
len
,
WS
,
WSEOL
,
wbl_eToken_Date
,
&
token
,
&
len
,
&
alloc
);
if
(
sts
)
{
t2
=
new_ast_node
(
wbl_eToken_Date
,
token
,
len
,
m_line_cnt
,
0
);
ast_node_insert_lch
(
m_current
,
t2
);
}
}
else
if
(
strncmp
(
line
,
"EndBody"
,
7
)
==
0
)
{
if
(
!
(
m_state
&
wbl_mState_InBody
))
throw
wb_error_str
(
"Body - EndBody mismatch"
);
m_state
&=
~
wbl_mState_InBody
;
m_current
=
m_current
->
fth
;
}
else
if
(
strncmp
(
line
,
"Buffer"
,
6
)
==
0
)
{
if
(
!
(
m_state
&
wbl_mState_InBody
))
throw
wb_error_str
(
"Attr defined outside body"
);
if
(
!
(
m_state
&
wbl_mState_InVolume
||
m_state
&
wbl_mState_InObject
))
throw
wb_error_str
(
"Buffer defined outside object"
);
m_buffer_level
++
;
m_state
|=
wbl_mState_InBuffer
;
// Buffer name
sts
=
next_token
(
is
,
&
line
[
6
],
WS
,
WSEOL
,
wbl_eToken_Name
,
&
token
,
&
len
,
&
alloc
);
if
(
!
sts
)
throw
wb_error_str
(
"Buffer syntax error"
);
t1
=
new_ast_node
(
wbl_eToken_Buffer
,
token
,
len
,
m_line_cnt
,
0
);
ast_node_insert_lch
(
m_current
,
t1
);
m_current
=
t1
;
// Buffer time
sts
=
next_token
(
is
,
token
+
len
,
WS
,
WSEOL
,
wbl_eToken_Date
,
&
token
,
&
len
,
&
alloc
);
if
(
sts
)
{
t2
=
new_ast_node
(
wbl_eToken_Date
,
token
,
len
,
m_line_cnt
,
0
);
ast_node_insert_lch
(
m_current
,
t2
);
}
}
else
if
(
strncmp
(
line
,
"EndBuffer"
,
9
)
==
0
)
{
if
(
!
(
m_state
&
wbl_mState_InBuffer
))
throw
wb_error_str
(
"Buffer - EndBuffer mismatch"
);
m_buffer_level
--
;
if
(
m_buffer_level
==
0
)
m_state
&=
~
wbl_mState_InBuffer
;
m_current
=
m_current
->
fth
;
}
else
if
(
strncmp
(
line
,
"Attr"
,
4
)
==
0
)
{
if
(
!
(
m_state
&
wbl_mState_InBody
))
throw
wb_error_str
(
"Attr defined outside body"
);
// Attr name
sts
=
next_token
(
is
,
&
line
[
4
],
WS
,
WS
,
wbl_eToken_Name
,
&
token
,
&
len
,
&
alloc
);
if
(
!
sts
)
throw
wb_error_str
(
"Attr syntax error"
);
t1
=
new_ast_node
(
wbl_eToken_Attr
,
token
,
len
,
m_line_cnt
,
0
);
ast_node_insert_lch
(
m_current
,
t1
);
m_current
=
t1
;
// Attr operator
sts
=
next_token
(
is
,
token
+
len
,
WS
,
WS
,
wbl_eToken_Operator
,
&
token
,
&
len
,
&
alloc
);
if
(
!
sts
)
throw
wb_error_str
(
"Attr syntax error"
);
t2
=
new_ast_node
(
wbl_eToken_Operator
,
token
,
len
,
m_line_cnt
,
0
);
if
(
!
check_operator
(
t2
))
throw
wb_error_str
(
"Undefined operator"
);
ast_node_insert_lch
(
m_current
,
t2
);
// Attr value
sts
=
next_token
(
is
,
token
+
len
,
WS
"="
,
WSEOL
,
wbl_eToken_Value
,
&
token
,
&
len
,
&
alloc
);
if
(
!
sts
)
throw
wb_error_str
(
"Attr syntax error"
);
t2
=
new_ast_node
(
wbl_eToken_Value
,
token
,
len
,
m_line_cnt
,
alloc
);
ast_node_insert_lch
(
m_current
,
t2
);
m_current
=
m_current
->
fth
;
}
else
{
// Syntax error
throw
wb_error_str
(
"Undefined token"
);
}
}
print_line
();
}
wb/lib/wb/src/wb_wbl_parser.h
0 → 100644
View file @
555034cb
/*
* 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
wb/lib/wb/src/wb_wblfile.h
View file @
555034cb
...
...
@@ -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
;
...
...
wb/lib/wb/src/wb_wblnode.cpp
View file @
555034cb
...
...
@@ -45,13 +45,10 @@
#include "wb_orepwbl.h"
#include "wb_merep.h"
#include "wb_cdrep.h"
#include "wb_wblvocabTokenTypes.hpp"
#include "wb_dbs.h"
#include "wb_name.h"
#include "wb_treeimport.h"
struct
wb_wblvocabTokenTypes
tokens
;
/* Datatypes */
static
wbl_sSym
datatypes
[]
=
{
...
...
@@ -354,9 +351,9 @@ static wbl_sSym attr_flags[] =
static
int
check_conversion_error
(
const
char
*
attr
);
void
wb_wblnode
::
initialize
(
antlr
::
RefToken
t
)
#if 0
void wb_wblnode::initialize()
{
CommonAST
::
initialize
(
t
);
line_number = t->getLine();
// Test
...
...
@@ -367,6 +364,7 @@ void wb_wblnode::initialize( antlr::RefToken t )
last = line_number;
}
}
#endif
int
wb_wblnode
::
classNameToCid
(
char
*
class_name
,
pwr_tCid
*
cid
)
{
...
...
@@ -449,7 +447,7 @@ int wb_wblnode::convconst( int *val, char *str)
ref_wblnode
wb_wblnode
::
find
(
wb_name
*
oname
,
int
level
)
{
if
(
getType
()
==
tokens
.
OBJECT
)
{
if
(
getType
()
==
wbl_eToken_Object
)
{
if
(
oname
->
segmentIsEqual
(
name
(),
level
))
{
if
(
!
oname
->
hasSegment
(
level
+
1
))
return
this
;
...
...
@@ -464,7 +462,7 @@ ref_wblnode wb_wblnode::find( wb_name *oname, int level)
return
0
;
}
if
((
getType
()
==
tokens
.
VOLUME
)
||
(
getType
()
==
tokens
.
OBJECT
))
{
if
((
getType
()
==
wbl_eToken_Volume
)
||
(
getType
()
==
wbl_eToken_Object
))
{
if
(
oname
->
volumeIsEqual
(
name
())
&&
!
oname
->
hasSegment
(
0
))
return
this
;
else
if
(
o
->
fch
)
...
...
@@ -1138,7 +1136,7 @@ void wb_wblnode::buildBody( ref_wblnode object)
ref_wblnode
first_child
;
ref_wblnode
next_sibling
;
if
(
getType
()
==
tokens
.
BODY
)
{
if
(
getType
()
==
wbl_eToken_Body
)
{
if
(
cdh_NoCaseStrcmp
(
name
(),
"SysBody"
)
==
0
)
bix
=
pwr_eBix_sys
;
else
if
(
cdh_NoCaseStrcmp
(
name
(),
"RtBody"
)
==
0
)
...
...
@@ -1153,10 +1151,9 @@ void wb_wblnode::buildBody( ref_wblnode object)
first_child
=
getFirstChild
();
// First child might be body time
if
(
first_child
&&
first_child
->
getType
()
==
tokens
.
ASC_TIME
)
{
string
timestr
=
first_child
->
getText
();
if
(
first_child
&&
first_child
->
getType
()
==
wbl_eToken_Date
)
{
pwr_tTime
bodytime
;
if
(
stringToTime
(
timestr
.
c_str
(),
&
bodytime
))
{
if
(
stringToTime
(
first_child
->
getText
(),
&
bodytime
))
{
if
(
bix
==
pwr_eBix_rt
)
object
->
o
->
m_rbtime
=
bodytime
;
else
...
...
@@ -1186,7 +1183,6 @@ void wb_wblnode::buildAttr( ref_wblnode object, pwr_eBix bix)
{
ref_wblnode
first_child
;
ref_wblnode
second_child
;
ref_wblnode
next_sibling
;
int
oper
;
char
value
[
8192
];
size_t
size
,
offset
;
...
...
@@ -1198,7 +1194,7 @@ void wb_wblnode::buildAttr( ref_wblnode object, pwr_eBix bix)
int
int_val
,
current_int_val
;
bool
string_continue
=
false
;
if
(
getType
()
==
tokens
.
ATTRIBUTE
)
{
if
(
getType
()
==
wbl_eToken_Attr
)
{
first_child
=
getFirstChild
();
if
(
!
first_child
)
{
// Attr exception
...
...
@@ -1207,7 +1203,7 @@ void wb_wblnode::buildAttr( ref_wblnode object, pwr_eBix bix)
}
oper
=
first_child
->
getType
();
if
(
(
oper
!=
tokens
.
OREQ
)
&&
(
oper
!=
tokens
.
EQ
))
{
if
(
!
(
oper
==
wbl_eToken_Operator_eq
||
oper
==
wbl_eToken_Operator_oreq
))
{
// Attr exception
m_vrep
->
error
(
"Attribute value required"
,
getFileName
(),
line_number
);
goto
error_continue
;
...
...
@@ -1262,7 +1258,7 @@ void wb_wblnode::buildAttr( ref_wblnode object, pwr_eBix bix)
// printf( "Attr %s %s %d %d %s\n", object->name, name, size, offset, value);
if
(
size
==
sizeof
(
int_val
)
&&
convconst
(
&
int_val
,
value
))
{
if
(
oper
==
tokens
.
EQ
)
{
if
(
oper
==
wbl_eToken_Operator_eq
)
{
if
(
bix
==
pwr_eBix_rt
||
bix
==
pwr_eBix_sys
)
memcpy
(
(
char
*
)((
unsigned
long
)
object
->
o
->
rbody
+
offset
),
&
int_val
,
size
);
...
...
@@ -1270,7 +1266,7 @@ void wb_wblnode::buildAttr( ref_wblnode object, pwr_eBix bix)
memcpy
(
(
char
*
)((
unsigned
long
)
object
->
o
->
dbody
+
offset
),
&
int_val
,
size
);
}
else
if
(
oper
==
tokens
.
OREQ
)
{
else
if
(
oper
==
wbl_eToken_Operator_oreq
)
{
if
(
bix
==
pwr_eBix_rt
||
bix
==
pwr_eBix_sys
)
{
current_int_val
=
*
(
int
*
)
((
unsigned
long
)
object
->
o
->
rbody
+
offset
);
int_val
|=
current_int_val
;
...
...
@@ -1311,7 +1307,7 @@ error_continue:
;
}
else
if
(
getType
()
==
tokens
.
BUFFER
)
else
if
(
getType
()
==
wbl_eToken_Buffer
)
{
buildBuff
(
object
,
bix
,
0
,
0
,
0
);
}
...
...
@@ -1325,6 +1321,7 @@ void wb_wblnode::buildBuff( ref_wblnode object, pwr_eBix bix, pwr_tCid buffer_ci
pwr_tStatus
sts
;
pwr_tCid
host_cid
;
pwr_tCid
cid
;
wb_attrname
aname
=
wb_attrname
(
name
());
if
(
buffer_cid
!=
0
)
{
// Buffer in buffer... Fix
...
...
@@ -1333,6 +1330,7 @@ void wb_wblnode::buildBuff( ref_wblnode object, pwr_eBix bix, pwr_tCid buffer_ci
else
host_cid
=
object
->
o
->
m_cid
;
if
(
cdh_CidToVid
(
host_cid
)
==
m_vrep
->
vid
())
{
pwr_tTypeId
tid
;
pwr_eType
type
;
...
...
@@ -1348,7 +1346,6 @@ void wb_wblnode::buildBuff( ref_wblnode object, pwr_eBix bix, pwr_tCid buffer_ci
m_vrep
->
error
(
"Unknown class of buffer owner"
,
getFileName
(),
line_number
);
return
;
}
wb_attrname
aname
=
wb_attrname
(
name
());
wb_adrep
*
adrep
=
cdrep
->
adrep
(
&
sts
,
aname
.
attribute
());
if
(
EVEN
(
sts
))
{
m_vrep
->
error
(
"Unknown Buffer"
,
getFileName
(),
line_number
);
...
...
@@ -1363,8 +1360,13 @@ void wb_wblnode::buildBuff( ref_wblnode object, pwr_eBix bix, pwr_tCid buffer_ci
delete
cdrep
;
delete
adrep
;
}
if
(
aname
.
hasAttrIndex
(
0
))
{
size
=
size
/
elements
;
offset
+=
aname
.
attrIndex
(
0
)
*
size
;
}
first_child
=
getFirstChild
();
if
(
first_child
&&
first_child
->
getType
()
==
tokens
.
INDEX
)
{
#if 0
if ( first_child && first_child->getType() == wbl_eToken_Index) {
int index;
int nr = sscanf( first_child->name(), "%d", &index);
if ( nr != 1) {
...
...
@@ -1378,6 +1380,7 @@ void wb_wblnode::buildBuff( ref_wblnode object, pwr_eBix bix, pwr_tCid buffer_ci
size = size / elements;
offset += index * size;
}
#endif
if
(
buffer_cid
!=
0
)
offset
+=
buffer_offset
;
...
...
@@ -1404,7 +1407,7 @@ void wb_wblnode::buildBuffAttr( ref_wblnode object, pwr_eBix bix, pwr_tCid buffe
wb_adrep
*
adrep
;
wb_attrname
aname
;
if
(
getType
()
==
tokens
.
ATTRIBUTE
)
if
(
getType
()
==
wbl_eToken_Attr
)
{
first_child
=
getFirstChild
();
if
(
!
first_child
)
{
...
...
@@ -1414,7 +1417,7 @@ void wb_wblnode::buildBuffAttr( ref_wblnode object, pwr_eBix bix, pwr_tCid buffe
}
oper
=
first_child
->
getType
();
if
(
(
oper
!=
tokens
.
OREQ
)
&&
(
oper
!=
tokens
.
EQ
))
{
if
(
!
(
oper
==
wbl_eToken_Operator_eq
||
oper
==
wbl_eToken_Operator_oreq
))
{
// Attr exception
m_vrep
->
error
(
"Attribute value required"
,
getFileName
(),
line_number
);
goto
error_continue
;
...
...
@@ -1533,7 +1536,7 @@ void wb_wblnode::buildBuffAttr( ref_wblnode object, pwr_eBix bix, pwr_tCid buffe
// printf( "Attr %s %s %d %d %s\n", object->name, name, size, offset, value);
if
(
size
/
elements
==
sizeof
(
int_val
)
&&
convconst
(
&
int_val
,
value
))
{
if
(
oper
==
tokens
.
EQ
)
{
if
(
oper
==
wbl_eToken_Operator_eq
)
{
if
(
bix
==
pwr_eBix_rt
||
bix
==
pwr_eBix_sys
)
memcpy
(
(
char
*
)((
unsigned
long
)
object
->
o
->
rbody
+
offset
),
&
int_val
,
size
/
elements
);
...
...
@@ -1541,7 +1544,7 @@ void wb_wblnode::buildBuffAttr( ref_wblnode object, pwr_eBix bix, pwr_tCid buffe
memcpy
(
(
char
*
)((
unsigned
long
)
object
->
o
->
dbody
+
offset
),
&
int_val
,
size
/
elements
);
}
else
if
(
oper
==
tokens
.
OREQ
)
{
else
if
(
oper
==
wbl_eToken_Operator_oreq
)
{
if
(
bix
==
pwr_eBix_rt
||
bix
==
pwr_eBix_sys
)
{
current_int_val
=
*
(
int
*
)
((
unsigned
long
)
object
->
o
->
rbody
+
offset
);
int_val
|=
current_int_val
;
...
...
@@ -1572,7 +1575,7 @@ void wb_wblnode::buildBuffAttr( ref_wblnode object, pwr_eBix bix, pwr_tCid buffe
error_continue:
;
}
else
if
(
getType
()
==
tokens
.
BUFFER
)
else
if
(
getType
()
==
wbl_eToken_Buffer
)
{
buildBuff
(
object
,
bix
,
buffer_cid
,
buffer_offset
,
buffer_size
);
}
...
...
@@ -1587,7 +1590,7 @@ void wb_wblnode::link( wb_vrepwbl *vol, ref_wblnode father, ref_wblnode parent_a
ref_wblnode
first_child
;
ref_wblnode
next_sibling
;
if
((
getType
()
==
tokens
.
OBJECT
)
||
(
getType
()
==
tokens
.
VOLUME
))
{
if
((
getType
()
==
wbl_eToken_Object
)
||
(
getType
()
==
wbl_eToken_Volume
))
{
if
(
!
father
)
{
// Volume root
vol
->
root_object
=
this
;
...
...
@@ -1619,12 +1622,12 @@ void wb_wblnode::link( wb_vrepwbl *vol, ref_wblnode father, ref_wblnode parent_a
prev
=
child
;
child
=
child
->
getNextSibling
();
}
if
(
prev
&&
prev
->
getType
()
==
tokens
.
DOCBLOCK
)
if
(
prev
&&
prev
->
getType
()
==
wbl_eToken_DocBlock
)
o
->
docblock
=
prev
;
}
// cout << "Linking " << name << endl;
}
else
if
(
getType
()
==
tokens
.
SOBJECT
)
else
if
(
getType
()
==
wbl_eToken_SObject
)
{
ref_wblnode
snode
=
m_vrep
->
find
(
name
());
if
(
!
snode
)
{
...
...
@@ -1655,10 +1658,10 @@ void wb_wblnode::registerNode( wb_vrepwbl *vol)
ref_wblnode
first_child
=
getFirstChild
();
m_vrep
=
vol
;
if
(
getType
()
==
tokens
.
DOCBLOCK
)
{
if
(
getType
()
==
wbl_eToken_DocBlock
)
{
string
txt
=
getText
();
}
else
if
(
getType
()
==
tokens
.
OBJECT
)
else
if
(
getType
()
==
wbl_eToken_Object
)
{
if
(
!
o
)
...
...
@@ -1673,8 +1676,7 @@ void wb_wblnode::registerNode( wb_vrepwbl *vol)
// Get class
if
(
first_child
)
{
string
class_name
=
first_child
->
getText
();
strcpy
(
o
->
cname
,
class_name
.
c_str
());
strcpy
(
o
->
cname
,
first_child
->
getText
());
if
(
!
classNameToCid
(
o
->
cname
,
&
o
->
m_cid
))
{
o
->
m_cid
=
0
;
...
...
@@ -1683,27 +1685,27 @@ void wb_wblnode::registerNode( wb_vrepwbl *vol)
// If $ClassDef, register class in classlist
if
(
!
isTemplate
())
{
if
(
first_child
->
getType
()
==
tokens
.
VALUE
&&
if
(
first_child
->
getType
()
==
wbl_eToken_Name
&&
(
strcmp
(
o
->
cname
,
"$ClassDef"
)
==
0
||
strcmp
(
o
->
cname
,
"pwr_eClass_ClassDef"
)
==
0
))
{
node_type
=
wbl_eNodeType_ClassDef
;
}
else
if
(
first_child
->
getType
()
==
tokens
.
VALUE
&&
else
if
(
first_child
->
getType
()
==
wbl_eToken_Name
&&
(
strcmp
(
o
->
cname
,
"$Type"
)
==
0
||
strcmp
(
o
->
cname
,
"pwr_eClass_Type"
)
==
0
))
{
node_type
=
wbl_eNodeType_Type
;
}
else
if
(
first_child
->
getType
()
==
tokens
.
VALUE
&&
else
if
(
first_child
->
getType
()
==
wbl_eToken_Name
&&
(
strcmp
(
o
->
cname
,
"$TypeDef"
)
==
0
||
strcmp
(
o
->
cname
,
"pwr_eClass_TypeDef"
)
==
0
))
{
node_type
=
wbl_eNodeType_TypeDef
;
}
else
if
(
first_child
->
getType
()
==
tokens
.
VALUE
&&
else
if
(
first_child
->
getType
()
==
wbl_eToken_Name
&&
(
strcmp
(
o
->
cname
,
"$ObjBodyDef"
)
==
0
||
strcmp
(
o
->
cname
,
"pwr_eClass_ObjBodyDef"
)
==
0
))
{
node_type
=
wbl_eNodeType_ObjBodyDef
;
}
else
if
(
first_child
->
getType
()
==
tokens
.
VALUE
&&
else
if
(
first_child
->
getType
()
==
wbl_eToken_Name
&&
(
strcmp
(
o
->
cname
,
"$Attribute"
)
==
0
||
strcmp
(
o
->
cname
,
"$Input"
)
==
0
||
strcmp
(
o
->
cname
,
"$Output"
)
==
0
||
...
...
@@ -1713,11 +1715,11 @@ void wb_wblnode::registerNode( wb_vrepwbl *vol)
strcmp
(
o
->
cname
,
"pwr_eClass_Param"
)
==
0
))
{
node_type
=
wbl_eNodeType_Attribute
;
}
else
if
(
first_child
->
getType
()
==
tokens
.
VALUE
&&
else
if
(
first_child
->
getType
()
==
wbl_eToken_Name
&&
(
strcmp
(
o
->
cname
,
"$Buffer"
)
==
0
))
{
node_type
=
wbl_eNodeType_Buffer
;
}
else
if
(
first_child
->
getType
()
==
tokens
.
VALUE
&&
else
if
(
first_child
->
getType
()
==
wbl_eToken_Name
&&
(
strcmp
(
o
->
cname
,
"$Param"
)
==
0
))
{
m_vrep
->
error
(
"Obsolete attribute class, use $Attribute instead"
,
getFileName
(),
line_number
);
...
...
@@ -1729,26 +1731,21 @@ void wb_wblnode::registerNode( wb_vrepwbl *vol)
if
(
second_child
)
{
ref_wblnode
third_child
=
second_child
->
getNextSibling
();
if
((
second_child
->
getType
()
==
tokens
.
VALUE
)
||
(
second_child
->
getType
()
==
tokens
.
INT
))
{
string
oixstr
=
second_child
->
getText
();
if
(
!
stringToOix
(
oixstr
.
c_str
(),
&
o
->
m_oid
.
oix
)
||
m_vrep
->
m_ignore_oix
)
{
if
(
second_child
->
getType
()
==
wbl_eToken_Index
)
{
if
(
!
stringToOix
(
second_child
->
getText
(),
&
o
->
m_oid
.
oix
)
||
m_vrep
->
m_ignore_oix
)
{
o
->
m_oid
.
oix
=
m_vrep
->
nextOix
();
}
if
(
third_child
&&
third_child
->
getType
()
==
tokens
.
ASC_TIME
)
{
string
timestr
=
third_child
->
getText
();
if
(
!
stringToTime
(
timestr
.
c_str
(),
&
o
->
m_ohtime
))
if
(
third_child
&&
third_child
->
getType
()
==
wbl_eToken_Date
)
{
if
(
!
stringToTime
(
third_child
->
getText
(),
&
o
->
m_ohtime
))
m_vrep
->
error
(
"Time syntax"
,
getFileName
(),
line_number
);
}
}
else
if
(
second_child
->
getType
()
==
tokens
.
ASC_TIME
)
{
string
timestr
=
second_child
->
getText
();
if
(
!
stringToTime
(
timestr
.
c_str
(),
&
o
->
m_ohtime
))
else
if
(
second_child
->
getType
()
==
wbl_eToken_Date
)
{
if
(
!
stringToTime
(
second_child
->
getText
(),
&
o
->
m_ohtime
))
m_vrep
->
error
(
"Time syntax"
,
getFileName
(),
line_number
);
}
else
if
((
second_child
->
getType
()
==
tokens
.
ENDOBJECT
)
||
(
second_child
->
getType
()
==
tokens
.
OBJECT
)
||
(
second_child
->
getType
()
==
tokens
.
BODY
))
{
else
if
((
second_child
->
getType
()
==
wbl_eToken_Object
)
||
(
second_child
->
getType
()
==
wbl_eToken_Body
))
{
o
->
m_oid
.
oix
=
m_vrep
->
nextOix
();
}
else
{
...
...
@@ -1783,11 +1780,9 @@ void wb_wblnode::registerNode( wb_vrepwbl *vol)
// Find Template object
ref_wblnode
child
=
first_child
;
ref_wblnode
last_child
=
child
;
string
childname
;
while
(
child
)
{
if
(
child
->
getType
()
==
tokens
.
OBJECT
)
{
childname
=
child
->
getText
();
if
(
strcmp
(
childname
.
c_str
(),
"Template"
)
==
0
)
{
if
(
child
->
getType
()
==
wbl_eToken_Object
)
{
if
(
strcmp
(
child
->
getText
(),
"Template"
)
==
0
)
{
ref_wblnode
fc
=
child
->
getFirstChild
();
if
(
fc
->
getText
()
==
name
())
{
o
->
c
.
templ
=
child
;
...
...
@@ -1800,11 +1795,10 @@ void wb_wblnode::registerNode( wb_vrepwbl *vol)
strcpy
(
o
->
c
.
templ
->
o
->
cname
,
name
());
o
->
c
.
templ
->
o
->
m_cid
=
o
->
c
.
cid
;
o
->
c
.
templ
->
node_type
=
wbl_eNodeType_Template
;
string
cname
(
name
());
fc
->
setText
(
cname
);
fc
->
setText
((
char
*
)
name
());
}
}
else
if
(
strcmp
(
child
name
.
c_str
(),
"Code"
)
==
0
)
{
else
if
(
strcmp
(
child
->
getText
(),
"Code"
)
==
0
)
{
o
->
c
.
code
=
child
;
o
->
c
.
code
->
node_type
=
wbl_eNodeType_Code
;
}
...
...
@@ -1818,13 +1812,12 @@ void wb_wblnode::registerNode( wb_vrepwbl *vol)
wb_wblnode
*
templ
=
new
wb_wblnode
();
// ref_wblnode reftempl(templ);
o
->
c
.
templ
=
templ
;
o
->
c
.
templ
->
setType
(
tokens
.
OBJECT
);
string
tname
(
"Template"
);
o
->
c
.
templ
->
setText
(
tname
);
o
->
c
.
templ
->
setType
(
wbl_eToken_Object
);
o
->
c
.
templ
->
setText
(
(
char
*
)
"Template"
);
if
(
last_child
)
last_child
->
setNextSibling
(
(
RefAST
)
o
->
c
.
templ
);
last_child
->
setNextSibling
(
o
->
c
.
templ
);
else
setFirstChild
(
(
RefAST
)
o
->
c
.
templ
);
setFirstChild
(
o
->
c
.
templ
);
o
->
c
.
templ
->
o
=
new
wbl_object
();
strcpy
(
o
->
c
.
templ
->
o
->
cname
,
name
());
// o->c.templ->o->m_oid.oix = m_vrep->nextOix();
...
...
@@ -1847,7 +1840,7 @@ void wb_wblnode::registerNode( wb_vrepwbl *vol)
m_vrep
->
error
(
"Bad body index"
,
getFileName
(),
line_number
);
}
}
else
if
(
getType
()
==
tokens
.
VOLUME
)
else
if
(
getType
()
==
wbl_eToken_Volume
)
{
pwr_tVid
vid
;
int
sts
;
...
...
@@ -1856,8 +1849,7 @@ void wb_wblnode::registerNode( wb_vrepwbl *vol)
// Get class
if
(
first_child
)
{
string
class_name
=
first_child
->
getText
();
strcpy
(
o
->
cname
,
class_name
.
c_str
());
strcpy
(
o
->
cname
,
first_child
->
getText
());
if
(
!
classNameToCid
(
o
->
cname
,
&
o
->
m_cid
))
{
// Syntax exception -- vid
...
...
@@ -1867,9 +1859,8 @@ void wb_wblnode::registerNode( wb_vrepwbl *vol)
// Get oid
ref_wblnode
second_child
=
first_child
->
getNextSibling
();
if
(
second_child
)
{
if
(
second_child
->
getType
()
==
tokens
.
OID
)
{
string
vidstring
=
second_child
->
getText
();
sts
=
cdh_StringToVolumeId
(
(
char
*
)
vidstring
.
c_str
(),
&
vid
);
if
(
second_child
->
getType
()
==
wbl_eToken_Index
)
{
sts
=
cdh_StringToVolumeId
(
second_child
->
getText
(),
&
vid
);
if
(
EVEN
(
sts
))
{
// Syntax exception -- vid
m_vrep
->
error
(
"Volume id syntax"
,
getFileName
(),
line_number
);
...
...
@@ -1898,18 +1889,17 @@ void wb_wblnode::registerNode( wb_vrepwbl *vol)
build
(
false
);
}
}
else
if
(
getType
()
==
tokens
.
CHAR_LITERAL
)
else
if
(
getType
()
==
wbl_eToken_Char
)
{
// Remove quotes
char
str
[
10
];
string
text
=
getText
();
const
char
*
text_p
=
text
.
c_str
();
const
char
*
text_p
=
getText
();
strncpy
(
str
,
&
text_p
[
1
],
sizeof
(
str
));
str
[
strlen
(
str
)
-
1
]
=
0
;
string
new_text
(
str
);
setText
(
new_text
);
setText
(
str
);
}
else
if
(
getType
()
==
tokens
.
STRING_LITERAL
)
else
if
(
getType
()
==
wbl_eToken_String
||
(
getType
()
==
wbl_eToken_Value
&&
text
[
0
]
==
'\"'
&&
text
[
size
-
1
]
==
'\"'
))
{
// Remove quotes and replace \" with " and also backslash
char
str
[
8192
];
...
...
@@ -1919,7 +1909,7 @@ void wb_wblnode::registerNode( wb_vrepwbl *vol)
bool
backslash_done
=
false
;
t
=
str
;
for
(
s
=
getText
()
.
c_str
()
;
*
s
;
s
++
)
{
for
(
s
=
getText
();
*
s
;
s
++
)
{
if
(
first
)
{
first
=
false
;
continue
;
...
...
@@ -1937,8 +1927,7 @@ void wb_wblnode::registerNode( wb_vrepwbl *vol)
}
t
--
;
*
t
=
0
;
string
new_text
(
str
);
setText
(
new_text
);
setText
(
str
);
}
ref_wblnode
child
=
first_child
;
...
...
@@ -2371,13 +2360,13 @@ bool wb_wblnode::docBlock( char **block, int *size) const
return
true
;
}
*
size
=
strlen
(
o
->
docblock
->
getText
()
.
c_str
()
)
+
1
;
*
size
=
strlen
(
o
->
docblock
->
getText
())
+
1
;
*
block
=
(
char
*
)
calloc
(
1
,
*
size
);
// strncpy( *block, o->docblock->getText()
.c_str()
, *size);
// strncpy( *block, o->docblock->getText(), *size);
// Remove first and last row, and the beginning ! on each row
char
*
s
=
(
char
*
)
o
->
docblock
->
getText
()
.
c_str
()
;
char
*
s
=
(
char
*
)
o
->
docblock
->
getText
();
char
*
t
=
*
block
;
char
*
start_t
=
t
;
// Skip first line
...
...
wb/lib/wb/src/wb_wblnode.h
View file @
555034cb
...
...
@@ -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
;
...
...
wb/lib/wb/src/wb_wblparser.cpp
deleted
100644 → 0
View file @
2e705e5e
/* $ANTLR 2.7.6 (20060211): "wb_wblparser.g" -> "wb_wblparser.cpp"$ */
#include "wb_wblparser.hpp"
#include <antlr/NoViableAltException.hpp>
#include <antlr/SemanticException.hpp>
#include <antlr/ASTFactory.hpp>
#line 14 "wb_wblparser.g"
#include "cow_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
;
}
#line 19 "wb_wblparser.cpp"
#line 1 "wb_wblparser.g"
#line 21 "wb_wblparser.cpp"
wb_wblparser
::
wb_wblparser
(
ANTLR_USE_NAMESPACE
(
antlr
)
TokenBuffer
&
tokenBuf
,
int
k
)
:
ANTLR_USE_NAMESPACE
(
antlr
)
LLkParser
(
tokenBuf
,
k
)
{
}
wb_wblparser
::
wb_wblparser
(
ANTLR_USE_NAMESPACE
(
antlr
)
TokenBuffer
&
tokenBuf
)
:
ANTLR_USE_NAMESPACE
(
antlr
)
LLkParser
(
tokenBuf
,
1
)
{
}
wb_wblparser
::
wb_wblparser
(
ANTLR_USE_NAMESPACE
(
antlr
)
TokenStream
&
lexer
,
int
k
)
:
ANTLR_USE_NAMESPACE
(
antlr
)
LLkParser
(
lexer
,
k
)
{
}
wb_wblparser
::
wb_wblparser
(
ANTLR_USE_NAMESPACE
(
antlr
)
TokenStream
&
lexer
)
:
ANTLR_USE_NAMESPACE
(
antlr
)
LLkParser
(
lexer
,
1
)
{
}
wb_wblparser
::
wb_wblparser
(
const
ANTLR_USE_NAMESPACE
(
antlr
)
ParserSharedInputState
&
state
)
:
ANTLR_USE_NAMESPACE
(
antlr
)
LLkParser
(
state
,
1
)
{
}
void
wb_wblparser
::
unit
()
{
returnAST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
ANTLR_USE_NAMESPACE
(
antlr
)
ASTPair
currentAST
;
ref_wblnode
unit_AST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
try
{
// for error handling
{
// ( ... )+
int
_cnt3
=
0
;
for
(;;)
{
switch
(
LA
(
1
))
{
case
VOLUME
:
{
volume
();
astFactory
->
addASTChild
(
currentAST
,
ANTLR_USE_NAMESPACE
(
antlr
)
RefAST
(
returnAST
));
break
;
}
case
SOBJECT
:
{
sobject
();
astFactory
->
addASTChild
(
currentAST
,
ANTLR_USE_NAMESPACE
(
antlr
)
RefAST
(
returnAST
));
break
;
}
case
OBJECT
:
{
object
();
astFactory
->
addASTChild
(
currentAST
,
ANTLR_USE_NAMESPACE
(
antlr
)
RefAST
(
returnAST
));
break
;
}
default:
{
if
(
_cnt3
>=
1
)
{
goto
_loop3
;
}
else
{
throw
ANTLR_USE_NAMESPACE
(
antlr
)
NoViableAltException
(
LT
(
1
),
getFilename
());}
}
}
_cnt3
++
;
}
_loop3:
;
}
// ( ... )+
unit_AST
=
ref_wblnode
(
currentAST
.
root
);
}
catch
(
ANTLR_USE_NAMESPACE
(
antlr
)
RecognitionException
&
ex
)
{
reportError
(
ex
);
recover
(
ex
,
_tokenSet_0
);
}
returnAST
=
unit_AST
;
}
void
wb_wblparser
::
volume
()
{
returnAST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
ANTLR_USE_NAMESPACE
(
antlr
)
ASTPair
currentAST
;
ref_wblnode
volume_AST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
try
{
// for error handling
ref_wblnode
tmp1_AST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
tmp1_AST
=
astFactory
->
create
(
LT
(
1
));
astFactory
->
makeASTRoot
(
currentAST
,
ANTLR_USE_NAMESPACE
(
antlr
)
RefAST
(
tmp1_AST
));
match
(
VOLUME
);
cid
();
astFactory
->
addASTChild
(
currentAST
,
ANTLR_USE_NAMESPACE
(
antlr
)
RefAST
(
returnAST
));
ref_wblnode
tmp2_AST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
tmp2_AST
=
astFactory
->
create
(
LT
(
1
));
astFactory
->
addASTChild
(
currentAST
,
ANTLR_USE_NAMESPACE
(
antlr
)
RefAST
(
tmp2_AST
));
match
(
OID
);
{
// ( ... )*
for
(;;)
{
if
((
LA
(
1
)
==
BODY
))
{
body
();
astFactory
->
addASTChild
(
currentAST
,
ANTLR_USE_NAMESPACE
(
antlr
)
RefAST
(
returnAST
));
}
else
{
goto
_loop6
;
}
}
_loop6:
;
}
// ( ... )*
{
// ( ... )*
for
(;;)
{
if
((
LA
(
1
)
==
OBJECT
||
LA
(
1
)
==
DOCBLOCK
))
{
{
switch
(
LA
(
1
))
{
case
DOCBLOCK
:
{
ref_wblnode
tmp3_AST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
tmp3_AST
=
astFactory
->
create
(
LT
(
1
));
astFactory
->
addASTChild
(
currentAST
,
ANTLR_USE_NAMESPACE
(
antlr
)
RefAST
(
tmp3_AST
));
match
(
DOCBLOCK
);
break
;
}
case
OBJECT
:
{
break
;
}
default:
{
throw
ANTLR_USE_NAMESPACE
(
antlr
)
NoViableAltException
(
LT
(
1
),
getFilename
());
}
}
}
object
();
astFactory
->
addASTChild
(
currentAST
,
ANTLR_USE_NAMESPACE
(
antlr
)
RefAST
(
returnAST
));
}
else
{
goto
_loop9
;
}
}
_loop9:
;
}
// ( ... )*
ref_wblnode
tmp4_AST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
tmp4_AST
=
astFactory
->
create
(
LT
(
1
));
astFactory
->
addASTChild
(
currentAST
,
ANTLR_USE_NAMESPACE
(
antlr
)
RefAST
(
tmp4_AST
));
match
(
ENDVOLUME
);
volume_AST
=
ref_wblnode
(
currentAST
.
root
);
}
catch
(
ANTLR_USE_NAMESPACE
(
antlr
)
RecognitionException
&
ex
)
{
reportError
(
ex
);
recover
(
ex
,
_tokenSet_1
);
}
returnAST
=
volume_AST
;
}
void
wb_wblparser
::
sobject
()
{
returnAST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
ANTLR_USE_NAMESPACE
(
antlr
)
ASTPair
currentAST
;
ref_wblnode
sobject_AST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
try
{
// for error handling
ref_wblnode
tmp5_AST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
tmp5_AST
=
astFactory
->
create
(
LT
(
1
));
astFactory
->
makeASTRoot
(
currentAST
,
ANTLR_USE_NAMESPACE
(
antlr
)
RefAST
(
tmp5_AST
));
match
(
SOBJECT
);
{
// ( ... )*
for
(;;)
{
if
((
LA
(
1
)
==
OBJECT
||
LA
(
1
)
==
DOCBLOCK
))
{
{
switch
(
LA
(
1
))
{
case
DOCBLOCK
:
{
ref_wblnode
tmp6_AST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
tmp6_AST
=
astFactory
->
create
(
LT
(
1
));
astFactory
->
addASTChild
(
currentAST
,
ANTLR_USE_NAMESPACE
(
antlr
)
RefAST
(
tmp6_AST
));
match
(
DOCBLOCK
);
break
;
}
case
OBJECT
:
{
break
;
}
default:
{
throw
ANTLR_USE_NAMESPACE
(
antlr
)
NoViableAltException
(
LT
(
1
),
getFilename
());
}
}
}
object
();
astFactory
->
addASTChild
(
currentAST
,
ANTLR_USE_NAMESPACE
(
antlr
)
RefAST
(
returnAST
));
}
else
{
goto
_loop13
;
}
}
_loop13:
;
}
// ( ... )*
ref_wblnode
tmp7_AST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
tmp7_AST
=
astFactory
->
create
(
LT
(
1
));
astFactory
->
addASTChild
(
currentAST
,
ANTLR_USE_NAMESPACE
(
antlr
)
RefAST
(
tmp7_AST
));
match
(
ENDSOBJECT
);
sobject_AST
=
ref_wblnode
(
currentAST
.
root
);
}
catch
(
ANTLR_USE_NAMESPACE
(
antlr
)
RecognitionException
&
ex
)
{
reportError
(
ex
);
recover
(
ex
,
_tokenSet_1
);
}
returnAST
=
sobject_AST
;
}
void
wb_wblparser
::
object
()
{
returnAST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
ANTLR_USE_NAMESPACE
(
antlr
)
ASTPair
currentAST
;
ref_wblnode
object_AST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
try
{
// for error handling
ref_wblnode
tmp8_AST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
tmp8_AST
=
astFactory
->
create
(
LT
(
1
));
astFactory
->
makeASTRoot
(
currentAST
,
ANTLR_USE_NAMESPACE
(
antlr
)
RefAST
(
tmp8_AST
));
match
(
OBJECT
);
cid
();
astFactory
->
addASTChild
(
currentAST
,
ANTLR_USE_NAMESPACE
(
antlr
)
RefAST
(
returnAST
));
{
switch
(
LA
(
1
))
{
case
INT
:
case
VALUE
:
{
oix
();
astFactory
->
addASTChild
(
currentAST
,
ANTLR_USE_NAMESPACE
(
antlr
)
RefAST
(
returnAST
));
break
;
}
case
OBJECT
:
case
ENDOBJECT
:
case
BODY
:
case
DOCBLOCK
:
case
ASC_TIME
:
{
break
;
}
default:
{
throw
ANTLR_USE_NAMESPACE
(
antlr
)
NoViableAltException
(
LT
(
1
),
getFilename
());
}
}
}
{
switch
(
LA
(
1
))
{
case
ASC_TIME
:
{
ref_wblnode
tmp9_AST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
tmp9_AST
=
astFactory
->
create
(
LT
(
1
));
astFactory
->
addASTChild
(
currentAST
,
ANTLR_USE_NAMESPACE
(
antlr
)
RefAST
(
tmp9_AST
));
match
(
ASC_TIME
);
break
;
}
case
OBJECT
:
case
ENDOBJECT
:
case
BODY
:
case
DOCBLOCK
:
{
break
;
}
default:
{
throw
ANTLR_USE_NAMESPACE
(
antlr
)
NoViableAltException
(
LT
(
1
),
getFilename
());
}
}
}
{
// ( ... )*
for
(;;)
{
if
((
LA
(
1
)
==
BODY
))
{
body
();
astFactory
->
addASTChild
(
currentAST
,
ANTLR_USE_NAMESPACE
(
antlr
)
RefAST
(
returnAST
));
}
else
{
goto
_loop18
;
}
}
_loop18:
;
}
// ( ... )*
{
// ( ... )*
for
(;;)
{
if
((
LA
(
1
)
==
OBJECT
||
LA
(
1
)
==
DOCBLOCK
))
{
{
switch
(
LA
(
1
))
{
case
DOCBLOCK
:
{
ref_wblnode
tmp10_AST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
tmp10_AST
=
astFactory
->
create
(
LT
(
1
));
astFactory
->
addASTChild
(
currentAST
,
ANTLR_USE_NAMESPACE
(
antlr
)
RefAST
(
tmp10_AST
));
match
(
DOCBLOCK
);
break
;
}
case
OBJECT
:
{
break
;
}
default:
{
throw
ANTLR_USE_NAMESPACE
(
antlr
)
NoViableAltException
(
LT
(
1
),
getFilename
());
}
}
}
object
();
astFactory
->
addASTChild
(
currentAST
,
ANTLR_USE_NAMESPACE
(
antlr
)
RefAST
(
returnAST
));
}
else
{
goto
_loop21
;
}
}
_loop21:
;
}
// ( ... )*
ref_wblnode
tmp11_AST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
tmp11_AST
=
astFactory
->
create
(
LT
(
1
));
astFactory
->
addASTChild
(
currentAST
,
ANTLR_USE_NAMESPACE
(
antlr
)
RefAST
(
tmp11_AST
));
match
(
ENDOBJECT
);
object_AST
=
ref_wblnode
(
currentAST
.
root
);
}
catch
(
ANTLR_USE_NAMESPACE
(
antlr
)
RecognitionException
&
ex
)
{
reportError
(
ex
);
recover
(
ex
,
_tokenSet_2
);
}
returnAST
=
object_AST
;
}
void
wb_wblparser
::
cid
()
{
returnAST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
ANTLR_USE_NAMESPACE
(
antlr
)
ASTPair
currentAST
;
ref_wblnode
cid_AST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
try
{
// for error handling
switch
(
LA
(
1
))
{
case
VALUE
:
{
ref_wblnode
tmp12_AST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
tmp12_AST
=
astFactory
->
create
(
LT
(
1
));
astFactory
->
addASTChild
(
currentAST
,
ANTLR_USE_NAMESPACE
(
antlr
)
RefAST
(
tmp12_AST
));
match
(
VALUE
);
cid_AST
=
ref_wblnode
(
currentAST
.
root
);
break
;
}
case
STRING_LITERAL
:
{
ref_wblnode
tmp13_AST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
tmp13_AST
=
astFactory
->
create
(
LT
(
1
));
astFactory
->
addASTChild
(
currentAST
,
ANTLR_USE_NAMESPACE
(
antlr
)
RefAST
(
tmp13_AST
));
match
(
STRING_LITERAL
);
cid_AST
=
ref_wblnode
(
currentAST
.
root
);
break
;
}
default:
{
throw
ANTLR_USE_NAMESPACE
(
antlr
)
NoViableAltException
(
LT
(
1
),
getFilename
());
}
}
}
catch
(
ANTLR_USE_NAMESPACE
(
antlr
)
RecognitionException
&
ex
)
{
reportError
(
ex
);
recover
(
ex
,
_tokenSet_3
);
}
returnAST
=
cid_AST
;
}
void
wb_wblparser
::
body
()
{
returnAST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
ANTLR_USE_NAMESPACE
(
antlr
)
ASTPair
currentAST
;
ref_wblnode
body_AST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
try
{
// for error handling
ref_wblnode
tmp14_AST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
tmp14_AST
=
astFactory
->
create
(
LT
(
1
));
astFactory
->
makeASTRoot
(
currentAST
,
ANTLR_USE_NAMESPACE
(
antlr
)
RefAST
(
tmp14_AST
));
match
(
BODY
);
{
switch
(
LA
(
1
))
{
case
ASC_TIME
:
{
ref_wblnode
tmp15_AST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
tmp15_AST
=
astFactory
->
create
(
LT
(
1
));
astFactory
->
addASTChild
(
currentAST
,
ANTLR_USE_NAMESPACE
(
antlr
)
RefAST
(
tmp15_AST
));
match
(
ASC_TIME
);
break
;
}
case
ENDBODY
:
case
ATTRIBUTE
:
case
BUFFER
:
{
break
;
}
default:
{
throw
ANTLR_USE_NAMESPACE
(
antlr
)
NoViableAltException
(
LT
(
1
),
getFilename
());
}
}
}
{
// ( ... )*
for
(;;)
{
if
((
LA
(
1
)
==
ATTRIBUTE
||
LA
(
1
)
==
BUFFER
))
{
attribute
();
astFactory
->
addASTChild
(
currentAST
,
ANTLR_USE_NAMESPACE
(
antlr
)
RefAST
(
returnAST
));
}
else
{
goto
_loop25
;
}
}
_loop25:
;
}
// ( ... )*
ref_wblnode
tmp16_AST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
tmp16_AST
=
astFactory
->
create
(
LT
(
1
));
astFactory
->
addASTChild
(
currentAST
,
ANTLR_USE_NAMESPACE
(
antlr
)
RefAST
(
tmp16_AST
));
match
(
ENDBODY
);
body_AST
=
ref_wblnode
(
currentAST
.
root
);
}
catch
(
ANTLR_USE_NAMESPACE
(
antlr
)
RecognitionException
&
ex
)
{
reportError
(
ex
);
recover
(
ex
,
_tokenSet_4
);
}
returnAST
=
body_AST
;
}
void
wb_wblparser
::
oix
()
{
returnAST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
ANTLR_USE_NAMESPACE
(
antlr
)
ASTPair
currentAST
;
ref_wblnode
oix_AST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
try
{
// for error handling
switch
(
LA
(
1
))
{
case
VALUE
:
{
ref_wblnode
tmp17_AST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
tmp17_AST
=
astFactory
->
create
(
LT
(
1
));
astFactory
->
addASTChild
(
currentAST
,
ANTLR_USE_NAMESPACE
(
antlr
)
RefAST
(
tmp17_AST
));
match
(
VALUE
);
oix_AST
=
ref_wblnode
(
currentAST
.
root
);
break
;
}
case
INT
:
{
ref_wblnode
tmp18_AST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
tmp18_AST
=
astFactory
->
create
(
LT
(
1
));
astFactory
->
addASTChild
(
currentAST
,
ANTLR_USE_NAMESPACE
(
antlr
)
RefAST
(
tmp18_AST
));
match
(
INT
);
oix_AST
=
ref_wblnode
(
currentAST
.
root
);
break
;
}
default:
{
throw
ANTLR_USE_NAMESPACE
(
antlr
)
NoViableAltException
(
LT
(
1
),
getFilename
());
}
}
}
catch
(
ANTLR_USE_NAMESPACE
(
antlr
)
RecognitionException
&
ex
)
{
reportError
(
ex
);
recover
(
ex
,
_tokenSet_5
);
}
returnAST
=
oix_AST
;
}
void
wb_wblparser
::
attribute
()
{
returnAST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
ANTLR_USE_NAMESPACE
(
antlr
)
ASTPair
currentAST
;
ref_wblnode
attribute_AST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
try
{
// for error handling
switch
(
LA
(
1
))
{
case
ATTRIBUTE
:
{
ref_wblnode
tmp19_AST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
tmp19_AST
=
astFactory
->
create
(
LT
(
1
));
astFactory
->
makeASTRoot
(
currentAST
,
ANTLR_USE_NAMESPACE
(
antlr
)
RefAST
(
tmp19_AST
));
match
(
ATTRIBUTE
);
{
switch
(
LA
(
1
))
{
case
EQ
:
{
ref_wblnode
tmp20_AST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
tmp20_AST
=
astFactory
->
create
(
LT
(
1
));
astFactory
->
addASTChild
(
currentAST
,
ANTLR_USE_NAMESPACE
(
antlr
)
RefAST
(
tmp20_AST
));
match
(
EQ
);
break
;
}
case
OREQ
:
{
ref_wblnode
tmp21_AST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
tmp21_AST
=
astFactory
->
create
(
LT
(
1
));
astFactory
->
addASTChild
(
currentAST
,
ANTLR_USE_NAMESPACE
(
antlr
)
RefAST
(
tmp21_AST
));
match
(
OREQ
);
break
;
}
default:
{
throw
ANTLR_USE_NAMESPACE
(
antlr
)
NoViableAltException
(
LT
(
1
),
getFilename
());
}
}
}
value
();
astFactory
->
addASTChild
(
currentAST
,
ANTLR_USE_NAMESPACE
(
antlr
)
RefAST
(
returnAST
));
attribute_AST
=
ref_wblnode
(
currentAST
.
root
);
break
;
}
case
BUFFER
:
{
ref_wblnode
tmp22_AST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
tmp22_AST
=
astFactory
->
create
(
LT
(
1
));
astFactory
->
makeASTRoot
(
currentAST
,
ANTLR_USE_NAMESPACE
(
antlr
)
RefAST
(
tmp22_AST
));
match
(
BUFFER
);
{
switch
(
LA
(
1
))
{
case
INDEX
:
{
ref_wblnode
tmp23_AST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
tmp23_AST
=
astFactory
->
create
(
LT
(
1
));
astFactory
->
addASTChild
(
currentAST
,
ANTLR_USE_NAMESPACE
(
antlr
)
RefAST
(
tmp23_AST
));
match
(
INDEX
);
break
;
}
case
ATTRIBUTE
:
case
BUFFER
:
case
ENDBUFFER
:
{
break
;
}
default:
{
throw
ANTLR_USE_NAMESPACE
(
antlr
)
NoViableAltException
(
LT
(
1
),
getFilename
());
}
}
}
{
// ( ... )*
for
(;;)
{
if
((
LA
(
1
)
==
ATTRIBUTE
||
LA
(
1
)
==
BUFFER
))
{
attribute
();
astFactory
->
addASTChild
(
currentAST
,
ANTLR_USE_NAMESPACE
(
antlr
)
RefAST
(
returnAST
));
}
else
{
goto
_loop30
;
}
}
_loop30:
;
}
// ( ... )*
ref_wblnode
tmp24_AST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
tmp24_AST
=
astFactory
->
create
(
LT
(
1
));
astFactory
->
addASTChild
(
currentAST
,
ANTLR_USE_NAMESPACE
(
antlr
)
RefAST
(
tmp24_AST
));
match
(
ENDBUFFER
);
attribute_AST
=
ref_wblnode
(
currentAST
.
root
);
break
;
}
default:
{
throw
ANTLR_USE_NAMESPACE
(
antlr
)
NoViableAltException
(
LT
(
1
),
getFilename
());
}
}
}
catch
(
ANTLR_USE_NAMESPACE
(
antlr
)
RecognitionException
&
ex
)
{
reportError
(
ex
);
recover
(
ex
,
_tokenSet_6
);
}
returnAST
=
attribute_AST
;
}
void
wb_wblparser
::
value
()
{
returnAST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
ANTLR_USE_NAMESPACE
(
antlr
)
ASTPair
currentAST
;
ref_wblnode
value_AST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
try
{
// for error handling
switch
(
LA
(
1
))
{
case
VALUE
:
{
ref_wblnode
tmp25_AST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
tmp25_AST
=
astFactory
->
create
(
LT
(
1
));
astFactory
->
addASTChild
(
currentAST
,
ANTLR_USE_NAMESPACE
(
antlr
)
RefAST
(
tmp25_AST
));
match
(
VALUE
);
value_AST
=
ref_wblnode
(
currentAST
.
root
);
break
;
}
case
STRING_LITERAL
:
{
ref_wblnode
tmp26_AST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
tmp26_AST
=
astFactory
->
create
(
LT
(
1
));
astFactory
->
addASTChild
(
currentAST
,
ANTLR_USE_NAMESPACE
(
antlr
)
RefAST
(
tmp26_AST
));
match
(
STRING_LITERAL
);
value_AST
=
ref_wblnode
(
currentAST
.
root
);
break
;
}
case
NUM_FLOAT
:
{
ref_wblnode
tmp27_AST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
tmp27_AST
=
astFactory
->
create
(
LT
(
1
));
astFactory
->
addASTChild
(
currentAST
,
ANTLR_USE_NAMESPACE
(
antlr
)
RefAST
(
tmp27_AST
));
match
(
NUM_FLOAT
);
value_AST
=
ref_wblnode
(
currentAST
.
root
);
break
;
}
case
INT
:
{
ref_wblnode
tmp28_AST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
tmp28_AST
=
astFactory
->
create
(
LT
(
1
));
astFactory
->
addASTChild
(
currentAST
,
ANTLR_USE_NAMESPACE
(
antlr
)
RefAST
(
tmp28_AST
));
match
(
INT
);
value_AST
=
ref_wblnode
(
currentAST
.
root
);
break
;
}
default:
{
throw
ANTLR_USE_NAMESPACE
(
antlr
)
NoViableAltException
(
LT
(
1
),
getFilename
());
}
}
}
catch
(
ANTLR_USE_NAMESPACE
(
antlr
)
RecognitionException
&
ex
)
{
reportError
(
ex
);
recover
(
ex
,
_tokenSet_6
);
}
returnAST
=
value_AST
;
}
void
wb_wblparser
::
oname
()
{
returnAST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
ANTLR_USE_NAMESPACE
(
antlr
)
ASTPair
currentAST
;
ref_wblnode
oname_AST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
try
{
// for error handling
ref_wblnode
tmp29_AST
=
ref_wblnode
(
ANTLR_USE_NAMESPACE
(
antlr
)
nullAST
);
tmp29_AST
=
astFactory
->
create
(
LT
(
1
));
astFactory
->
addASTChild
(
currentAST
,
ANTLR_USE_NAMESPACE
(
antlr
)
RefAST
(
tmp29_AST
));
match
(
VALUE
);
oname_AST
=
ref_wblnode
(
currentAST
.
root
);
}
catch
(
ANTLR_USE_NAMESPACE
(
antlr
)
RecognitionException
&
ex
)
{
reportError
(
ex
);
recover
(
ex
,
_tokenSet_0
);
}
returnAST
=
oname_AST
;
}
void
wb_wblparser
::
initializeASTFactory
(
ANTLR_USE_NAMESPACE
(
antlr
)
ASTFactory
&
factory
)
{
factory
.
setMaxNodeType
(
35
);
}
const
char
*
wb_wblparser
::
tokenNames
[]
=
{
"<0>"
,
"EOF"
,
"<2>"
,
"NULL_TREE_LOOKAHEAD"
,
"OBJECT"
,
"ENDOBJECT"
,
"VOLUME"
,
"ENDVOLUME"
,
"SOBJECT"
,
"ENDSOBJECT"
,
"BODY"
,
"ENDBODY"
,
"ATTRIBUTE"
,
"BUFFER"
,
"ENDBUFFER"
,
"DOBJECT"
,
"ENDDOBJECT"
,
"DBUFFER"
,
"ENDDBUFFER"
,
"DATTRIBUTE"
,
"NUM_FLOAT"
,
"INT"
,
"OID"
,
"DOCBLOCK"
,
"ASC_TIME"
,
"EQ"
,
"OREQ"
,
"WS"
,
"COMMENT"
,
"an index"
,
"an identifer"
,
"CHAR_LITERAL"
,
"STRING_LITERAL"
,
"DIGITS"
,
"ESC"
,
"SWEC"
,
0
};
const
unsigned
long
wb_wblparser
::
_tokenSet_0_data_
[]
=
{
2UL
,
0UL
,
0UL
,
0UL
};
// EOF
const
ANTLR_USE_NAMESPACE
(
antlr
)
BitSet
wb_wblparser
::
_tokenSet_0
(
_tokenSet_0_data_
,
4
);
const
unsigned
long
wb_wblparser
::
_tokenSet_1_data_
[]
=
{
338UL
,
0UL
,
0UL
,
0UL
};
// EOF OBJECT VOLUME SOBJECT
const
ANTLR_USE_NAMESPACE
(
antlr
)
BitSet
wb_wblparser
::
_tokenSet_1
(
_tokenSet_1_data_
,
4
);
const
unsigned
long
wb_wblparser
::
_tokenSet_2_data_
[]
=
{
8389618UL
,
0UL
,
0UL
,
0UL
};
// EOF OBJECT ENDOBJECT VOLUME ENDVOLUME SOBJECT ENDSOBJECT DOCBLOCK
const
ANTLR_USE_NAMESPACE
(
antlr
)
BitSet
wb_wblparser
::
_tokenSet_2
(
_tokenSet_2_data_
,
4
);
const
unsigned
long
wb_wblparser
::
_tokenSet_3_data_
[]
=
{
1105200176UL
,
0UL
,
0UL
,
0UL
};
// OBJECT ENDOBJECT BODY INT OID DOCBLOCK ASC_TIME VALUE
const
ANTLR_USE_NAMESPACE
(
antlr
)
BitSet
wb_wblparser
::
_tokenSet_3
(
_tokenSet_3_data_
,
4
);
const
unsigned
long
wb_wblparser
::
_tokenSet_4_data_
[]
=
{
8389808UL
,
0UL
,
0UL
,
0UL
};
// OBJECT ENDOBJECT ENDVOLUME BODY DOCBLOCK
const
ANTLR_USE_NAMESPACE
(
antlr
)
BitSet
wb_wblparser
::
_tokenSet_4
(
_tokenSet_4_data_
,
4
);
const
unsigned
long
wb_wblparser
::
_tokenSet_5_data_
[]
=
{
25166896UL
,
0UL
,
0UL
,
0UL
};
// OBJECT ENDOBJECT BODY DOCBLOCK ASC_TIME
const
ANTLR_USE_NAMESPACE
(
antlr
)
BitSet
wb_wblparser
::
_tokenSet_5
(
_tokenSet_5_data_
,
4
);
const
unsigned
long
wb_wblparser
::
_tokenSet_6_data_
[]
=
{
30720UL
,
0UL
,
0UL
,
0UL
};
// ENDBODY ATTRIBUTE BUFFER ENDBUFFER
const
ANTLR_USE_NAMESPACE
(
antlr
)
BitSet
wb_wblparser
::
_tokenSet_6
(
_tokenSet_6_data_
,
4
);
wb/lib/wb/src/wb_wblparser.g
deleted
100644 → 0
View file @
2e705e5e
/*
* 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
;
wb/lib/wb/src/wb_wblparser.hpp
deleted
100644 → 0
View file @
2e705e5e
#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_*/
wb/lib/wb/src/wb_wblparserTokenTypes.hpp
deleted
100644 → 0
View file @
2e705e5e
#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_*/
wb/lib/wb/src/wb_wblparserTokenTypes.txt
deleted
100644 → 0
View file @
2e705e5e
// $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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment