ENH: update lemon version, wmake wrappers

This commit is contained in:
Mark Olesen 2021-11-08 13:29:39 +01:00
parent a78e79908b
commit 79e110aeb0
24 changed files with 388 additions and 316 deletions

View File

@ -730,55 +730,6 @@ static YYACTIONTYPE yy_reduce(
(void)yyLookahead;
(void)yyLookaheadToken;
yymsp = yypParser->yytos;
assert( yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) );
#ifndef NDEBUG
if( yyTraceFILE ){
yysize = yyRuleInfoNRhs[yyruleno];
if( yysize ){
fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n",
yyTracePrompt,
yyruleno, yyRuleName[yyruleno],
yyruleno<YYNRULE_WITH_ACTION ? "" : " without external action",
yymsp[yysize].stateno);
}else{
fprintf(yyTraceFILE, "%sReduce %d [%s]%s.\n",
yyTracePrompt, yyruleno, yyRuleName[yyruleno],
yyruleno<YYNRULE_WITH_ACTION ? "" : " without external action");
}
}
#endif /* NDEBUG */
/* Check that the stack is large enough to grow by a single entry
** if the RHS of the rule is empty. This ensures that there is room
** enough on the stack to push the LHS value */
if( yyRuleInfoNRhs[yyruleno]==0 ){
#ifdef YYTRACKMAXSTACKDEPTH
if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){
yypParser->yyhwm++;
assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack));
}
#endif
#if YYSTACKDEPTH>0
if( yypParser->yytos>=yypParser->yystackEnd ){
yyStackOverflow(yypParser);
/* The call to yyStackOverflow() above pops the stack until it is
** empty, causing the main parser loop to exit. So the return value
** is never used and does not matter. */
return 0;
}
#else
if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){
if( yyGrowStack(yypParser) ){
yyStackOverflow(yypParser);
/* The call to yyStackOverflow() above pops the stack until it is
** empty, causing the main parser loop to exit. So the return value
** is never used and does not matter. */
return 0;
}
yymsp = yypParser->yytos;
}
#endif
}
switch( yyruleno ){
/* Beginning here are the reduction cases. A typical example
@ -938,12 +889,56 @@ void Parse(
}
#endif
do{
while(1){ /* Exit by "break" */
assert( yypParser->yytos>=yypParser->yystack );
assert( yyact==yypParser->yytos->stateno );
yyact = yy_find_shift_action((YYCODETYPE)yymajor,yyact);
if( yyact >= YY_MIN_REDUCE ){
yyact = yy_reduce(yypParser,yyact-YY_MIN_REDUCE,yymajor,
yyminor ParseCTX_PARAM);
unsigned int yyruleno = yyact - YY_MIN_REDUCE; /* Reduce by this rule */
assert( yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) );
#ifndef NDEBUG
if( yyTraceFILE ){
int yysize = yyRuleInfoNRhs[yyruleno];
if( yysize ){
fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n",
yyTracePrompt,
yyruleno, yyRuleName[yyruleno],
yyruleno<YYNRULE_WITH_ACTION ? "" : " without external action",
yypParser->yytos[yysize].stateno);
}else{
fprintf(yyTraceFILE, "%sReduce %d [%s]%s.\n",
yyTracePrompt, yyruleno, yyRuleName[yyruleno],
yyruleno<YYNRULE_WITH_ACTION ? "" : " without external action");
}
}
#endif /* NDEBUG */
/* Check that the stack is large enough to grow by a single entry
** if the RHS of the rule is empty. This ensures that there is room
** enough on the stack to push the LHS value */
if( yyRuleInfoNRhs[yyruleno]==0 ){
#ifdef YYTRACKMAXSTACKDEPTH
if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){
yypParser->yyhwm++;
assert( yypParser->yyhwm ==
(int)(yypParser->yytos - yypParser->yystack));
}
#endif
#if YYSTACKDEPTH>0
if( yypParser->yytos>=yypParser->yystackEnd ){
yyStackOverflow(yypParser);
break;
}
#else
if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){
if( yyGrowStack(yypParser) ){
yyStackOverflow(yypParser);
break;
}
}
#endif
}
yyact = yy_reduce(yypParser,yyruleno,yymajor,yyminor ParseCTX_PARAM);
}else if( yyact <= YY_MAX_SHIFTREDUCE ){
yy_shift(yypParser,yyact,(YYCODETYPE)yymajor,yyminor);
#ifndef YYNOERRORRECOVERY
@ -999,14 +994,13 @@ void Parse(
yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion);
yymajor = YYNOCODE;
}else{
while( yypParser->yytos >= yypParser->yystack
&& (yyact = yy_find_reduce_action(
yypParser->yytos->stateno,
YYERRORSYMBOL)) > YY_MAX_SHIFTREDUCE
){
while( yypParser->yytos > yypParser->yystack ){
yyact = yy_find_reduce_action(yypParser->yytos->stateno,
YYERRORSYMBOL);
if( yyact<=YY_MAX_SHIFTREDUCE ) break;
yy_pop_parser_stack(yypParser);
}
if( yypParser->yytos < yypParser->yystack || yymajor==0 ){
if( yypParser->yytos <= yypParser->yystack || yymajor==0 ){
yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
yy_parse_failed(yypParser);
#ifndef YYNOERRORRECOVERY
@ -1056,7 +1050,7 @@ void Parse(
break;
#endif
}
}while( yypParser->yytos>yypParser->yystack );
}
#ifndef NDEBUG
if( yyTraceFILE ){
yyStackEntry *i;

View File

@ -8,8 +8,7 @@
# Copyright (C) 2011-2016 OpenFOAM Foundation
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# File
# wmake/makefiles/apps

14
wmake/rules/General/eigen Normal file
View File

@ -0,0 +1,14 @@
# ----------------------------------------------------------------------------
# Eigen definitions
#
# 0. missing
# 1. header-only
# ----------------------------------------------------------------------------
ifneq (,$(EIGEN_INC_DIR))
EIGEN_INC := -I$(EIGEN_INC_DIR)
else
EIGEN_INC :=
endif
# ---------------------------------------------------------------------------

View File

@ -9,8 +9,7 @@
# Copyright (C) 2019 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# dirToString

159
wmake/scripts/have_eigen Normal file
View File

@ -0,0 +1,159 @@
#----------------------------------*-sh-*--------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2021 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# have_eigen
#
# Description
# Detection/setup of EIGEN (Eigen3)
#
# Expects
# config.sh/eigen
#
# Functions provided
# have_eigen, no_eigen, echo_eigen, query_eigen, search_eigen
#
# Variables set on success
# HAVE_EIGEN
# EIGEN_INC_DIR
#
#------------------------------------------------------------------------------
. ${WM_PROJECT_DIR:?}/wmake/scripts/sysFunctions # General system functions
#------------------------------------------------------------------------------
# Reset
no_eigen()
{
unset HAVE_EIGEN EIGEN_INC_DIR EIGEN_LIB_DIR
}
# Report
echo_eigen()
{
echo "eigen=${HAVE_EIGEN:-false}"
echo "include=\"$EIGEN_INC_DIR\""
}
# Search
# $1 : prefix (*_ARCH_PATH, system, ...)
#
# On success, return 0 and export variables
# -> HAVE_EIGEN, EIGEN_INC_DIR
search_eigen()
{
local warn # warn="==> skip eigen"
local incName="Eigen/Eigen"
local pkgName="eigen3"
local sentinel="signature_of_eigen3_matrix_library"
local prefix="${1:-system}"
local header incdir
# ----------------------------------
if isNone "$prefix"
then
[ -n "$warn" ] && echo "$warn (disabled)"
return 1
elif hasAbsdir "$prefix"
then
header=$(findFirstFile "$prefix/include/$incName")
elif isSystem "$prefix"
then
header=$(findSystemInclude -name="eigen3/$incName")
# No system header, attempt discovery with pkg-config
if [ -z "$header" ] && pkg-config --exists "$pkgName" 2>/dev/null
then
includeDirs=$(pkg-config --cflags-only-I "$pkgName" | sed -e 's/^-[IL]//; s/[ ]-[IL]/ /;')
header="${includeDirs% *}/$incName" # First entry (ie, split on space)
fi
else
unset prefix
fi
# ----------------------------------
# Header
[ -n "$header" ] || {
[ -n "$warn" ] && echo "$warn (no header)"
return 2
}
# ----------------------------------
header="${header%/*}" # Strip one-level (include/Eigen/...)
# OK
export HAVE_EIGEN=true
export EIGEN_INC_DIR="${header%/*}" # Basename
}
# Output as per search_* function
have_eigen()
{
local warn # warn="==> skip eigen"
local config="config.sh/eigen"
local path="$EIGEN_ARCH_PATH"
local file
# Setup - current environment if set
if [ -z "$path" ]
then
if file="$("$WM_PROJECT_DIR"/bin/foamEtcFile "$config")"
then
. "$file"
path="$EIGEN_ARCH_PATH"
fi
fi
search_eigen "${path:-system}"
}
# Query settings
query_eigen()
{
local config="config.sh/eigen"
local file
if file="$("$WM_PROJECT_DIR"/bin/foamEtcFile -mode=o "$config")"
then
. "$file"
_process_query eigen "${EIGEN_ARCH_PATH:-system}"
else
echo "(no $config)" 1>&2
echo "eigen=unknown"
_process_query eigen "system"
fi
}
#------------------------------------------------------------------------------
# Reset
no_eigen
# Test/query
case "$1" in
-test)
have_eigen
echo_eigen
;;
-query)
query_eigen
;;
esac
#------------------------------------------------------------------------------

View File

@ -9,8 +9,7 @@
# Copyright (C) 2018 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# makeDepend

View File

@ -9,20 +9,7 @@
# Copyright (C) 2011-2016 OpenFOAM Foundation
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
# OpenFOAM 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 3 of the License, or
# (at your option) any later version.
#
# OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# makeFiles

View File

@ -9,20 +9,7 @@
# Copyright (C) 2011 OpenFOAM Foundation
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
# OpenFOAM 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 3 of the License, or
# (at your option) any later version.
#
# OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# makeOptions

View File

@ -9,8 +9,7 @@
# Copyright (C) 2019 OpenCFD Ltd.
#-------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# makeParser
@ -19,9 +18,7 @@
# Pregenerate ragel code and/or lemon parser headers
#
#------------------------------------------------------------------------------
usage() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
printHelp() {
cat<<USAGE
Usage: ${0##*/} [options]
@ -32,7 +29,9 @@ options:
-scanner=FILE Generate ragel scanner code
-code Generate parser code, not header
-header Generate parser header, not code (default)
-grammar Output grammar tables (if supported)
-dry-run Process m4 only (output on stdout)
-no-lines Suppress generation of #line directives
-no-tmp Do not retain temporary m4 processed files
-remove Remove generated code
-h, -help Print the usage
@ -40,18 +39,19 @@ options:
Pregenerate ragel code and/or lemon parser headers
USAGE
exit 1
exit 0 # Clean exit
}
#------------------------------------------------------------------------------
# Parse arguments and options
#------------------------------------------------------------------------------
unset prefix parser scanner optHeader optDryRun optRemoveFile optRemoveTmp
unset prefix parser scanner optHeader optGrammar optDryRun
unset optRemoveFile optRemoveTmp optNoLines
while [ "$#" -gt 0 ]
do
case "$1" in
(-h | -help*) usage ;;
(-h | -help*) printHelp ;;
(-prefix=*) prefix="${1#*=}" ;;
(-parser=*) parser="${1#*=}" ;;
@ -59,7 +59,9 @@ do
(-code) optHeader=false ;;
(-head*) optHeader=true ;;
(-gram*) optGrammar="-grammar" ;; # Pass verbatim to wrapper
(-dry-run) optDryRun="-dry-run" ;; # Pass verbatim to wrapper
(-no-lines) optNoLines=true ;;
(-no-tmp) optRemoveTmp="-no-tmp" ;; # Pass verbatim to wrapper
(-remove) optRemoveFile=true ;;
@ -92,7 +94,7 @@ case "$scanner" in
elif command -v ragel >/dev/null
then
echo "Generating ragel scanner" 1>&2
ragel -G2 -o "$output" "$input"
ragel -G2 ${optNoLines:+-L} -o "$output" "$input"
else
echo "No ragel, leaving scanner intact" 1>&2
fi
@ -144,11 +146,13 @@ case "$parser" in
then
echo "Generating lemon parser code ($extCode)$message" 1>&2
"${WM_PROJECT_DIR:?}/wmake/scripts/wrap-lemon" \
$optDryRun $optRemoveTmp -e"$extCode" -p -s "$input"
$optDryRun $optGrammar $optRemoveTmp \
-e"$extCode" -p -s "$input"
else
echo "Generating lemon parser header$message" 1>&2
"${WM_PROJECT_DIR:?}/wmake/scripts/wrap-lemon" \
$optDryRun $optRemoveTmp -header -p -s "$input"
$optDryRun $optGrammar $optRemoveTmp -header \
-p -s "$input"
fi
fi
echo

View File

@ -9,8 +9,7 @@
# Copyright (C) 2011 OpenFOAM Foundation
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# makeTargetDir

View File

@ -9,20 +9,7 @@
# Copyright (C) 2011-2016 OpenFOAM Foundation
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
# OpenFOAM 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 3 of the License, or
# (at your option) any later version.
#
# OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# wmakeFilesAndOptions

View File

@ -10,20 +10,7 @@
# Copyright (C) 2019 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
# OpenFOAM 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 3 of the License, or
# (at your option) any later version.
#
# OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# wmakeWindowsDlOpenLibs

View File

@ -6,11 +6,10 @@
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#-------------------------------------------------------------------------------
# Copyright (C) 2019 OpenCFD Ltd.
# Copyright (C) 2019-2021 OpenCFD Ltd.
#-------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# wrap-bison
@ -53,15 +52,14 @@
# Note
# General idea lifted from swak
#------------------------------------------------------------------------------
usage() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
printHelp() {
cat<<USAGE
Usage: ${0##*/} [options] [bison args/options]
options:
-dry-run Process m4 only (output on stdout)
-grammar Output grammar tables (ignored)
-no-tmp Do not retain temporary m4 processed files
-output=NAME Request renaming actions
-h, -help Print the usage
@ -69,7 +67,7 @@ options:
A bison wrapper with renaming of skeleton files
USAGE
exit 1
exit 0 # A clean exit
}
# File extensions used (may need adjustment)
@ -81,13 +79,14 @@ extHead="hh"
#------------------------------------------------------------------------------
# wrap-bison -output=...
unset outputFile optDryRun optRemoveTmp m4Flags
unset outputFile optDryRun optGrammar optRemoveTmp m4Flags
while [ "$#" -gt 0 ]
do
case "$1" in
(-h | -help*) usage ;;
(-dry-run) optDryRun=true ;;
(-gram*) optGrammar=true ;; # currently ignored
(-no-tmp) optRemoveTmp=true ;;
(-output=*) outputFile="${1#*=}" ;;

View File

@ -6,7 +6,7 @@
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#-------------------------------------------------------------------------------
# Copyright (C) 2019-2020 OpenCFD Ltd.
# Copyright (C) 2019-2021 OpenCFD Ltd.
#-------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -34,12 +34,10 @@ binDir="${WMAKE_BIN:-$WM_PROJECT_DIR/platforms/tools/$WM_ARCH$WM_COMPILER}"
etcDir="${WM_DIR:-$WM_PROJECT_DIR/wmake}/etc"
# Executable and skeleton locations
lemon="$binDir/lemon"
lemon="${binDir}/lemon"
skel="-T${etcDir}/lempar.c"
usage() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
printHelp() {
cat<<USAGE
Usage: ${0##*/} [options] [lemon args/options]
@ -47,6 +45,7 @@ Usage: ${0##*/} [options] [lemon args/options]
options:
-header Generate header only, suppressing other output
-dry-run Process m4 only (output on stdout)
-grammar Output grammar tables (stdout)
-no-tmp Do not retain temporary m4 processed files
-h, -help Print the usage
@ -56,7 +55,7 @@ the m4(1) macro processor and lemon will be called with 'm4' as a macro
definition, which can be used in conditions (%ifdef m4, %ifndef m4)
USAGE
exit 1
exit 0 # Clean exit
}
#------------------------------------------------------------------------------
@ -64,14 +63,15 @@ USAGE
#------------------------------------------------------------------------------
# Eg, wrap-lemon -header
unset optHeader optDryRun optRemoveTmp m4Flags
unset optDryRun optHeader optGrammar optRemoveTmp m4Flags
while [ "$#" -gt 0 ]
do
case "$1" in
(-h | -help*) usage ;;
(-h | -help*) printHelp ;;
(-head*) optHeader=true ;;
(-dry-run) optDryRun=true ;;
(-head*) optHeader=true ;;
(-gram*) optGrammar=true ;;
(-no-tmp) optRemoveTmp=true ;;
(*) break ;;
@ -163,6 +163,12 @@ case "$parser" in
;;
esac
if [ -n "$optGrammar" ]
then
parserFlags="${parserFlags}${parserFlags:+ }-g"
fi
exitCode=0 # No failures
#------------------------------------------------------------------------------
@ -188,6 +194,8 @@ unset tmpFile tmpDir
if [ -n "$optHeader" ]
then
## echo "${0##*/} : generate header" 1>&2
# Drop last argument (the parser input file)
set -- "${@:1:${#}-1}"
@ -196,8 +204,7 @@ then
rm -rf "$tmpDir" 2>/dev/null
mkdir "$tmpDir" 2>/dev/null
# We may want this:
# trap 'rm -f $tmpDir 2>/dev/null; exit $exitCode' EXIT TERM INT
trap 'rm -rf $tmpDir; exit $exitCode' EXIT TERM INT
if [ "$usingM4" = true ]
then
@ -236,10 +243,10 @@ then
done
fi
rm -rf "$tmpDir" 2>/dev/null
elif [ "$usingM4" = true ]
then
## echo "${0##*/} : generate code (with m4 filtering)" 1>&2
# Drop last argument (the parser input file)
set -- "${@:1:${#}-1}"
@ -252,8 +259,10 @@ then
fi
tmpFile="${tmpFile%.*}$extParser" # Eg, from .lyy-m4 -> .lyy
# We may want this:
# trap 'rm -f $tmpFile 2>/dev/null; exit $exitCode' EXIT TERM INT
if [ -n "$optRemoveTmp" ]
then
trap 'rm -f $tmpFile; exit $exitCode' EXIT TERM INT
fi
if m4 $m4Flags "$parser" > "$tmpFile" && [ -f "$tmpFile" ]
then
@ -264,16 +273,16 @@ then
exitCode=1
fi
if [ -n "$optRemoveTmp" ]
if [ -z "$optRemoveTmp" ]
then
rm -f "$tmpFile" 2>/dev/null
else
echo 2>/dev/null
echo "Retaining intermediate: $tmpFile" 2>/dev/null
fi
else
# No special handling
## echo "${0##*/} : generate code" 1>&2
"$lemon" "$skel" "$@"
exitCode=$?

View File

@ -1,7 +1,9 @@
/*
* https://www.sqlite.org/src/artifact/70eedc31
* Artifact 70eedc31614a58fe31a71025c17ebd1502a6ce9cfef0ed5e33acb0b5b737b291:
* File tool/lemon.c part of check-in [4591ee03] at 2020-09-21
/* OPENFOAM note
*
* https://sqlite.org/src/raw/
* https://www.sqlite.org/src/artifact/25888183
* Artifact 258881835bd5bccd0c74fb110fe54244ff18e8e7ef3d949cbdab7187f02132bb:
* File tool/lemon.c part of check-in [f2f279b2]] at 2021-10-04
*/
/*
** This file contains all sources (including headers) to the LEMON
@ -406,7 +408,7 @@ struct lemon {
struct symbol *errsym; /* The error symbol */
struct symbol *wildcard; /* Token that matches anything */
char *name; /* Name of the generated parser */
char *arg; /* Declaration of the 3th argument to parser */
char *arg; /* Declaration of the 3rd argument to parser */
char *ctx; /* Declaration of 2nd argument to constructor */
char *tokentype; /* Type of terminal symbols in the parser stack */
char *vartype; /* The default type of non-terminal symbols */
@ -923,8 +925,11 @@ void FindStates(struct lemon *lemp)
lemp->errorcnt++;
sp = lemp->startRule->lhs;
}
}else{
}else if( lemp->startRule ){
sp = lemp->startRule->lhs;
}else{
ErrorMsg(lemp->filename,0,"Internal error - no start rule\n");
exit(1);
}
/* Make sure the start symbol doesn't occur on the right-hand side of
@ -1033,7 +1038,7 @@ PRIVATE void buildshifts(struct lemon *lemp, struct state *stp)
struct symbol *bsp; /* Symbol following the dot in configuration "bcfp" */
struct state *newstp; /* A pointer to a successor state */
/* Each configuration becomes complete after it contibutes to a successor
/* Each configuration becomes complete after it contributes to a successor
** state. Initially, all configurations are incomplete */
for(cfp=stp->cfp; cfp; cfp=cfp->next) cfp->status = INCOMPLETE;
@ -1089,7 +1094,7 @@ void FindLinks(struct lemon *lemp)
** which the link is attached. */
for(i=0; i<lemp->nstate; i++){
stp = lemp->sorted[i];
for(cfp=stp->cfp; cfp; cfp=cfp->next){
for(cfp=stp?stp->cfp:0; cfp; cfp=cfp->next){
cfp->stp = stp;
}
}
@ -1098,7 +1103,7 @@ void FindLinks(struct lemon *lemp)
** links are used in the follow-set computation. */
for(i=0; i<lemp->nstate; i++){
stp = lemp->sorted[i];
for(cfp=stp->cfp; cfp; cfp=cfp->next){
for(cfp=stp?stp->cfp:0; cfp; cfp=cfp->next){
for(plp=cfp->bplp; plp; plp=plp->next){
other = plp->cfp;
Plink_add(&other->fplp,cfp);
@ -1121,6 +1126,7 @@ void FindFollowSets(struct lemon *lemp)
int change;
for(i=0; i<lemp->nstate; i++){
assert( lemp->sorted[i]!=0 );
for(cfp=lemp->sorted[i]->cfp; cfp; cfp=cfp->next){
cfp->status = INCOMPLETE;
}
@ -1129,6 +1135,7 @@ void FindFollowSets(struct lemon *lemp)
do{
progress = 0;
for(i=0; i<lemp->nstate; i++){
assert( lemp->sorted[i]!=0 );
for(cfp=lemp->sorted[i]->cfp; cfp; cfp=cfp->next){
if( cfp->status==COMPLETE ) continue;
for(plp=cfp->fplp; plp; plp=plp->next){
@ -1178,7 +1185,14 @@ void FindActions(struct lemon *lemp)
/* Add the accepting token */
if( lemp->start ){
sp = Symbol_find(lemp->start);
if( sp==0 ) sp = lemp->startRule->lhs;
if( sp==0 ){
if( lemp->startRule==0 ){
fprintf(stderr, "internal error on source line %d: no start rule\n",
__LINE__);
exit(1);
}
sp = lemp->startRule->lhs;
}
}else{
sp = lemp->startRule->lhs;
}
@ -1305,21 +1319,7 @@ static struct config **basisend = 0; /* End of list of basis configs */
/* Return a pointer to a new configuration */
PRIVATE struct config *newconfig(void){
struct config *newcfg;
if( freelist==0 ){
int i;
int amt = 3;
freelist = (struct config *)calloc( amt, sizeof(struct config) );
if( freelist==0 ){
fprintf(stderr,"Unable to allocate memory for a new configuration.");
exit(1);
}
for(i=0; i<amt-1; i++) freelist[i].next = &freelist[i+1];
freelist[amt-1].next = 0;
}
newcfg = freelist;
freelist = freelist->next;
return newcfg;
return (struct config*)calloc(1, sizeof(struct config));
}
/* The configuration "old" is no longer used */
@ -1549,7 +1549,7 @@ static void handle_D_option(char *z){
*z = 0;
}
/* Remember the name of the output directory
/* Rember the name of the output directory
*/
static char *outputDir = NULL;
static void handle_d_option(char *z){
@ -1912,7 +1912,7 @@ static char *merge(
**
** Return Value:
** A pointer to the head of a sorted list containing the elements
** orginally in list.
** originally in list.
**
** Side effects:
** The "next" pointers for elements in list are changed.
@ -1957,8 +1957,12 @@ static FILE *errstream;
static void errline(int n, int k, FILE *err)
{
int spcnt, i;
if( g_argv[0] ) fprintf(err,"%s",g_argv[0]);
spcnt = lemonStrlen(g_argv[0]) + 1;
if( g_argv[0] ){
fprintf(err,"%s",g_argv[0]);
spcnt = lemonStrlen(g_argv[0]) + 1;
}else{
spcnt = 0;
}
for(i=1; i<n && g_argv[i]; i++){
fprintf(err," %s",g_argv[i]);
spcnt += lemonStrlen(g_argv[i])+1;
@ -2739,7 +2743,7 @@ static void parseonetoken(struct pstate *psp)
** in order to control their assigned integer number. The number for
** each token is assigned when it is first seen. So by including
**
** %token ONE TWO THREE
** %token ONE TWO THREE.
**
** early in the grammar file, that assigns small consecutive values
** to each of the tokens ONE TWO and THREE.
@ -3544,7 +3548,7 @@ void ReportOutput(struct lemon *lemp)
}
/* Search for the file "name" which is in the same directory as
** the exacutable */
** the executable */
PRIVATE char *pathsearch(char *argv0, char *name, int modemask)
{
const char *pathlist;
@ -3602,7 +3606,9 @@ PRIVATE int compute_action(struct lemon *lemp, struct action *ap)
/* Since a SHIFT is inherient after a prior REDUCE, convert any
** SHIFTREDUCE action with a nonterminal on the LHS into a simple
** REDUCE action: */
if( ap->sp->index>=lemp->nterminal ){
if( ap->sp->index>=lemp->nterminal
&& (lemp->errsym==0 || ap->sp->index!=lemp->errsym->index)
){
act = lemp->minReduce + ap->x.rp->iRule;
}else{
act = lemp->minShiftReduce + ap->x.rp->iRule;
@ -3899,7 +3905,7 @@ PRIVATE int translate_code(struct lemon *lemp, struct rule *rp){
lhsdirect = 1;
}else if( rp->rhsalias[0]==0 ){
/* The left-most RHS symbol has no value. LHS direct is ok. But
** we have to call the distructor on the RHS symbol first. */
** we have to call the destructor on the RHS symbol first. */
lhsdirect = 1;
if( has_destructor(rp->rhs[0],lemp) ){
append_str(0,0,0,0);
@ -4121,7 +4127,7 @@ void print_stack_union(
int *plineno, /* Pointer to the line number */
int mhflag /* True if generating makeheaders output */
){
int lineno = *plineno; /* The line number of the output */
int lineno; /* The line number of the output */
char **types; /* A hash table of datatypes */
int arraysize; /* Size of the "types" array */
int maxdtlength; /* Maximum length of any ".datatype" field. */
@ -4883,7 +4889,7 @@ void ReportTable(
** yyRuleInfoNRhs[].
**
** Note: This code depends on the fact that rules are number
** sequentually beginning with 0.
** sequentially beginning with 0.
*/
for(i=0, rp=lemp->rule; rp; rp=rp->next, i++){
fprintf(out," %4d, /* (%d) ", rp->lhs->index, i);
@ -5371,7 +5377,8 @@ int Strsafe_insert(const char *data)
newnp->from = &(array.ht[h]);
array.ht[h] = newnp;
}
free(x1a->tbl);
/* free(x1a->tbl); // This program was originally for 16-bit machines.
** Don't worry about freeing memory on modern platforms. */
*x1a = array;
}
/* Insert the new data */
@ -5539,7 +5546,9 @@ int Symbol_insert(struct symbol *data, const char *key)
newnp->from = &(array.ht[h]);
array.ht[h] = newnp;
}
free(x2a->tbl);
/* free(x2a->tbl); // This program was originally written for 16-bit
** machines. Don't worry about freeing this trivial amount of memory
** on modern platforms. Just leak it. */
*x2a = array;
}
/* Insert the new data */
@ -5875,7 +5884,9 @@ int Configtable_insert(struct config *data)
newnp->from = &(array.ht[h]);
array.ht[h] = newnp;
}
free(x4a->tbl);
/* free(x4a->tbl); // This code was originall written for 16-bit machines.
** on modern machines, don't worry about freeing this trival amount of
** memory. */
*x4a = array;
}
/* Insert the new data */

41
wmake/src/lemon.help.txt Normal file
View File

@ -0,0 +1,41 @@
# Snippets for documentation
3.1 Command-line options:
* -eextension
Output code extension, the default is 'c'.
Changing this will not change the type of code generated (it will
still be C) but it does allow triggering of different make rules
or diffferent compiler types.
3.2.2 Interface Summary
Notes:
* Use the %name directive to change the "Parse" prefix names of the
procedures in the interface.
* Use the %static directive to change the interface type defined by
YYFUNCAPI to file `static` linkage. This can be useful if the entire
parser code is to be locally wrapped inside of a different caller.
4.4 Special directives
* %static
4.4.xxx The %static directive
By default, the functions generated by Lemon are exposed as globally
visible symbols. You can change this by specifying the %static
directive.
This places parser routines in a static (ie, file-local) scope so that
they are not visible outside of the compilation unit. The parser
routines will then be wrapped with some other type of mechanism.

View File

@ -10,20 +10,7 @@
# Copyright (C) 2017-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
# OpenFOAM 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 3 of the License, or
# (at your option) any later version.
#
# OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# wclean

View File

@ -9,20 +9,7 @@
# Copyright (C) 2011-2016 OpenFOAM Foundation
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
# OpenFOAM 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 3 of the License, or
# (at your option) any later version.
#
# OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# wcleanLnIncludeAll

View File

@ -10,20 +10,7 @@
# Copyright (C) 2017 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
# OpenFOAM 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 3 of the License, or
# (at your option) any later version.
#
# OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# wdep
@ -39,7 +26,7 @@
#
#------------------------------------------------------------------------------
Script=${0##*/} # Use 'Script' for error messages in wmakeFunctions
. ${0%/*}/scripts/wmakeFunctions # Source wmake functions
. "${0%/*}"/scripts/wmakeFunctions # Source wmake functions
usage() {
exec 1>&2
@ -84,7 +71,7 @@ fi
# Check environment variables
checkEnv
sourceFile=$1
sourceFile="$1"
#------------------------------------------------------------------------------
# Check <file> is in the current directory,

View File

@ -10,20 +10,7 @@
# Copyright (C) 2017-2021 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
# OpenFOAM 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 3 of the License, or
# (at your option) any later version.
#
# OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# wmake

View File

@ -9,20 +9,7 @@
# Copyright (C) 2016 OpenFOAM Foundation
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
# OpenFOAM 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 3 of the License, or
# (at your option) any later version.
#
# OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# wmakeCollect
@ -95,7 +82,7 @@ done
if [ -z "$WM_COLLECT_DIR" ]
then
echo "$Script error: WM_COLLECT_DIR not set"
echo "$Script error: WM_COLLECT_DIR not set" 1>&2
exit 1
fi
@ -143,7 +130,7 @@ then
echo -e "\t$E cd $PWD && \\" >> $file
echo -e "\t${@:1:($#-1)} $objectFile" >> $file
echo >> $file
elif [ -d $WM_COLLECT_DIR ]
elif [ -d "$WM_COLLECT_DIR" ]
then
# Collect all the makefiles into a single makefiles for this build
(cd $WM_COLLECT_DIR && ls -1rt | xargs cat > $makefile)

View File

@ -10,20 +10,7 @@
# Copyright (C) 2018-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
# OpenFOAM 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 3 of the License, or
# (at your option) any later version.
#
# OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# wmakeLnIncludeAll

View File

@ -10,22 +10,10 @@
# Copyright (C) 2017-2019 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# OpenFOAM 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 3 of the License, or
# (at your option) any later version.
#
# OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
#
# Script wrmdep
# Script
# wrmdep
#
# Usage
# wrmdep [-a | -all | all] [file1 [..fileN]]
@ -180,7 +168,7 @@ oldFolders)
find "$objectsDir" -name '*.dep' -type f -print | while read depFile
do
sourceFile=$(depToSource "$depFile")
sourceFile="$(depToSource "$depFile")"
# Check C++ or Flex source file exists
if [ ! -r "$sourceFile" ]

View File

@ -10,20 +10,7 @@
# Copyright (C) 2017-2019 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
# OpenFOAM 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 3 of the License, or
# (at your option) any later version.
#
# OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# wrmo