From ed00a6673cd7a27c05c78952937a20406af5b4f0 Mon Sep 17 00:00:00 2001 From: Ladislav Michl Date: Mon, 7 Apr 2025 16:31:57 +0200 Subject: [PATCH] Base: Quantity: rename lexer and parser files Rename files according 7d233dc ("Gui: Rename generated lexer files to match core naming pattern"). Note that C space errors (space before tabs, spaces on blank lines, etc.) still need to be fixed manually after regenerating lexer file. --- src/Base/CMakeLists.txt | 4 +- src/Base/Parser.bat | 4 +- src/Base/Parser.sh | 8 +- src/Base/Quantity.cpp | 8 +- src/Base/{QuantityParser.l => Quantity.l} | 7 - src/Base/{QuantityLexer.c => Quantity.lex.c} | 374 +++-- src/Base/{QuantityParser.c => Quantity.tab.c} | 1332 ++++++++--------- src/Base/{QuantityParser.y => Quantity.y} | 0 src/Base/QuantityParser.h | 85 -- 9 files changed, 806 insertions(+), 1016 deletions(-) rename src/Base/{QuantityParser.l => Quantity.l} (97%) rename src/Base/{QuantityLexer.c => Quantity.lex.c} (91%) rename src/Base/{QuantityParser.c => Quantity.tab.c} (54%) rename src/Base/{QuantityParser.y => Quantity.y} (100%) delete mode 100644 src/Base/QuantityParser.h diff --git a/src/Base/CMakeLists.txt b/src/Base/CMakeLists.txt index 58c8d3c0d3..c7ef083eea 100644 --- a/src/Base/CMakeLists.txt +++ b/src/Base/CMakeLists.txt @@ -167,8 +167,8 @@ SET(FreeCADBase_UNITAPI_SRCS Quantity.h Quantity.cpp QuantityPyImp.cpp - QuantityParser.l - QuantityParser.y + Quantity.l + Quantity.y Unit.h Unit.cpp UnitPyImp.cpp diff --git a/src/Base/Parser.bat b/src/Base/Parser.bat index d5620b88f4..6b67cd3d76 100644 --- a/src/Base/Parser.bat +++ b/src/Base/Parser.bat @@ -1,2 +1,2 @@ -C:\cygwin\bin\flex.exe -oQuantityLexer.c QuantityParser.l -C:\cygwin\bin\bison -oQuantityParser.c QuantityParser.y +C:\cygwin\bin\flex.exe -oQuantity.lex.c Quantity.l +C:\cygwin\bin\bison -oQuantity.tab.c Quantity.y diff --git a/src/Base/Parser.sh b/src/Base/Parser.sh index c82c9b8cb7..2e7d75aaf3 100644 --- a/src/Base/Parser.sh +++ b/src/Base/Parser.sh @@ -1,2 +1,6 @@ -flex -oQuantityLexer.c < QuantityParser.l -bison -oQuantityParser.c QuantityParser.y +(cd "$(dirname "$0")" && \ + flex -oQuantity.lex.c Quantity.l && \ + bison -oQuantity.tab.c Quantity.y && \ + sed -i '1s|^|// clang-format off\n|' Quantity.tab.c && \ + sed -i '1s|^|// clang-format off\n|' Quantity.lex.c \ +) diff --git a/src/Base/Quantity.cpp b/src/Base/Quantity.cpp index 1b25793824..e5102dbb16 100644 --- a/src/Base/Quantity.cpp +++ b/src/Base/Quantity.cpp @@ -523,14 +523,14 @@ namespace QuantityParser #define yylex QuantityLexer int QuantityLexer(); -// Parser, defined in QuantityParser.y +// Parser, defined in Quantity.y // NOLINTNEXTLINE -#include "QuantityParser.c" +#include "Quantity.tab.c" #ifndef DOXYGEN_SHOULD_SKIP_THIS -// Scanner, defined in QuantityParser.l +// Scanner, defined in Quantity.l // NOLINTNEXTLINE -#include "QuantityLexer.c" +#include "Quantity.lex.c" #endif // DOXYGEN_SHOULD_SKIP_THIS class StringBufferCleaner diff --git a/src/Base/QuantityParser.l b/src/Base/Quantity.l similarity index 97% rename from src/Base/QuantityParser.l rename to src/Base/Quantity.l index 1daf9a4e25..08d0c03fd4 100644 --- a/src/Base/QuantityParser.l +++ b/src/Base/Quantity.l @@ -21,13 +21,6 @@ /* Lexer for the FreeCAD Units language */ -/* use this file to generate the file 'QuantityLexer.c' using the program flex - * the command for this operation is: - * flex --outfile=QuantityLexer.c QuantityParser.l - * (flex for Windows is available here: - * https://sourceforge.net/projects/winflexbison/ - * (you must then change 'flex' to 'win_flex' in the command)) */ - /* This disables inclusion of unistd.h, which is not available under Visual C++ * on Win32. The C++ scanner uses STL streams instead. */ #define YY_NO_UNISTD_H diff --git a/src/Base/QuantityLexer.c b/src/Base/Quantity.lex.c similarity index 91% rename from src/Base/QuantityLexer.c rename to src/Base/Quantity.lex.c index 547916b50b..8a645130a6 100644 --- a/src/Base/QuantityLexer.c +++ b/src/Base/Quantity.lex.c @@ -1,7 +1,7 @@ // clang-format off -#line 1 "QuantityLexer.c" +#line 2 "Quantity.lex.c" -#line 3 "QuantityLexer.c" +#line 4 "Quantity.lex.c" #define YY_INT_ALIGNED short int @@ -627,8 +627,8 @@ int yy_flex_debug = 0; #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET char *yytext; -#line 1 "QuantityParser.l" -#line 2 "QuantityParser.l" +#line 1 "Quantity.l" +#line 2 "Quantity.l" /*************************************************************************** * Copyright (c) 2013 Jürgen Riegel * * * @@ -651,23 +651,16 @@ char *yytext; /* Lexer for the FreeCAD Units language */ -/* use this file to generate the file 'QuantityLexer.c' using the program flex - * the command for this operation is: - * flex --outfile=QuantityLexer.c QuantityParser.l - * (flex for Windows is available here: - * https://sourceforge.net/projects/winflexbison/ - * (you must then change 'flex' to 'win_flex' in the command)) */ - /* This disables inclusion of unistd.h, which is not available under Visual C++ * on Win32. The C++ scanner uses STL streams instead. */ #define YY_NO_UNISTD_H -#line 664 "QuantityLexer.c" +#line 658 "Quantity.lex.c" /*** Flex Declarations and Options ***/ /* the manual says "somewhat more optimized" */ /* no support for include files is planned */ -#line 669 "QuantityLexer.c" +#line 663 "Quantity.lex.c" #define INITIAL 0 #define C_COMMENT 1 @@ -883,10 +876,10 @@ YY_DECL } { -#line 56 "QuantityParser.l" +#line 49 "Quantity.l" -#line 888 "QuantityLexer.c" +#line 882 "Quantity.lex.c" while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { @@ -941,776 +934,776 @@ do_action: /* This label is used only to access EOF actions. */ case 1: YY_RULE_SETUP -#line 58 "QuantityParser.l" +#line 51 "Quantity.l" { BEGIN(C_COMMENT); } YY_BREAK case 2: YY_RULE_SETUP -#line 59 "QuantityParser.l" +#line 52 "Quantity.l" { BEGIN(INITIAL); } YY_BREAK case 3: YY_RULE_SETUP -#line 60 "QuantityParser.l" +#line 53 "Quantity.l" { ;} YY_BREAK case 4: YY_RULE_SETUP -#line 63 "QuantityParser.l" +#line 56 "Quantity.l" ; YY_BREAK case 5: /* rule 5 can match eol */ YY_RULE_SETUP -#line 64 "QuantityParser.l" +#line 57 "Quantity.l" ; YY_BREAK case 6: YY_RULE_SETUP -#line 66 "QuantityParser.l" -{ return *yytext; } +#line 59 "Quantity.l" +return *yytext; YY_BREAK case 7: YY_RULE_SETUP -#line 68 "QuantityParser.l" +#line 61 "Quantity.l" return MINUSSIGN; YY_BREAK case 8: YY_RULE_SETUP -#line 69 "QuantityParser.l" +#line 62 "Quantity.l" return MINUSSIGN; YY_BREAK case 9: YY_RULE_SETUP -#line 71 "QuantityParser.l" +#line 64 "Quantity.l" yylval = Quantity::NanoMetre; return UNIT; // nano meter YY_BREAK case 10: YY_RULE_SETUP -#line 72 "QuantityParser.l" +#line 65 "Quantity.l" yylval = Quantity::MicroMetre; return UNIT; // micro meter YY_BREAK case 11: YY_RULE_SETUP -#line 73 "QuantityParser.l" +#line 66 "Quantity.l" yylval = Quantity::MicroMetre; return UNIT; // micro meter (greek micro in UTF8) YY_BREAK case 12: YY_RULE_SETUP -#line 74 "QuantityParser.l" +#line 67 "Quantity.l" yylval = Quantity::MilliMetre; return UNIT; // milli meter (internal standard length) YY_BREAK case 13: YY_RULE_SETUP -#line 75 "QuantityParser.l" +#line 68 "Quantity.l" yylval = Quantity::CentiMetre; return UNIT; // centi meter YY_BREAK case 14: YY_RULE_SETUP -#line 76 "QuantityParser.l" +#line 69 "Quantity.l" yylval = Quantity::DeciMetre; return UNIT; // deci meter YY_BREAK case 15: YY_RULE_SETUP -#line 77 "QuantityParser.l" +#line 70 "Quantity.l" yylval = Quantity::Metre; return UNIT; // Metre YY_BREAK case 16: YY_RULE_SETUP -#line 78 "QuantityParser.l" +#line 71 "Quantity.l" yylval = Quantity::KiloMetre; return UNIT; // kilo meter YY_BREAK case 17: YY_RULE_SETUP -#line 80 "QuantityParser.l" +#line 73 "Quantity.l" yylval = Quantity::Liter; return UNIT; // Liter (dm^3) YY_BREAK case 18: YY_RULE_SETUP -#line 81 "QuantityParser.l" +#line 74 "Quantity.l" yylval = Quantity::MilliLiter; return UNIT; // milli Liter YY_BREAK case 19: YY_RULE_SETUP -#line 83 "QuantityParser.l" +#line 76 "Quantity.l" yylval = Quantity::Hertz; return UNIT; // Hertz YY_BREAK case 20: YY_RULE_SETUP -#line 84 "QuantityParser.l" +#line 77 "Quantity.l" yylval = Quantity::KiloHertz; return UNIT; // kilo Hertz YY_BREAK case 21: YY_RULE_SETUP -#line 85 "QuantityParser.l" +#line 78 "Quantity.l" yylval = Quantity::MegaHertz; return UNIT; // mega Hertz YY_BREAK case 22: YY_RULE_SETUP -#line 86 "QuantityParser.l" +#line 79 "Quantity.l" yylval = Quantity::GigaHertz; return UNIT; // giga Hertz YY_BREAK case 23: YY_RULE_SETUP -#line 87 "QuantityParser.l" +#line 80 "Quantity.l" yylval = Quantity::TeraHertz; return UNIT; // tera Hertz YY_BREAK case 24: YY_RULE_SETUP -#line 89 "QuantityParser.l" +#line 82 "Quantity.l" yylval = Quantity::MicroGram; return UNIT; // micro gram YY_BREAK case 25: YY_RULE_SETUP -#line 90 "QuantityParser.l" +#line 83 "Quantity.l" yylval = Quantity::MicroGram; return UNIT; // micro gram YY_BREAK case 26: YY_RULE_SETUP -#line 91 "QuantityParser.l" +#line 84 "Quantity.l" yylval = Quantity::MilliGram; return UNIT; // milli gram YY_BREAK case 27: YY_RULE_SETUP -#line 92 "QuantityParser.l" +#line 85 "Quantity.l" yylval = Quantity::Gram; return UNIT; // gram YY_BREAK case 28: YY_RULE_SETUP -#line 93 "QuantityParser.l" +#line 86 "Quantity.l" yylval = Quantity::KiloGram; return UNIT; // kilo gram (internal standard for mass) YY_BREAK case 29: YY_RULE_SETUP -#line 94 "QuantityParser.l" +#line 87 "Quantity.l" yylval = Quantity::Ton; return UNIT; // Metric Tonne YY_BREAK case 30: YY_RULE_SETUP -#line 96 "QuantityParser.l" +#line 89 "Quantity.l" yylval = Quantity::Second; return UNIT; // second (internal standard time) YY_BREAK case 31: YY_RULE_SETUP -#line 97 "QuantityParser.l" +#line 90 "Quantity.l" yylval = Quantity::Minute; return UNIT; // minute YY_BREAK case 32: YY_RULE_SETUP -#line 98 "QuantityParser.l" +#line 91 "Quantity.l" yylval = Quantity::Hour; return UNIT; // hour YY_BREAK case 33: YY_RULE_SETUP -#line 100 "QuantityParser.l" +#line 93 "Quantity.l" yylval = Quantity::Ampere; return UNIT; // Ampere (internal standard electric current) YY_BREAK case 34: YY_RULE_SETUP -#line 101 "QuantityParser.l" +#line 94 "Quantity.l" yylval = Quantity::MilliAmpere; return UNIT; // milli Ampere YY_BREAK case 35: YY_RULE_SETUP -#line 102 "QuantityParser.l" +#line 95 "Quantity.l" yylval = Quantity::KiloAmpere; return UNIT; // kilo Ampere YY_BREAK case 36: YY_RULE_SETUP -#line 103 "QuantityParser.l" +#line 96 "Quantity.l" yylval = Quantity::MegaAmpere; return UNIT; // mega Ampere YY_BREAK case 37: YY_RULE_SETUP -#line 105 "QuantityParser.l" +#line 98 "Quantity.l" yylval = Quantity::Kelvin; return UNIT; // Kelvin (internal standard thermodynamic temperature) YY_BREAK case 38: YY_RULE_SETUP -#line 106 "QuantityParser.l" +#line 99 "Quantity.l" yylval = Quantity::MilliKelvin; return UNIT; // milli Kelvin YY_BREAK case 39: YY_RULE_SETUP -#line 107 "QuantityParser.l" +#line 100 "Quantity.l" yylval = Quantity::MicroKelvin; return UNIT; // micro Kelvin YY_BREAK case 40: YY_RULE_SETUP -#line 108 "QuantityParser.l" +#line 101 "Quantity.l" yylval = Quantity::MicroKelvin; return UNIT; // micro Kelvin YY_BREAK case 41: YY_RULE_SETUP -#line 110 "QuantityParser.l" +#line 103 "Quantity.l" yylval = Quantity::Mole; return UNIT; // Mole (internal standard amount of substance) YY_BREAK case 42: YY_RULE_SETUP -#line 111 "QuantityParser.l" +#line 104 "Quantity.l" yylval = Quantity::MilliMole; return UNIT; // Milli Mole YY_BREAK case 43: YY_RULE_SETUP -#line 113 "QuantityParser.l" +#line 106 "Quantity.l" yylval = Quantity::Candela; return UNIT; // Candela (internal standard luminous intensity) YY_BREAK case 44: YY_RULE_SETUP -#line 115 "QuantityParser.l" +#line 108 "Quantity.l" yylval = Quantity::Inch; return UNIT; // inch YY_BREAK case 45: YY_RULE_SETUP -#line 116 "QuantityParser.l" +#line 109 "Quantity.l" yylval = Quantity::Inch; return UNIT; // inch YY_BREAK case 46: YY_RULE_SETUP -#line 117 "QuantityParser.l" +#line 110 "Quantity.l" yylval = Quantity::Foot; return UNIT; // foot YY_BREAK case 47: YY_RULE_SETUP -#line 118 "QuantityParser.l" +#line 111 "Quantity.l" yylval = Quantity::Foot; return UNIT; // foot YY_BREAK case 48: YY_RULE_SETUP -#line 119 "QuantityParser.l" +#line 112 "Quantity.l" yylval = Quantity::Thou; return UNIT; // thou (in/1000) YY_BREAK case 49: YY_RULE_SETUP -#line 120 "QuantityParser.l" +#line 113 "Quantity.l" yylval = Quantity::Thou; return UNIT; // mil (the thou in US) YY_BREAK case 50: YY_RULE_SETUP -#line 121 "QuantityParser.l" +#line 114 "Quantity.l" yylval = Quantity::Yard; return UNIT; // yard YY_BREAK case 51: YY_RULE_SETUP -#line 122 "QuantityParser.l" +#line 115 "Quantity.l" yylval = Quantity::Mile; return UNIT; // mile YY_BREAK case 52: YY_RULE_SETUP -#line 124 "QuantityParser.l" +#line 117 "Quantity.l" yylval = Quantity::MilePerHour; return UNIT; // mile per hour YY_BREAK case 53: YY_RULE_SETUP -#line 125 "QuantityParser.l" +#line 118 "Quantity.l" yylval = Quantity::SquareFoot; return UNIT; // square foot YY_BREAK case 54: YY_RULE_SETUP -#line 126 "QuantityParser.l" +#line 119 "Quantity.l" yylval = Quantity::CubicFoot; return UNIT; // cubic foot YY_BREAK case 55: YY_RULE_SETUP -#line 128 "QuantityParser.l" +#line 121 "Quantity.l" yylval = Quantity::Pound; return UNIT; // pound YY_BREAK case 56: YY_RULE_SETUP -#line 129 "QuantityParser.l" +#line 122 "Quantity.l" yylval = Quantity::Pound; return UNIT; // pound YY_BREAK case 57: YY_RULE_SETUP -#line 130 "QuantityParser.l" +#line 123 "Quantity.l" yylval = Quantity::Ounce; return UNIT; // ounce YY_BREAK case 58: YY_RULE_SETUP -#line 131 "QuantityParser.l" +#line 124 "Quantity.l" yylval = Quantity::Stone; return UNIT; // Stone YY_BREAK case 59: YY_RULE_SETUP -#line 132 "QuantityParser.l" +#line 125 "Quantity.l" yylval = Quantity::Hundredweights; return UNIT; // hundredweights YY_BREAK case 60: YY_RULE_SETUP -#line 134 "QuantityParser.l" +#line 127 "Quantity.l" yylval = Quantity::PoundForce; return UNIT; // pound YY_BREAK case 61: YY_RULE_SETUP -#line 136 "QuantityParser.l" +#line 129 "Quantity.l" yylval = Quantity::Newton; return UNIT; // Newton (kg*m/s^2) YY_BREAK case 62: YY_RULE_SETUP -#line 137 "QuantityParser.l" +#line 130 "Quantity.l" yylval = Quantity::MilliNewton; return UNIT; // milli Newton YY_BREAK case 63: YY_RULE_SETUP -#line 138 "QuantityParser.l" +#line 131 "Quantity.l" yylval = Quantity::KiloNewton; return UNIT; // kilo Newton YY_BREAK case 64: YY_RULE_SETUP -#line 139 "QuantityParser.l" +#line 132 "Quantity.l" yylval = Quantity::MegaNewton; return UNIT; // mega Newton YY_BREAK case 65: YY_RULE_SETUP -#line 141 "QuantityParser.l" +#line 134 "Quantity.l" yylval = Quantity::Pascal; return UNIT; // Pascal (kg/m/s^2 or N/m^2) YY_BREAK case 66: YY_RULE_SETUP -#line 142 "QuantityParser.l" +#line 135 "Quantity.l" yylval = Quantity::KiloPascal; return UNIT; // kilo Pascal YY_BREAK case 67: YY_RULE_SETUP -#line 143 "QuantityParser.l" +#line 136 "Quantity.l" yylval = Quantity::MegaPascal; return UNIT; // mega Pascal YY_BREAK case 68: YY_RULE_SETUP -#line 144 "QuantityParser.l" +#line 137 "Quantity.l" yylval = Quantity::GigaPascal; return UNIT; // giga Pascal YY_BREAK case 69: YY_RULE_SETUP -#line 146 "QuantityParser.l" +#line 139 "Quantity.l" yylval = Quantity::Bar; return UNIT; // 1 bar = 100 kPa YY_BREAK case 70: YY_RULE_SETUP -#line 147 "QuantityParser.l" +#line 140 "Quantity.l" yylval = Quantity::MilliBar; return UNIT; // milli Bar YY_BREAK case 71: YY_RULE_SETUP -#line 149 "QuantityParser.l" +#line 142 "Quantity.l" yylval = Quantity::Torr; return UNIT; // portion of Pascal ( 101325/760 ) YY_BREAK case 72: YY_RULE_SETUP -#line 150 "QuantityParser.l" +#line 143 "Quantity.l" yylval = Quantity::mTorr; return UNIT; // YY_BREAK case 73: YY_RULE_SETUP -#line 151 "QuantityParser.l" +#line 144 "Quantity.l" yylval = Quantity::yTorr; return UNIT; // YY_BREAK case 74: YY_RULE_SETUP -#line 152 "QuantityParser.l" +#line 145 "Quantity.l" yylval = Quantity::yTorr; return UNIT; // YY_BREAK case 75: YY_RULE_SETUP -#line 154 "QuantityParser.l" +#line 147 "Quantity.l" yylval = Quantity::PSI; return UNIT; // pounds/in^2 YY_BREAK case 76: YY_RULE_SETUP -#line 155 "QuantityParser.l" +#line 148 "Quantity.l" yylval = Quantity::KSI; return UNIT; // 1000 x pounds/in^2 YY_BREAK case 77: YY_RULE_SETUP -#line 156 "QuantityParser.l" +#line 149 "Quantity.l" yylval = Quantity::MPSI; return UNIT; // 1000 ksi YY_BREAK case 78: YY_RULE_SETUP -#line 158 "QuantityParser.l" +#line 151 "Quantity.l" yylval = Quantity::Watt; return UNIT; // Watt (kg*m^2/s^3) YY_BREAK case 79: YY_RULE_SETUP -#line 159 "QuantityParser.l" +#line 152 "Quantity.l" yylval = Quantity::MilliWatt; return UNIT; // milli Watt YY_BREAK case 80: YY_RULE_SETUP -#line 160 "QuantityParser.l" +#line 153 "Quantity.l" yylval = Quantity::KiloWatt; return UNIT; // kilo Watt YY_BREAK case 81: YY_RULE_SETUP -#line 161 "QuantityParser.l" +#line 154 "Quantity.l" yylval = Quantity::VoltAmpere; return UNIT; // VoltAmpere (kg*m^2/s^3) YY_BREAK case 82: YY_RULE_SETUP -#line 163 "QuantityParser.l" +#line 156 "Quantity.l" yylval = Quantity::Volt; return UNIT; // Volt (kg*m^2/A/s^3) YY_BREAK case 83: YY_RULE_SETUP -#line 164 "QuantityParser.l" +#line 157 "Quantity.l" yylval = Quantity::KiloVolt; return UNIT; // kilo Volt YY_BREAK case 84: YY_RULE_SETUP -#line 165 "QuantityParser.l" +#line 158 "Quantity.l" yylval = Quantity::MilliVolt; return UNIT; // milli Volt YY_BREAK case 85: YY_RULE_SETUP -#line 167 "QuantityParser.l" +#line 160 "Quantity.l" yylval = Quantity::MegaSiemens; return UNIT; // mega Siemens YY_BREAK case 86: YY_RULE_SETUP -#line 168 "QuantityParser.l" +#line 161 "Quantity.l" yylval = Quantity::KiloSiemens; return UNIT; // kilo Siemens YY_BREAK case 87: YY_RULE_SETUP -#line 169 "QuantityParser.l" +#line 162 "Quantity.l" yylval = Quantity::Siemens; return UNIT; // Siemens (A^2*s^3/kg/m^2) YY_BREAK case 88: YY_RULE_SETUP -#line 170 "QuantityParser.l" +#line 163 "Quantity.l" yylval = Quantity::MilliSiemens; return UNIT; // milli Siemens YY_BREAK case 89: YY_RULE_SETUP -#line 171 "QuantityParser.l" -yylval = Quantity::MicroSiemens; return UNIT; // micro Siemens +#line 164 "Quantity.l" +yylval = Quantity::MicroSiemens; return UNIT; // micro Siemens YY_BREAK case 90: YY_RULE_SETUP -#line 172 "QuantityParser.l" +#line 165 "Quantity.l" yylval = Quantity::MicroSiemens; return UNIT; // micro Siemens YY_BREAK case 91: YY_RULE_SETUP -#line 174 "QuantityParser.l" +#line 167 "Quantity.l" yylval = Quantity::Ohm; return UNIT; // Ohm (kg*m^2/A^2/s^3) YY_BREAK case 92: YY_RULE_SETUP -#line 175 "QuantityParser.l" +#line 168 "Quantity.l" yylval = Quantity::KiloOhm; return UNIT; // kilo Ohm YY_BREAK case 93: YY_RULE_SETUP -#line 176 "QuantityParser.l" +#line 169 "Quantity.l" yylval = Quantity::MegaOhm; return UNIT; // mega Ohm YY_BREAK case 94: YY_RULE_SETUP -#line 178 "QuantityParser.l" +#line 171 "Quantity.l" yylval = Quantity::Coulomb; return UNIT; // Coulomb (A*s) YY_BREAK case 95: YY_RULE_SETUP -#line 180 "QuantityParser.l" +#line 173 "Quantity.l" yylval = Quantity::Tesla; return UNIT; // Tesla (kg/s^2/A) YY_BREAK case 96: YY_RULE_SETUP -#line 181 "QuantityParser.l" +#line 174 "Quantity.l" yylval = Quantity::Gauss; return UNIT; // Gauss (1 G = 1e-4 T) YY_BREAK case 97: YY_RULE_SETUP -#line 183 "QuantityParser.l" +#line 176 "Quantity.l" yylval = Quantity::Weber; return UNIT; // Weber (kg*m^2/s^2/A) YY_BREAK case 98: YY_RULE_SETUP -#line 185 "QuantityParser.l" +#line 178 "Quantity.l" yylval = Quantity::Farad; return UNIT; // Farad (s^4*A^2/m^2/kg) YY_BREAK case 99: YY_RULE_SETUP -#line 186 "QuantityParser.l" +#line 179 "Quantity.l" yylval = Quantity::MilliFarad; return UNIT; // milli Farad YY_BREAK case 100: YY_RULE_SETUP -#line 187 "QuantityParser.l" -yylval = Quantity::MicroFarad; return UNIT; // micro Farad +#line 180 "Quantity.l" +yylval = Quantity::MicroFarad; return UNIT; // micro Farad YY_BREAK case 101: YY_RULE_SETUP -#line 188 "QuantityParser.l" +#line 181 "Quantity.l" yylval = Quantity::MicroFarad; return UNIT; // micro Farad YY_BREAK case 102: YY_RULE_SETUP -#line 189 "QuantityParser.l" +#line 182 "Quantity.l" yylval = Quantity::NanoFarad; return UNIT; // nano Farad YY_BREAK case 103: YY_RULE_SETUP -#line 190 "QuantityParser.l" +#line 183 "Quantity.l" yylval = Quantity::PicoFarad; return UNIT; // pico Farad YY_BREAK case 104: YY_RULE_SETUP -#line 192 "QuantityParser.l" +#line 185 "Quantity.l" yylval = Quantity::Henry; return UNIT; // Henry (kg*m^2/s^2/A^2) YY_BREAK case 105: YY_RULE_SETUP -#line 193 "QuantityParser.l" +#line 186 "Quantity.l" yylval = Quantity::MilliHenry; return UNIT; // milli Henry YY_BREAK case 106: YY_RULE_SETUP -#line 194 "QuantityParser.l" -yylval = Quantity::MicroHenry; return UNIT; // micro Henry +#line 187 "Quantity.l" +yylval = Quantity::MicroHenry; return UNIT; // micro Henry YY_BREAK case 107: YY_RULE_SETUP -#line 195 "QuantityParser.l" +#line 188 "Quantity.l" yylval = Quantity::MicroHenry; return UNIT; // micro Henry YY_BREAK case 108: YY_RULE_SETUP -#line 196 "QuantityParser.l" +#line 189 "Quantity.l" yylval = Quantity::NanoHenry; return UNIT; // nano Henry YY_BREAK case 109: YY_RULE_SETUP -#line 198 "QuantityParser.l" +#line 191 "Quantity.l" yylval = Quantity::Joule; return UNIT; // Joule (kg*m^2/s^2) YY_BREAK case 110: YY_RULE_SETUP -#line 199 "QuantityParser.l" +#line 192 "Quantity.l" yylval = Quantity::MilliJoule; return UNIT; // milli Joule YY_BREAK case 111: YY_RULE_SETUP -#line 200 "QuantityParser.l" +#line 193 "Quantity.l" yylval = Quantity::KiloJoule; return UNIT; // kilo Joule YY_BREAK case 112: YY_RULE_SETUP -#line 201 "QuantityParser.l" +#line 194 "Quantity.l" yylval = Quantity::NewtonMeter; return UNIT; // N*m = Joule YY_BREAK case 113: YY_RULE_SETUP -#line 202 "QuantityParser.l" +#line 195 "Quantity.l" yylval = Quantity::VoltAmpereSecond; return UNIT; // V*A*s = Joule YY_BREAK case 114: YY_RULE_SETUP -#line 203 "QuantityParser.l" +#line 196 "Quantity.l" yylval = Quantity::WattSecond; return UNIT; // YY_BREAK case 115: YY_RULE_SETUP -#line 204 "QuantityParser.l" +#line 197 "Quantity.l" yylval = Quantity::WattSecond; return UNIT; // W*s = Joule YY_BREAK case 116: YY_RULE_SETUP -#line 205 "QuantityParser.l" +#line 198 "Quantity.l" yylval = Quantity::KiloWattHour; return UNIT; // 1 kWh = 3.6e6 J YY_BREAK case 117: YY_RULE_SETUP -#line 206 "QuantityParser.l" +#line 199 "Quantity.l" yylval = Quantity::ElectronVolt; return UNIT; // 1 eV = 1.602176634e-19 J YY_BREAK case 118: YY_RULE_SETUP -#line 207 "QuantityParser.l" +#line 200 "Quantity.l" yylval = Quantity::KiloElectronVolt; return UNIT; YY_BREAK case 119: YY_RULE_SETUP -#line 208 "QuantityParser.l" +#line 201 "Quantity.l" yylval = Quantity::MegaElectronVolt; return UNIT; YY_BREAK case 120: YY_RULE_SETUP -#line 209 "QuantityParser.l" +#line 202 "Quantity.l" yylval = Quantity::Calorie; return UNIT; // 1 cal = 4.1868 J YY_BREAK case 121: YY_RULE_SETUP -#line 210 "QuantityParser.l" +#line 203 "Quantity.l" yylval = Quantity::KiloCalorie; return UNIT; YY_BREAK case 122: YY_RULE_SETUP -#line 212 "QuantityParser.l" +#line 205 "Quantity.l" yylval = Quantity::Degree; return UNIT; // degree (internal standard angle) YY_BREAK case 123: YY_RULE_SETUP -#line 213 "QuantityParser.l" +#line 206 "Quantity.l" yylval = Quantity::Degree; return UNIT; // degree (internal standard angle) YY_BREAK case 124: YY_RULE_SETUP -#line 214 "QuantityParser.l" +#line 207 "Quantity.l" yylval = Quantity::Radian; return UNIT; // radian YY_BREAK case 125: YY_RULE_SETUP -#line 215 "QuantityParser.l" +#line 208 "Quantity.l" yylval = Quantity::Gon; return UNIT; // gon YY_BREAK case 126: YY_RULE_SETUP -#line 216 "QuantityParser.l" +#line 209 "Quantity.l" yylval = Quantity::AngMinute; return UNIT; // minute(Angular) YY_BREAK case 127: YY_RULE_SETUP -#line 217 "QuantityParser.l" -yylval = Quantity::AngMinute; return UNIT; // minute(Angular) +#line 210 "Quantity.l" +yylval = Quantity::AngMinute; return UNIT; // minute(Angular) YY_BREAK case 128: YY_RULE_SETUP -#line 218 "QuantityParser.l" +#line 211 "Quantity.l" yylval = Quantity::AngSecond; return UNIT; // second(Angular) YY_BREAK case 129: YY_RULE_SETUP -#line 219 "QuantityParser.l" -yylval = Quantity::AngSecond; return UNIT; // second(Angular) +#line 212 "Quantity.l" +yylval = Quantity::AngSecond; return UNIT; // second(Angular) YY_BREAK case 130: YY_RULE_SETUP -#line 221 "QuantityParser.l" +#line 214 "Quantity.l" yylval = Quantity(1.0); return ONE; YY_BREAK case 131: YY_RULE_SETUP -#line 222 "QuantityParser.l" -{ yylval = Quantity(num_change(yytext,'.',','));return NUM; } +#line 215 "Quantity.l" +yylval = Quantity(num_change(yytext,'.',',')); return NUM; YY_BREAK case 132: YY_RULE_SETUP -#line 223 "QuantityParser.l" -{ yylval = Quantity(num_change(yytext,'.',','));return NUM; } +#line 216 "Quantity.l" +yylval = Quantity(num_change(yytext,'.',',')); return NUM; YY_BREAK case 133: YY_RULE_SETUP -#line 224 "QuantityParser.l" -{ yylval = Quantity(num_change(yytext,',','.'));return NUM; } +#line 217 "Quantity.l" +yylval = Quantity(num_change(yytext,',','.')); return NUM; YY_BREAK case 134: YY_RULE_SETUP -#line 225 "QuantityParser.l" -{ yylval = Quantity(num_change(yytext,',','.'));return NUM; } +#line 218 "Quantity.l" +yylval = Quantity(num_change(yytext,',','.')); return NUM; YY_BREAK case 135: YY_RULE_SETUP -#line 228 "QuantityParser.l" -{yylval = Quantity(std::numbers::pi) ; return NUM;} // constant pi +#line 220 "Quantity.l" +yylval = Quantity(std::numbers::pi); return NUM; // constant pi YY_BREAK case 136: YY_RULE_SETUP -#line 229 "QuantityParser.l" -{yylval = Quantity(std::numbers::e) ; return NUM;} // constant e +#line 221 "Quantity.l" +yylval = Quantity(std::numbers::e); return NUM; // constant e YY_BREAK case 137: YY_RULE_SETUP -#line 231 "QuantityParser.l" +#line 223 "Quantity.l" return ACOS; YY_BREAK case 138: YY_RULE_SETUP -#line 232 "QuantityParser.l" +#line 224 "Quantity.l" return ASIN; YY_BREAK case 139: YY_RULE_SETUP -#line 233 "QuantityParser.l" +#line 225 "Quantity.l" return ATAN; YY_BREAK case 140: YY_RULE_SETUP -#line 234 "QuantityParser.l" +#line 226 "Quantity.l" return ATAN2; YY_BREAK case 141: YY_RULE_SETUP -#line 235 "QuantityParser.l" +#line 227 "Quantity.l" return COS; YY_BREAK case 142: YY_RULE_SETUP -#line 236 "QuantityParser.l" +#line 228 "Quantity.l" return EXP; YY_BREAK case 143: YY_RULE_SETUP -#line 237 "QuantityParser.l" +#line 229 "Quantity.l" return ABS; YY_BREAK case 144: YY_RULE_SETUP -#line 238 "QuantityParser.l" +#line 230 "Quantity.l" return MOD; YY_BREAK case 145: YY_RULE_SETUP -#line 239 "QuantityParser.l" +#line 231 "Quantity.l" return LOG; YY_BREAK case 146: YY_RULE_SETUP -#line 240 "QuantityParser.l" +#line 232 "Quantity.l" return LOG10; YY_BREAK case 147: YY_RULE_SETUP -#line 241 "QuantityParser.l" +#line 233 "Quantity.l" return POW; YY_BREAK case 148: YY_RULE_SETUP -#line 242 "QuantityParser.l" +#line 234 "Quantity.l" return SIN; YY_BREAK case 149: YY_RULE_SETUP -#line 243 "QuantityParser.l" +#line 235 "Quantity.l" return SINH; YY_BREAK case 150: YY_RULE_SETUP -#line 244 "QuantityParser.l" +#line 236 "Quantity.l" return TAN; YY_BREAK case 151: YY_RULE_SETUP -#line 245 "QuantityParser.l" +#line 237 "Quantity.l" return TANH; YY_BREAK case 152: YY_RULE_SETUP -#line 246 "QuantityParser.l" +#line 238 "Quantity.l" return SQRT; YY_BREAK case 153: YY_RULE_SETUP -#line 248 "QuantityParser.l" +#line 240 "Quantity.l" return *yytext; YY_BREAK case 154: YY_RULE_SETUP -#line 249 "QuantityParser.l" +#line 241 "Quantity.l" ECHO; YY_BREAK -#line 1712 "QuantityLexer.c" +#line 1706 "Quantity.lex.c" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(C_COMMENT): yyterminate(); @@ -1855,7 +1848,7 @@ case YY_STATE_EOF(C_COMMENT): */ static int yy_get_next_buffer (void) { - char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; char *source = (yytext_ptr); int number_to_move, i; int ret_val; @@ -2026,7 +2019,7 @@ static int yy_get_next_buffer (void) static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) { int yy_is_jam; - char *yy_cp = (yy_c_buf_p); + char *yy_cp = (yy_c_buf_p); YY_CHAR yy_c = 1; if ( yy_accept[yy_current_state] ) @@ -2149,7 +2142,7 @@ static int yy_get_next_buffer (void) void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) { - /* TODO: We should be able to replace this entire function body + /* TODO. We should be able to replace this entire function body * with * yypop_buffer_state(); * yypush_buffer_state(new_buffer); @@ -2179,7 +2172,7 @@ static int yy_get_next_buffer (void) static void yy_load_buffer_state (void) { - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; (yy_hold_char) = *(yy_c_buf_p); @@ -2268,7 +2261,7 @@ static void yy_load_buffer_state (void) */ void yy_flush_buffer (YY_BUFFER_STATE b ) { - if ( ! b ) + if ( ! b ) return; b->yy_n_chars = 0; @@ -2297,7 +2290,7 @@ static void yy_load_buffer_state (void) */ void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) { - if (new_buffer == NULL) + if (new_buffer == NULL) return; yyensure_buffer_stack(); @@ -2327,7 +2320,7 @@ void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) */ void yypop_buffer_state (void) { - if (!YY_CURRENT_BUFFER) + if (!YY_CURRENT_BUFFER) return; yy_delete_buffer(YY_CURRENT_BUFFER ); @@ -2680,5 +2673,4 @@ void yyfree (void * ptr ) #define YYTABLES_NAME "yytables" -#line 249 "QuantityParser.l" -// clang-format on +#line 241 "Quantity.l" diff --git a/src/Base/QuantityParser.c b/src/Base/Quantity.tab.c similarity index 54% rename from src/Base/QuantityParser.c rename to src/Base/Quantity.tab.c index e38a289ab8..37374eae03 100644 --- a/src/Base/QuantityParser.c +++ b/src/Base/Quantity.tab.c @@ -1,9 +1,10 @@ // clang-format off -/* A Bison parser, made by GNU Bison 3.0.4. */ +/* A Bison parser, made by GNU Bison 3.8.2. */ /* Bison implementation for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation, + Inc. 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 @@ -16,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see . */ + along with this program. If not, see . */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -34,6 +35,10 @@ /* C LALR(1) parser skeleton written by Richard Stallman, by simplifying the original so-called "semantic" parser. */ +/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual, + especially those whose name start with YY_ or yy_. They are + private implementation details that can be changed or removed. */ + /* All symbols defined below should begin with yy or YY, to avoid infringing on user name space. This should be done even for local variables, as they might otherwise be expanded by user macros. @@ -41,11 +46,11 @@ define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */ -/* Identify Bison output. */ -#define YYBISON 1 +/* Identify Bison output, and Bison version. */ +#define YYBISON 30802 -/* Bison version. */ -#define YYBISON_VERSION "3.0.4" +/* Bison version string. */ +#define YYBISON_VERSION "3.8.2" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -62,37 +67,35 @@ -/* Copy the first part of user declarations. */ -#line 6 "QuantityParser.y" /* yacc.c:339 */ +/* First part of user prologue. */ +#line 24 "Quantity.y" - #define YYSTYPE Quantity - #define yyparse Quantity_yyparse - #define yyerror Quantity_yyerror + #define YYSTYPE Quantity + #define yyparse Quantity_yyparse + #define yyerror Quantity_yyerror +#line 77 "Quantity.tab.c" - - - - - - -#line 79 "QuantityParser.c" /* yacc.c:339 */ - -# ifndef YY_NULLPTR -# if defined __cplusplus && 201103L <= __cplusplus -# define YY_NULLPTR nullptr +# ifndef YY_CAST +# ifdef __cplusplus +# define YY_CAST(Type, Val) static_cast (Val) +# define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast (Val) # else -# define YY_NULLPTR 0 +# define YY_CAST(Type, Val) ((Type) (Val)) +# define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val)) +# endif +# endif +# ifndef YY_NULLPTR +# if defined __cplusplus +# if 201103L <= __cplusplus +# define YY_NULLPTR nullptr +# else +# define YY_NULLPTR 0 +# endif +# else +# define YY_NULLPTR ((void*)0) # endif # endif - -/* Enabling verbose error messages. */ -#ifdef YYERROR_VERBOSE -# undef YYERROR_VERBOSE -# define YYERROR_VERBOSE 1 -#else -# define YYERROR_VERBOSE 0 -#endif /* Debug traces. */ @@ -103,33 +106,38 @@ extern int yydebug; #endif -/* Token type. */ +/* Token kinds. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE enum yytokentype { - UNIT = 258, - ONE = 259, - NUM = 260, - MINUSSIGN = 261, - ACOS = 262, - ASIN = 263, - ATAN = 264, - ATAN2 = 265, - COS = 266, - EXP = 267, - ABS = 268, - MOD = 269, - LOG = 270, - LOG10 = 271, - POW = 272, - SIN = 273, - SINH = 274, - TAN = 275, - TANH = 276, - SQRT = 277, - NEG = 278 + YYEMPTY = -2, + YYEOF = 0, /* "end of file" */ + YYerror = 256, /* error */ + YYUNDEF = 257, /* "invalid token" */ + UNIT = 258, /* UNIT */ + ONE = 259, /* ONE */ + NUM = 260, /* NUM */ + MINUSSIGN = 261, /* MINUSSIGN */ + ACOS = 262, /* ACOS */ + ASIN = 263, /* ASIN */ + ATAN = 264, /* ATAN */ + ATAN2 = 265, /* ATAN2 */ + COS = 266, /* COS */ + EXP = 267, /* EXP */ + ABS = 268, /* ABS */ + MOD = 269, /* MOD */ + LOG = 270, /* LOG */ + LOG10 = 271, /* LOG10 */ + POW = 272, /* POW */ + SIN = 273, /* SIN */ + SINH = 274, /* SINH */ + TAN = 275, /* TAN */ + TANH = 276, /* TANH */ + SQRT = 277, /* SQRT */ + NEG = 278 /* NEG */ }; + typedef enum yytokentype yytoken_kind_t; #endif /* Value type. */ @@ -142,40 +150,141 @@ typedef int YYSTYPE; extern YYSTYPE yylval; + int yyparse (void); -/* Copy the second part of user declarations. */ +/* Symbol kind. */ +enum yysymbol_kind_t +{ + YYSYMBOL_YYEMPTY = -2, + YYSYMBOL_YYEOF = 0, /* "end of file" */ + YYSYMBOL_YYerror = 1, /* error */ + YYSYMBOL_YYUNDEF = 2, /* "invalid token" */ + YYSYMBOL_UNIT = 3, /* UNIT */ + YYSYMBOL_ONE = 4, /* ONE */ + YYSYMBOL_NUM = 5, /* NUM */ + YYSYMBOL_MINUSSIGN = 6, /* MINUSSIGN */ + YYSYMBOL_ACOS = 7, /* ACOS */ + YYSYMBOL_ASIN = 8, /* ASIN */ + YYSYMBOL_ATAN = 9, /* ATAN */ + YYSYMBOL_ATAN2 = 10, /* ATAN2 */ + YYSYMBOL_COS = 11, /* COS */ + YYSYMBOL_EXP = 12, /* EXP */ + YYSYMBOL_ABS = 13, /* ABS */ + YYSYMBOL_MOD = 14, /* MOD */ + YYSYMBOL_LOG = 15, /* LOG */ + YYSYMBOL_LOG10 = 16, /* LOG10 */ + YYSYMBOL_POW = 17, /* POW */ + YYSYMBOL_SIN = 18, /* SIN */ + YYSYMBOL_SINH = 19, /* SINH */ + YYSYMBOL_TAN = 20, /* TAN */ + YYSYMBOL_TANH = 21, /* TANH */ + YYSYMBOL_SQRT = 22, /* SQRT */ + YYSYMBOL_23_ = 23, /* '+' */ + YYSYMBOL_24_ = 24, /* '*' */ + YYSYMBOL_25_ = 25, /* '/' */ + YYSYMBOL_NEG = 26, /* NEG */ + YYSYMBOL_27_ = 27, /* '^' */ + YYSYMBOL_28_ = 28, /* '(' */ + YYSYMBOL_29_ = 29, /* ')' */ + YYSYMBOL_YYACCEPT = 30, /* $accept */ + YYSYMBOL_input = 31, /* input */ + YYSYMBOL_num = 32, /* num */ + YYSYMBOL_unit = 33, /* unit */ + YYSYMBOL_quantity = 34 /* quantity */ +}; +typedef enum yysymbol_kind_t yysymbol_kind_t; + + -#line 151 "QuantityParser.c" /* yacc.c:358 */ #ifdef short # undef short #endif -#ifdef YYTYPE_UINT8 -typedef YYTYPE_UINT8 yytype_uint8; -#else -typedef unsigned char yytype_uint8; +/* On compilers that do not define __PTRDIFF_MAX__ etc., make sure + and (if available) are included + so that the code can choose integer types of a good width. */ + +#ifndef __PTRDIFF_MAX__ +# include /* INFRINGES ON USER NAME SPACE */ +# if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_STDINT_H +# endif #endif -#ifdef YYTYPE_INT8 -typedef YYTYPE_INT8 yytype_int8; +/* Narrow types that promote to a signed type and that can represent a + signed or unsigned integer of at least N bits. In tables they can + save space and decrease cache pressure. Promoting to a signed type + helps avoid bugs in integer arithmetic. */ + +#ifdef __INT_LEAST8_MAX__ +typedef __INT_LEAST8_TYPE__ yytype_int8; +#elif defined YY_STDINT_H +typedef int_least8_t yytype_int8; #else typedef signed char yytype_int8; #endif -#ifdef YYTYPE_UINT16 -typedef YYTYPE_UINT16 yytype_uint16; +#ifdef __INT_LEAST16_MAX__ +typedef __INT_LEAST16_TYPE__ yytype_int16; +#elif defined YY_STDINT_H +typedef int_least16_t yytype_int16; #else -typedef unsigned short int yytype_uint16; +typedef short yytype_int16; #endif -#ifdef YYTYPE_INT16 -typedef YYTYPE_INT16 yytype_int16; +/* Work around bug in HP-UX 11.23, which defines these macros + incorrectly for preprocessor constants. This workaround can likely + be removed in 2023, as HPE has promised support for HP-UX 11.23 + (aka HP-UX 11i v2) only through the end of 2022; see Table 2 of + . */ +#ifdef __hpux +# undef UINT_LEAST8_MAX +# undef UINT_LEAST16_MAX +# define UINT_LEAST8_MAX 255 +# define UINT_LEAST16_MAX 65535 +#endif + +#if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__ +typedef __UINT_LEAST8_TYPE__ yytype_uint8; +#elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \ + && UINT_LEAST8_MAX <= INT_MAX) +typedef uint_least8_t yytype_uint8; +#elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX +typedef unsigned char yytype_uint8; #else -typedef short int yytype_int16; +typedef short yytype_uint8; +#endif + +#if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__ +typedef __UINT_LEAST16_TYPE__ yytype_uint16; +#elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \ + && UINT_LEAST16_MAX <= INT_MAX) +typedef uint_least16_t yytype_uint16; +#elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX +typedef unsigned short yytype_uint16; +#else +typedef int yytype_uint16; +#endif + +#ifndef YYPTRDIFF_T +# if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__ +# define YYPTRDIFF_T __PTRDIFF_TYPE__ +# define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__ +# elif defined PTRDIFF_MAX +# ifndef ptrdiff_t +# include /* INFRINGES ON USER NAME SPACE */ +# endif +# define YYPTRDIFF_T ptrdiff_t +# define YYPTRDIFF_MAXIMUM PTRDIFF_MAX +# else +# define YYPTRDIFF_T long +# define YYPTRDIFF_MAXIMUM LONG_MAX +# endif #endif #ifndef YYSIZE_T @@ -183,15 +292,28 @@ typedef short int yytype_int16; # define YYSIZE_T __SIZE_TYPE__ # elif defined size_t # define YYSIZE_T size_t -# elif ! defined YYSIZE_T +# elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else -# define YYSIZE_T unsigned int +# define YYSIZE_T unsigned # endif #endif -#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) +#define YYSIZE_MAXIMUM \ + YY_CAST (YYPTRDIFF_T, \ + (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \ + ? YYPTRDIFF_MAXIMUM \ + : YY_CAST (YYSIZE_T, -1))) + +#define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X)) + + +/* Stored state numbers (used for stacks). */ +typedef yytype_int8 yy_state_t; + +/* State numbers in computations. */ +typedef int yy_state_fast_t; #ifndef YY_ # if defined YYENABLE_NLS && YYENABLE_NLS @@ -205,47 +327,43 @@ typedef short int yytype_int16; # endif #endif -#ifndef YY_ATTRIBUTE -# if (defined __GNUC__ \ - && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ - || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C -# define YY_ATTRIBUTE(Spec) __attribute__(Spec) + +#ifndef YY_ATTRIBUTE_PURE +# if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__) +# define YY_ATTRIBUTE_PURE __attribute__ ((__pure__)) # else -# define YY_ATTRIBUTE(Spec) /* empty */ +# define YY_ATTRIBUTE_PURE # endif #endif -#ifndef YY_ATTRIBUTE_PURE -# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) -#endif - #ifndef YY_ATTRIBUTE_UNUSED -# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) -#endif - -#if !defined _Noreturn \ - && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) -# if defined _MSC_VER && 1200 <= _MSC_VER -# define _Noreturn __declspec (noreturn) +# if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__) +# define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__)) # else -# define _Noreturn YY_ATTRIBUTE ((__noreturn__)) +# define YY_ATTRIBUTE_UNUSED # endif #endif /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ -# define YYUSE(E) ((void) (E)) +# define YY_USE(E) ((void) (E)) #else -# define YYUSE(E) /* empty */ +# define YY_USE(E) /* empty */ #endif -#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ /* Suppress an incorrect diagnostic about yylval being uninitialized. */ -# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ - _Pragma ("GCC diagnostic push") \ - _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ +#if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__ +# if __GNUC__ * 100 + __GNUC_MINOR__ < 407 +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") +# else +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \ _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") -# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ +# endif +# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ _Pragma ("GCC diagnostic pop") #else # define YY_INITIAL_VALUE(Value) Value @@ -258,8 +376,22 @@ typedef short int yytype_int16; # define YY_INITIAL_VALUE(Value) /* Nothing. */ #endif +#if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__ +# define YY_IGNORE_USELESS_CAST_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"") +# define YY_IGNORE_USELESS_CAST_END \ + _Pragma ("GCC diagnostic pop") +#endif +#ifndef YY_IGNORE_USELESS_CAST_BEGIN +# define YY_IGNORE_USELESS_CAST_BEGIN +# define YY_IGNORE_USELESS_CAST_END +#endif -#if ! defined yyoverflow || YYERROR_VERBOSE + +#define YY_ASSERT(E) ((void) (0 && (E))) + +#if !defined yyoverflow /* The parser invokes alloca or malloc; define the necessary symbols. */ @@ -324,8 +456,7 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif # endif # endif -#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ - +#endif /* !defined yyoverflow */ #if (! defined yyoverflow \ && (! defined __cplusplus \ @@ -334,17 +465,17 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ /* A type that is properly aligned for any stack member. */ union yyalloc { - yytype_int16 yyss_alloc; + yy_state_t yyss_alloc; YYSTYPE yyvs_alloc; }; /* The size of the maximum gap between one aligned stack and the next. */ -# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) +# define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1) /* The size of an array large to enough to hold all stacks, each with N elements. */ # define YYSTACK_BYTES(N) \ - ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM) # define YYCOPY_NEEDED 1 @@ -357,11 +488,11 @@ union yyalloc # define YYSTACK_RELOCATE(Stack_alloc, Stack) \ do \ { \ - YYSIZE_T yynewbytes; \ + YYPTRDIFF_T yynewbytes; \ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ Stack = &yyptr->Stack_alloc; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ + yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / YYSIZEOF (*yyptr); \ } \ while (0) @@ -373,12 +504,12 @@ union yyalloc # ifndef YYCOPY # if defined __GNUC__ && 1 < __GNUC__ # define YYCOPY(Dst, Src, Count) \ - __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) + __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src))) # else # define YYCOPY(Dst, Src, Count) \ do \ { \ - YYSIZE_T yyi; \ + YYPTRDIFF_T yyi; \ for (yyi = 0; yyi < (Count); yyi++) \ (Dst)[yyi] = (Src)[yyi]; \ } \ @@ -401,17 +532,20 @@ union yyalloc /* YYNSTATES -- Number of states. */ #define YYNSTATES 96 -/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned - by yylex, with out-of-bounds checking. */ -#define YYUNDEFTOK 2 +/* YYMAXUTOK -- Last valid token kind. */ #define YYMAXUTOK 278 -#define YYTRANSLATE(YYX) \ - ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM + as returned by yylex, with out-of-bounds checking. */ +#define YYTRANSLATE(YYX) \ + (0 <= (YYX) && (YYX) <= YYMAXUTOK \ + ? YY_CAST (yysymbol_kind_t, yytranslate[YYX]) \ + : YYSYMBOL_YYUNDEF) /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM - as returned by yylex, without out-of-bounds checking. */ -static const yytype_uint8 yytranslate[] = + as returned by yylex. */ +static const yytype_int8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -444,52 +578,54 @@ static const yytype_uint8 yytranslate[] = }; #if YYDEBUG - /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ -static const yytype_uint8 yyrline[] = +/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ +static const yytype_int8 yyrline[] = { - 0, 34, 34, 35, 36, 37, 38, 39, 41, 42, - 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, - 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, - 65, 66, 67, 68, 69, 70, 72, 73 + 0, 43, 43, 44, 45, 46, 47, 48, 50, 51, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, + 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, + 74, 75, 76, 77, 78, 79, 81, 82 }; #endif -#if YYDEBUG || YYERROR_VERBOSE || 0 +/** Accessing symbol of state STATE. */ +#define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State]) + +#if YYDEBUG || 0 +/* The user-facing name of the symbol whose (internal) number is + YYSYMBOL. No bounds checking. */ +static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED; + /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { - "$end", "error", "$undefined", "UNIT", "ONE", "NUM", "MINUSSIGN", - "ACOS", "ASIN", "ATAN", "ATAN2", "COS", "EXP", "ABS", "MOD", "LOG", - "LOG10", "POW", "SIN", "SINH", "TAN", "TANH", "SQRT", "'+'", "'*'", - "'/'", "NEG", "'^'", "'('", "')'", "$accept", "input", "num", "unit", - "quantity", YY_NULLPTR + "\"end of file\"", "error", "\"invalid token\"", "UNIT", "ONE", "NUM", + "MINUSSIGN", "ACOS", "ASIN", "ATAN", "ATAN2", "COS", "EXP", "ABS", "MOD", + "LOG", "LOG10", "POW", "SIN", "SINH", "TAN", "TANH", "SQRT", "'+'", + "'*'", "'/'", "NEG", "'^'", "'('", "')'", "$accept", "input", "num", + "unit", "quantity", YY_NULLPTR }; + +static const char * +yysymbol_name (yysymbol_kind_t yysymbol) +{ + return yytname[yysymbol]; +} #endif -# ifdef YYPRINT -/* YYTOKNUM[NUM] -- (External) token number corresponding to the - (internal) symbol number NUM (which must be that of a token). */ -static const yytype_uint16 yytoknum[] = -{ - 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, - 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, - 275, 276, 277, 43, 42, 47, 278, 94, 40, 41 -}; -# endif +#define YYPACT_NINF (-26) -#define YYPACT_NINF -26 +#define yypact_value_is_default(Yyn) \ + ((Yyn) == YYPACT_NINF) -#define yypact_value_is_default(Yystate) \ - (!!((Yystate) == (-26))) +#define YYTABLE_NINF (-1) -#define YYTABLE_NINF -1 - -#define yytable_value_is_error(Yytable_value) \ +#define yytable_value_is_error(Yyn) \ 0 - /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing - STATE-NUM. */ +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ static const yytype_int16 yypact[] = { 72, -26, -26, -26, 117, -25, -23, -10, -7, -5, @@ -504,10 +640,10 @@ static const yytype_int16 yypact[] = -26, -26, -26, -26, -26, -26 }; - /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. - Performed when YYTABLE does not specify something else to do. Zero - means the default is an error. */ -static const yytype_uint8 yydefact[] = +/* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. + Performed when YYTABLE does not specify something else to do. Zero + means the default is an error. */ +static const yytype_int8 yydefact[] = { 2, 30, 9, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -521,22 +657,22 @@ static const yytype_uint8 yydefact[] = 23, 24, 25, 26, 27, 28 }; - /* YYPGOTO[NTERM-NUM]. */ +/* YYPGOTO[NTERM-NUM]. */ static const yytype_int8 yypgoto[] = { -26, -26, 0, 20, -14 }; - /* YYDEFGOTO[NTERM-NUM]. */ +/* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int8 yydefgoto[] = { - -1, 19, 40, 41, 22 + 0, 19, 40, 41, 22 }; - /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If - positive, shift that token. If negative, reduce the rule whose - number is the opposite. If YYTABLE_NINF, syntax error. */ -static const yytype_uint8 yytable[] = +/* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule whose + number is the opposite. If YYTABLE_NINF, syntax error. */ +static const yytype_int8 yytable[] = { 20, 1, 43, 27, 26, 28, 51, 52, 55, 53, 45, 72, 51, 52, 48, 53, 46, 57, 29, 48, @@ -592,9 +728,9 @@ static const yytype_int8 yycheck[] = 23, 24, 25, -1, 27, -1, 29 }; - /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing - symbol of state STATE-NUM. */ -static const yytype_uint8 yystos[] = +/* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of + state STATE-NUM. */ +static const yytype_int8 yystos[] = { 0, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 15, 16, 18, 19, 20, 21, 22, 28, 31, @@ -608,8 +744,8 @@ static const yytype_uint8 yystos[] = 29, 29, 29, 29, 29, 29 }; - /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const yytype_uint8 yyr1[] = +/* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM. */ +static const yytype_int8 yyr1[] = { 0, 30, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, @@ -617,8 +753,8 @@ static const yytype_uint8 yyr1[] = 33, 33, 33, 33, 33, 33, 34, 34 }; - /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ -static const yytype_uint8 yyr2[] = +/* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM. */ +static const yytype_int8 yyr2[] = { 0, 2, 0, 1, 1, 1, 2, 3, 1, 1, 3, 3, 3, 3, 2, 3, 3, 4, 4, 4, @@ -627,39 +763,39 @@ static const yytype_uint8 yyr2[] = }; +enum { YYENOMEM = -2 }; + #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) -#define YYEOF 0 #define YYACCEPT goto yyacceptlab #define YYABORT goto yyabortlab #define YYERROR goto yyerrorlab +#define YYNOMEM goto yyexhaustedlab #define YYRECOVERING() (!!yyerrstatus) -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - YYPOPSTACK (yylen); \ - yystate = *yyssp; \ - goto yybackup; \ - } \ - else \ - { \ - yyerror (YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ -while (0) - -/* Error token number */ -#define YYTERROR 1 -#define YYERRCODE 256 +#define YYBACKUP(Token, Value) \ + do \ + if (yychar == YYEMPTY) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + YYPOPSTACK (yylen); \ + yystate = *yyssp; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ + while (0) +/* Backward compatibility with an undocumented macro. + Use YYerror or YYUNDEF. */ +#define YYERRCODE YYUNDEF /* Enable debugging if requested. */ @@ -676,55 +812,52 @@ do { \ YYFPRINTF Args; \ } while (0) -/* This macro is provided for backward compatibility. */ -#ifndef YY_LOCATION_PRINT -# define YY_LOCATION_PRINT(File, Loc) ((void) 0) -#endif -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ + +# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \ do { \ if (yydebug) \ { \ YYFPRINTF (stderr, "%s ", Title); \ yy_symbol_print (stderr, \ - Type, Value); \ + Kind, Value); \ YYFPRINTF (stderr, "\n"); \ } \ } while (0) -/*----------------------------------------. -| Print this symbol's value on YYOUTPUT. | -`----------------------------------------*/ +/*-----------------------------------. +| Print this symbol's value on YYO. | +`-----------------------------------*/ static void -yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +yy_symbol_value_print (FILE *yyo, + yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep) { - FILE *yyo = yyoutput; - YYUSE (yyo); + FILE *yyoutput = yyo; + YY_USE (yyoutput); if (!yyvaluep) return; -# ifdef YYPRINT - if (yytype < YYNTOKENS) - YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); -# endif - YYUSE (yytype); + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + YY_USE (yykind); + YY_IGNORE_MAYBE_UNINITIALIZED_END } -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ +/*---------------------------. +| Print this symbol on YYO. | +`---------------------------*/ static void -yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +yy_symbol_print (FILE *yyo, + yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep) { - YYFPRINTF (yyoutput, "%s %s (", - yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); + YYFPRINTF (yyo, "%s %s (", + yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind)); - yy_symbol_value_print (yyoutput, yytype, yyvaluep); - YYFPRINTF (yyoutput, ")"); + yy_symbol_value_print (yyo, yykind, yyvaluep); + YYFPRINTF (yyo, ")"); } /*------------------------------------------------------------------. @@ -733,7 +866,7 @@ yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) `------------------------------------------------------------------*/ static void -yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) +yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop) { YYFPRINTF (stderr, "Stack now"); for (; yybottom <= yytop; yybottom++) @@ -756,21 +889,21 @@ do { \ `------------------------------------------------*/ static void -yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule) +yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp, + int yyrule) { - unsigned long int yylno = yyrline[yyrule]; + int yylno = yyrline[yyrule]; int yynrhs = yyr2[yyrule]; int yyi; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n", yyrule - 1, yylno); /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, - yystos[yyssp[yyi + 1 - yynrhs]], - &(yyvsp[(yyi + 1) - (yynrhs)]) - ); + YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]), + &yyvsp[(yyi + 1) - (yynrhs)]); YYFPRINTF (stderr, "\n"); } } @@ -785,8 +918,8 @@ do { \ multiple parsers can coexist. */ int yydebug; #else /* !YYDEBUG */ -# define YYDPRINTF(Args) -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YYDPRINTF(Args) ((void) 0) +# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) # define YY_STACK_PRINT(Bottom, Top) # define YY_REDUCE_PRINT(Rule) #endif /* !YYDEBUG */ @@ -809,249 +942,30 @@ int yydebug; #endif -#if YYERROR_VERBOSE -# ifndef yystrlen -# if defined __GLIBC__ && defined _STRING_H -# define yystrlen strlen -# else -/* Return the length of YYSTR. */ -static YYSIZE_T -yystrlen (const char *yystr) -{ - YYSIZE_T yylen; - for (yylen = 0; yystr[yylen]; yylen++) - continue; - return yylen; -} -# endif -# endif -# ifndef yystpcpy -# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE -# define yystpcpy stpcpy -# else -/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in - YYDEST. */ -static char * -yystpcpy (char *yydest, const char *yysrc) -{ - char *yyd = yydest; - const char *yys = yysrc; - while ((*yyd++ = *yys++) != '\0') - continue; - - return yyd - 1; -} -# endif -# endif - -# ifndef yytnamerr -/* Copy to YYRES the contents of YYSTR after stripping away unnecessary - quotes and backslashes, so that it's suitable for yyerror. The - heuristic is that double-quoting is unnecessary unless the string - contains an apostrophe, a comma, or backslash (other than - backslash-backslash). YYSTR is taken from yytname. If YYRES is - null, do not copy; instead, return the length of what the result - would have been. */ -static YYSIZE_T -yytnamerr (char *yyres, const char *yystr) -{ - if (*yystr == '"') - { - YYSIZE_T yyn = 0; - char const *yyp = yystr; - - for (;;) - switch (*++yyp) - { - case '\'': - case ',': - goto do_not_strip_quotes; - - case '\\': - if (*++yyp != '\\') - goto do_not_strip_quotes; - /* Fall through. */ - default: - if (yyres) - yyres[yyn] = *yyp; - yyn++; - break; - - case '"': - if (yyres) - yyres[yyn] = '\0'; - return yyn; - } - do_not_strip_quotes: ; - } - - if (! yyres) - return yystrlen (yystr); - - return yystpcpy (yyres, yystr) - yyres; -} -# endif - -/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message - about the unexpected token YYTOKEN for the state stack whose top is - YYSSP. - - Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is - not large enough to hold the message. In that case, also set - *YYMSG_ALLOC to the required number of bytes. Return 2 if the - required number of bytes is too large to store. */ -static int -yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, - yytype_int16 *yyssp, int yytoken) -{ - YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); - YYSIZE_T yysize = yysize0; - enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; - /* Internationalized format string. */ - const char *yyformat = YY_NULLPTR; - /* Arguments of yyformat. */ - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - /* Number of reported tokens (one for the "unexpected", one per - "expected"). */ - int yycount = 0; - - /* There are many possibilities here to consider: - - If this state is a consistent state with a default action, then - the only way this function was invoked is if the default action - is an error action. In that case, don't check for expected - tokens because there are none. - - The only way there can be no lookahead present (in yychar) is if - this state is a consistent state with a default action. Thus, - detecting the absence of a lookahead is sufficient to determine - that there is no unexpected or expected token to report. In that - case, just report a simple "syntax error". - - Don't assume there isn't a lookahead just because this state is a - consistent state with a default action. There might have been a - previous inconsistent state, consistent state with a non-default - action, or user semantic action that manipulated yychar. - - Of course, the expected token list depends on states to have - correct lookahead information, and it depends on the parser not - to perform extra reductions after fetching a lookahead from the - scanner and before detecting a syntax error. Thus, state merging - (from LALR or IELR) and default reductions corrupt the expected - token list. However, the list is correct for canonical LR with - one exception: it will still contain any token that will not be - accepted due to an error action in a later state. - */ - if (yytoken != YYEMPTY) - { - int yyn = yypact[*yyssp]; - yyarg[yycount++] = yytname[yytoken]; - if (!yypact_value_is_default (yyn)) - { - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. In other words, skip the first -YYN actions for - this state because they are default actions. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn + 1; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yyx; - - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR - && !yytable_value_is_error (yytable[yyx + yyn])) - { - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - yysize = yysize0; - break; - } - yyarg[yycount++] = yytname[yyx]; - { - YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); - if (! (yysize <= yysize1 - && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; - } - } - } - } - - switch (yycount) - { -# define YYCASE_(N, S) \ - case N: \ - yyformat = S; \ - break - YYCASE_(0, YY_("syntax error")); - YYCASE_(1, YY_("syntax error, unexpected %s")); - YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); - YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); - YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); - YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); -# undef YYCASE_ - } - - { - YYSIZE_T yysize1 = yysize + yystrlen (yyformat); - if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; - } - - if (*yymsg_alloc < yysize) - { - *yymsg_alloc = 2 * yysize; - if (! (yysize <= *yymsg_alloc - && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) - *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; - return 1; - } - - /* Avoid sprintf, as that infringes on the user's name space. - Don't have undefined behavior even if the translation - produced a string with the wrong number of "%s"s. */ - { - char *yyp = *yymsg; - int yyi = 0; - while ((*yyp = *yyformat) != '\0') - if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) - { - yyp += yytnamerr (yyp, yyarg[yyi++]); - yyformat += 2; - } - else - { - yyp++; - yyformat++; - } - } - return 0; -} -#endif /* YYERROR_VERBOSE */ /*-----------------------------------------------. | Release the memory associated to this symbol. | `-----------------------------------------------*/ static void -yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) +yydestruct (const char *yymsg, + yysymbol_kind_t yykind, YYSTYPE *yyvaluep) { - YYUSE (yyvaluep); + YY_USE (yyvaluep); if (!yymsg) yymsg = "Deleting"; - YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp); YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN - YYUSE (yytype); + YY_USE (yykind); YY_IGNORE_MAYBE_UNINITIALIZED_END } - - -/* The lookahead symbol. */ +/* Lookahead token kind. */ int yychar; /* The semantic value of the lookahead symbol. */ @@ -1060,6 +974,8 @@ YYSTYPE yylval; int yynerrs; + + /*----------. | yyparse. | `----------*/ @@ -1067,43 +983,36 @@ int yynerrs; int yyparse (void) { - int yystate; + yy_state_fast_t yystate = 0; /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; + int yyerrstatus = 0; - /* The stacks and their tools: - 'yyss': related to states. - 'yyvs': related to semantic values. - - Refer to the stacks through separate pointers, to allow yyoverflow + /* Refer to the stacks through separate pointers, to allow yyoverflow to reallocate them elsewhere. */ - /* The state stack. */ - yytype_int16 yyssa[YYINITDEPTH]; - yytype_int16 *yyss; - yytype_int16 *yyssp; + /* Their size. */ + YYPTRDIFF_T yystacksize = YYINITDEPTH; - /* The semantic value stack. */ + /* The state stack: array, bottom, top. */ + yy_state_t yyssa[YYINITDEPTH]; + yy_state_t *yyss = yyssa; + yy_state_t *yyssp = yyss; + + /* The semantic value stack: array, bottom, top. */ YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs; - YYSTYPE *yyvsp; - - YYSIZE_T yystacksize; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp = yyvs; int yyn; + /* The return value of yyparse. */ int yyresult; - /* Lookahead token as an internal (translated) token number. */ - int yytoken = 0; + /* Lookahead symbol kind. */ + yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; -#if YYERROR_VERBOSE - /* Buffer for error messages, and its allocated size. */ - char yymsgbuf[128]; - char *yymsg = yymsgbuf; - YYSIZE_T yymsg_alloc = sizeof yymsgbuf; -#endif + #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) @@ -1111,71 +1020,75 @@ yyparse (void) Keep to zero when no symbol should be popped. */ int yylen = 0; - yyssp = yyss = yyssa; - yyvsp = yyvs = yyvsa; - yystacksize = YYINITDEPTH; - YYDPRINTF ((stderr, "Starting parse\n")); - yystate = 0; - yyerrstatus = 0; - yynerrs = 0; yychar = YYEMPTY; /* Cause a token to be read. */ + goto yysetstate; + /*------------------------------------------------------------. -| yynewstate -- Push a new state, which is found in yystate. | +| yynewstate -- push a new state, which is found in yystate. | `------------------------------------------------------------*/ - yynewstate: +yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. So pushing a state here evens the stacks. */ yyssp++; - yysetstate: - *yyssp = yystate; + +/*--------------------------------------------------------------------. +| yysetstate -- set current state (the top of the stack) to yystate. | +`--------------------------------------------------------------------*/ +yysetstate: + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + YY_ASSERT (0 <= yystate && yystate < YYNSTATES); + YY_IGNORE_USELESS_CAST_BEGIN + *yyssp = YY_CAST (yy_state_t, yystate); + YY_IGNORE_USELESS_CAST_END + YY_STACK_PRINT (yyss, yyssp); if (yyss + yystacksize - 1 <= yyssp) +#if !defined yyoverflow && !defined YYSTACK_RELOCATE + YYNOMEM; +#else { /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = yyssp - yyss + 1; + YYPTRDIFF_T yysize = yyssp - yyss + 1; -#ifdef yyoverflow +# if defined yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into memory. */ + yy_state_t *yyss1 = yyss; YYSTYPE *yyvs1 = yyvs; - yytype_int16 *yyss1 = yyss; /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ yyoverflow (YY_("memory exhausted"), - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), + &yyss1, yysize * YYSIZEOF (*yyssp), + &yyvs1, yysize * YYSIZEOF (*yyvsp), &yystacksize); - yyss = yyss1; yyvs = yyvs1; } -#else /* no yyoverflow */ -# ifndef YYSTACK_RELOCATE - goto yyexhaustedlab; -# else +# else /* defined YYSTACK_RELOCATE */ /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) - goto yyexhaustedlab; + YYNOMEM; yystacksize *= 2; if (YYMAXDEPTH < yystacksize) yystacksize = YYMAXDEPTH; { - yytype_int16 *yyss1 = yyss; + yy_state_t *yyss1 = yyss; union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + YY_CAST (union yyalloc *, + YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize)))); if (! yyptr) - goto yyexhaustedlab; + YYNOMEM; YYSTACK_RELOCATE (yyss_alloc, yyss); YYSTACK_RELOCATE (yyvs_alloc, yyvs); # undef YYSTACK_RELOCATE @@ -1183,30 +1096,31 @@ yyparse (void) YYSTACK_FREE (yyss1); } # endif -#endif /* no yyoverflow */ yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; - YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); + YY_IGNORE_USELESS_CAST_BEGIN + YYDPRINTF ((stderr, "Stack size increased to %ld\n", + YY_CAST (long, yystacksize))); + YY_IGNORE_USELESS_CAST_END if (yyss + yystacksize - 1 <= yyssp) YYABORT; } +#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */ - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); if (yystate == YYFINAL) YYACCEPT; goto yybackup; + /*-----------. | yybackup. | `-----------*/ yybackup: - /* Do appropriate processing given the current state. Read a lookahead token if we need one and don't already have one. */ @@ -1217,18 +1131,29 @@ yybackup: /* Not known => get a lookahead token if don't already have one. */ - /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */ if (yychar == YYEMPTY) { - YYDPRINTF ((stderr, "Reading a token: ")); + YYDPRINTF ((stderr, "Reading a token\n")); yychar = yylex (); } if (yychar <= YYEOF) { - yychar = yytoken = YYEOF; + yychar = YYEOF; + yytoken = YYSYMBOL_YYEOF; YYDPRINTF ((stderr, "Now at end of input.\n")); } + else if (yychar == YYerror) + { + /* The scanner already issued an error message, process directly + to error recovery. But do not keep the error token as + lookahead, it is too special and may lead us to an endless + loop in error recovery. */ + yychar = YYUNDEF; + yytoken = YYSYMBOL_YYerror; + goto yyerrlab1; + } else { yytoken = YYTRANSLATE (yychar); @@ -1256,15 +1181,13 @@ yybackup: /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - - /* Discard the shifted token. */ - yychar = YYEMPTY; - yystate = yyn; YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; YY_IGNORE_MAYBE_UNINITIALIZED_END + /* Discard the shifted token. */ + yychar = YYEMPTY; goto yynewstate; @@ -1279,7 +1202,7 @@ yydefault: /*-----------------------------. -| yyreduce -- Do a reduction. | +| yyreduce -- do a reduction. | `-----------------------------*/ yyreduce: /* yyn is the number of a rule to reduce with. */ @@ -1299,224 +1222,225 @@ yyreduce: YY_REDUCE_PRINT (yyn); switch (yyn) { - case 2: -#line 34 "QuantityParser.y" /* yacc.c:1646 */ - { QuantResult = Quantity(std::numeric_limits::min()); /* empty input */ } -#line 1305 "QuantityParser.c" /* yacc.c:1646 */ + case 2: /* input: %empty */ +#line 43 "Quantity.y" + { QuantResult = Quantity(std::numeric_limits::min()); /* empty input */ } +#line 1228 "Quantity.tab.c" break; - case 3: -#line 35 "QuantityParser.y" /* yacc.c:1646 */ - { QuantResult = (yyvsp[0]) ; } -#line 1311 "QuantityParser.c" /* yacc.c:1646 */ + case 3: /* input: num */ +#line 44 "Quantity.y" + { QuantResult = yyvsp[0]; } +#line 1234 "Quantity.tab.c" break; - case 4: -#line 36 "QuantityParser.y" /* yacc.c:1646 */ - { QuantResult = (yyvsp[0]) ; } -#line 1317 "QuantityParser.c" /* yacc.c:1646 */ + case 4: /* input: unit */ +#line 45 "Quantity.y" + { QuantResult = yyvsp[0]; } +#line 1240 "Quantity.tab.c" break; - case 5: -#line 37 "QuantityParser.y" /* yacc.c:1646 */ - { QuantResult = (yyvsp[0]) ; } -#line 1323 "QuantityParser.c" /* yacc.c:1646 */ + case 5: /* input: quantity */ +#line 46 "Quantity.y" + { QuantResult = yyvsp[0]; } +#line 1246 "Quantity.tab.c" break; - case 6: -#line 38 "QuantityParser.y" /* yacc.c:1646 */ - { QuantResult = (yyvsp[-1]) + (yyvsp[0]); } -#line 1329 "QuantityParser.c" /* yacc.c:1646 */ + case 6: /* input: quantity quantity */ +#line 47 "Quantity.y" + { QuantResult = yyvsp[-1] + yyvsp[0]; } +#line 1252 "Quantity.tab.c" break; - case 7: -#line 39 "QuantityParser.y" /* yacc.c:1646 */ - { QuantResult = (yyvsp[-2]) + (yyvsp[-1]) + (yyvsp[0]); } -#line 1335 "QuantityParser.c" /* yacc.c:1646 */ + case 7: /* input: quantity quantity quantity */ +#line 48 "Quantity.y" + { QuantResult = yyvsp[-2] + yyvsp[-1] + yyvsp[0]; } +#line 1258 "Quantity.tab.c" break; - case 8: -#line 41 "QuantityParser.y" /* yacc.c:1646 */ - { (yyval) = (yyvsp[0]); } -#line 1341 "QuantityParser.c" /* yacc.c:1646 */ + case 8: /* num: NUM */ +#line 50 "Quantity.y" + { yyval = yyvsp[0]; } +#line 1264 "Quantity.tab.c" break; - case 9: -#line 42 "QuantityParser.y" /* yacc.c:1646 */ - { (yyval) = (yyvsp[0]); } -#line 1347 "QuantityParser.c" /* yacc.c:1646 */ + case 9: /* num: ONE */ +#line 51 "Quantity.y" + { yyval = yyvsp[0]; } +#line 1270 "Quantity.tab.c" break; - case 10: -#line 43 "QuantityParser.y" /* yacc.c:1646 */ - { (yyval) = Quantity((yyvsp[-2]).getValue() + (yyvsp[0]).getValue()); } -#line 1353 "QuantityParser.c" /* yacc.c:1646 */ + case 10: /* num: num '+' num */ +#line 52 "Quantity.y" + { yyval = Quantity(yyvsp[-2].getValue() + yyvsp[0].getValue()); } +#line 1276 "Quantity.tab.c" break; - case 11: -#line 44 "QuantityParser.y" /* yacc.c:1646 */ - { (yyval) = Quantity((yyvsp[-2]).getValue() - (yyvsp[0]).getValue()); } -#line 1359 "QuantityParser.c" /* yacc.c:1646 */ + case 11: /* num: num MINUSSIGN num */ +#line 53 "Quantity.y" + { yyval = Quantity(yyvsp[-2].getValue() - yyvsp[0].getValue()); } +#line 1282 "Quantity.tab.c" break; - case 12: -#line 45 "QuantityParser.y" /* yacc.c:1646 */ - { (yyval) = Quantity((yyvsp[-2]).getValue() * (yyvsp[0]).getValue()); } -#line 1365 "QuantityParser.c" /* yacc.c:1646 */ + case 12: /* num: num '*' num */ +#line 54 "Quantity.y" + { yyval = Quantity(yyvsp[-2].getValue() * yyvsp[0].getValue()); } +#line 1288 "Quantity.tab.c" break; - case 13: -#line 46 "QuantityParser.y" /* yacc.c:1646 */ - { (yyval) = Quantity((yyvsp[-2]).getValue() / (yyvsp[0]).getValue()); } -#line 1371 "QuantityParser.c" /* yacc.c:1646 */ + case 13: /* num: num '/' num */ +#line 55 "Quantity.y" + { yyval = Quantity(yyvsp[-2].getValue() / yyvsp[0].getValue()); } +#line 1294 "Quantity.tab.c" break; - case 14: -#line 47 "QuantityParser.y" /* yacc.c:1646 */ - { (yyval) = Quantity(-(yyvsp[0]).getValue()); } -#line 1377 "QuantityParser.c" /* yacc.c:1646 */ + case 14: /* num: MINUSSIGN num */ +#line 56 "Quantity.y" + { yyval = Quantity(-yyvsp[0].getValue()); } +#line 1300 "Quantity.tab.c" break; - case 15: -#line 48 "QuantityParser.y" /* yacc.c:1646 */ - { (yyval) = Quantity(pow ((yyvsp[-2]).getValue(), (yyvsp[0]).getValue()));} -#line 1383 "QuantityParser.c" /* yacc.c:1646 */ + case 15: /* num: num '^' num */ +#line 57 "Quantity.y" + { yyval = Quantity(pow(yyvsp[-2].getValue(), yyvsp[0].getValue())); } +#line 1306 "Quantity.tab.c" break; - case 16: -#line 49 "QuantityParser.y" /* yacc.c:1646 */ - { (yyval) = (yyvsp[-1]); } -#line 1389 "QuantityParser.c" /* yacc.c:1646 */ + case 16: /* num: '(' num ')' */ +#line 58 "Quantity.y" + { yyval = yyvsp[-1]; } +#line 1312 "Quantity.tab.c" break; - case 17: -#line 50 "QuantityParser.y" /* yacc.c:1646 */ - { (yyval) = Quantity(acos((yyvsp[-1]).getValue())); } -#line 1395 "QuantityParser.c" /* yacc.c:1646 */ + case 17: /* num: ACOS '(' num ')' */ +#line 59 "Quantity.y" + { yyval = Quantity(acos(yyvsp[-1].getValue())); } +#line 1318 "Quantity.tab.c" break; - case 18: -#line 51 "QuantityParser.y" /* yacc.c:1646 */ - { (yyval) = Quantity(asin((yyvsp[-1]).getValue())); } -#line 1401 "QuantityParser.c" /* yacc.c:1646 */ + case 18: /* num: ASIN '(' num ')' */ +#line 60 "Quantity.y" + { yyval = Quantity(asin(yyvsp[-1].getValue())); } +#line 1324 "Quantity.tab.c" break; - case 19: -#line 52 "QuantityParser.y" /* yacc.c:1646 */ - { (yyval) = Quantity(atan((yyvsp[-1]).getValue())); } -#line 1407 "QuantityParser.c" /* yacc.c:1646 */ + case 19: /* num: ATAN '(' num ')' */ +#line 61 "Quantity.y" + { yyval = Quantity(atan(yyvsp[-1].getValue())); } +#line 1330 "Quantity.tab.c" break; - case 20: -#line 53 "QuantityParser.y" /* yacc.c:1646 */ - { (yyval) = Quantity(fabs((yyvsp[-1]).getValue())); } -#line 1413 "QuantityParser.c" /* yacc.c:1646 */ + case 20: /* num: ABS '(' num ')' */ +#line 62 "Quantity.y" + { yyval = Quantity(fabs(yyvsp[-1].getValue())); } +#line 1336 "Quantity.tab.c" break; - case 21: -#line 54 "QuantityParser.y" /* yacc.c:1646 */ - { (yyval) = Quantity(exp((yyvsp[-1]).getValue())); } -#line 1419 "QuantityParser.c" /* yacc.c:1646 */ + case 21: /* num: EXP '(' num ')' */ +#line 63 "Quantity.y" + { yyval = Quantity(exp(yyvsp[-1].getValue())); } +#line 1342 "Quantity.tab.c" break; - case 22: -#line 55 "QuantityParser.y" /* yacc.c:1646 */ - { (yyval) = Quantity(log((yyvsp[-1]).getValue())); } -#line 1425 "QuantityParser.c" /* yacc.c:1646 */ + case 22: /* num: LOG '(' num ')' */ +#line 64 "Quantity.y" + { yyval = Quantity(log(yyvsp[-1].getValue())); } +#line 1348 "Quantity.tab.c" break; - case 23: -#line 56 "QuantityParser.y" /* yacc.c:1646 */ - { (yyval) = Quantity(log10((yyvsp[-1]).getValue())); } -#line 1431 "QuantityParser.c" /* yacc.c:1646 */ + case 23: /* num: LOG10 '(' num ')' */ +#line 65 "Quantity.y" + { yyval = Quantity(log10(yyvsp[-1].getValue())); } +#line 1354 "Quantity.tab.c" break; - case 24: -#line 57 "QuantityParser.y" /* yacc.c:1646 */ - { (yyval) = Quantity(sin((yyvsp[-1]).getValue())); } -#line 1437 "QuantityParser.c" /* yacc.c:1646 */ + case 24: /* num: SIN '(' num ')' */ +#line 66 "Quantity.y" + { yyval = Quantity(sin(yyvsp[-1].getValue())); } +#line 1360 "Quantity.tab.c" break; - case 25: -#line 58 "QuantityParser.y" /* yacc.c:1646 */ - { (yyval) = Quantity(sinh((yyvsp[-1]).getValue())); } -#line 1443 "QuantityParser.c" /* yacc.c:1646 */ + case 25: /* num: SINH '(' num ')' */ +#line 67 "Quantity.y" + { yyval = Quantity(sinh(yyvsp[-1].getValue())); } +#line 1366 "Quantity.tab.c" break; - case 26: -#line 59 "QuantityParser.y" /* yacc.c:1646 */ - { (yyval) = Quantity(tan((yyvsp[-1]).getValue())); } -#line 1449 "QuantityParser.c" /* yacc.c:1646 */ + case 26: /* num: TAN '(' num ')' */ +#line 68 "Quantity.y" + { yyval = Quantity(tan(yyvsp[-1].getValue())); } +#line 1372 "Quantity.tab.c" break; - case 27: -#line 60 "QuantityParser.y" /* yacc.c:1646 */ - { (yyval) = Quantity(tanh((yyvsp[-1]).getValue())); } -#line 1455 "QuantityParser.c" /* yacc.c:1646 */ + case 27: /* num: TANH '(' num ')' */ +#line 69 "Quantity.y" + { yyval = Quantity(tanh(yyvsp[-1].getValue())); } +#line 1378 "Quantity.tab.c" break; - case 28: -#line 61 "QuantityParser.y" /* yacc.c:1646 */ - { (yyval) = Quantity(sqrt((yyvsp[-1]).getValue())); } -#line 1461 "QuantityParser.c" /* yacc.c:1646 */ + case 28: /* num: SQRT '(' num ')' */ +#line 70 "Quantity.y" + { yyval = Quantity(sqrt(yyvsp[-1].getValue())); } +#line 1384 "Quantity.tab.c" break; - case 29: -#line 62 "QuantityParser.y" /* yacc.c:1646 */ - { (yyval) = Quantity(cos((yyvsp[-1]).getValue())); } -#line 1467 "QuantityParser.c" /* yacc.c:1646 */ + case 29: /* num: COS '(' num ')' */ +#line 71 "Quantity.y" + { yyval = Quantity(cos(yyvsp[-1].getValue())); } +#line 1390 "Quantity.tab.c" break; - case 30: -#line 65 "QuantityParser.y" /* yacc.c:1646 */ - { (yyval) = (yyvsp[0]); } -#line 1473 "QuantityParser.c" /* yacc.c:1646 */ + case 30: /* unit: UNIT */ +#line 74 "Quantity.y" + { yyval = yyvsp[0]; } +#line 1396 "Quantity.tab.c" break; - case 31: -#line 66 "QuantityParser.y" /* yacc.c:1646 */ - { (yyval) = Quantity(1.0)/(yyvsp[0]); } -#line 1479 "QuantityParser.c" /* yacc.c:1646 */ + case 31: /* unit: ONE '/' unit */ +#line 75 "Quantity.y" + { yyval = Quantity(1.0)/yyvsp[0]; } +#line 1402 "Quantity.tab.c" break; - case 32: -#line 67 "QuantityParser.y" /* yacc.c:1646 */ - { (yyval) = (yyvsp[-2]) * (yyvsp[0]); } -#line 1485 "QuantityParser.c" /* yacc.c:1646 */ + case 32: /* unit: unit '*' unit */ +#line 76 "Quantity.y" + { yyval = yyvsp[-2] * yyvsp[0]; } +#line 1408 "Quantity.tab.c" break; - case 33: -#line 68 "QuantityParser.y" /* yacc.c:1646 */ - { (yyval) = (yyvsp[-2]) / (yyvsp[0]); } -#line 1491 "QuantityParser.c" /* yacc.c:1646 */ + case 33: /* unit: unit '/' unit */ +#line 77 "Quantity.y" + { yyval = yyvsp[-2] / yyvsp[0]; } +#line 1414 "Quantity.tab.c" break; - case 34: -#line 69 "QuantityParser.y" /* yacc.c:1646 */ - { (yyval) = (yyvsp[-2]).pow ((yyvsp[0])); } -#line 1497 "QuantityParser.c" /* yacc.c:1646 */ + case 34: /* unit: unit '^' num */ +#line 78 "Quantity.y" + { yyval = yyvsp[-2].pow (yyvsp[0]); } +#line 1420 "Quantity.tab.c" break; - case 35: -#line 70 "QuantityParser.y" /* yacc.c:1646 */ - { (yyval) = (yyvsp[-1]); } -#line 1503 "QuantityParser.c" /* yacc.c:1646 */ + case 35: /* unit: '(' unit ')' */ +#line 79 "Quantity.y" + { yyval = yyvsp[-1]; } +#line 1426 "Quantity.tab.c" break; - case 36: -#line 72 "QuantityParser.y" /* yacc.c:1646 */ - { (yyval) = (yyvsp[-1])*(yyvsp[0]); } -#line 1509 "QuantityParser.c" /* yacc.c:1646 */ + case 36: /* quantity: num unit */ +#line 81 "Quantity.y" + { yyval = yyvsp[-1]*yyvsp[0]; } +#line 1432 "Quantity.tab.c" break; - case 37: -#line 73 "QuantityParser.y" /* yacc.c:1646 */ - { (yyval) = Quantity((yyvsp[-2]))/(yyvsp[0]); } -#line 1515 "QuantityParser.c" /* yacc.c:1646 */ + case 37: /* quantity: num '/' unit */ +#line 82 "Quantity.y" + { yyval = Quantity(yyvsp[-2])/yyvsp[0]; } +#line 1438 "Quantity.tab.c" break; -#line 1519 "QuantityParser.c" /* yacc.c:1646 */ +#line 1442 "Quantity.tab.c" + default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -1530,25 +1454,23 @@ yyreduce: case of YYERROR or YYBACKUP, subsequent parser actions might lead to an incorrect destructor call or verbose syntax error message before the lookahead is translated. */ - YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc); YYPOPSTACK (yylen); yylen = 0; - YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval; /* Now 'shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ - - yyn = yyr1[yyn]; - - yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; - if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTOKENS]; + { + const int yylhs = yyr1[yyn] - YYNTOKENS; + const int yyi = yypgoto[yylhs] + *yyssp; + yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp + ? yytable[yyi] + : yydefgoto[yylhs]); + } goto yynewstate; @@ -1559,50 +1481,14 @@ yyreduce: yyerrlab: /* Make sure we have latest lookahead translation. See comments at user semantic actions for why this is necessary. */ - yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); - + yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar); /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { ++yynerrs; -#if ! YYERROR_VERBOSE yyerror (YY_("syntax error")); -#else -# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ - yyssp, yytoken) - { - char const *yymsgp = YY_("syntax error"); - int yysyntax_error_status; - yysyntax_error_status = YYSYNTAX_ERROR; - if (yysyntax_error_status == 0) - yymsgp = yymsg; - else if (yysyntax_error_status == 1) - { - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); - yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); - if (!yymsg) - { - yymsg = yymsgbuf; - yymsg_alloc = sizeof yymsgbuf; - yysyntax_error_status = 2; - } - else - { - yysyntax_error_status = YYSYNTAX_ERROR; - yymsgp = yymsg; - } - } - yyerror (yymsgp); - if (yysyntax_error_status == 2) - goto yyexhaustedlab; - } -# undef YYSYNTAX_ERROR -#endif } - - if (yyerrstatus == 3) { /* If just tried and failed to reuse lookahead token after an @@ -1631,12 +1517,11 @@ yyerrlab: | yyerrorlab -- error raised explicitly by YYERROR. | `---------------------------------------------------*/ yyerrorlab: - - /* Pacify compilers like GCC when the user code never invokes - YYERROR and the label yyerrorlab therefore never appears in user - code. */ - if (/*CONSTCOND*/ 0) - goto yyerrorlab; + /* Pacify compilers when the user code never invokes YYERROR and the + label yyerrorlab therefore never appears in user code. */ + if (0) + YYERROR; + ++yynerrs; /* Do not reclaim the symbols of the rule whose action triggered this YYERROR. */ @@ -1653,13 +1538,14 @@ yyerrorlab: yyerrlab1: yyerrstatus = 3; /* Each real token shifted decrements this. */ + /* Pop stack until we find a state that shifts the error token. */ for (;;) { yyn = yypact[yystate]; if (!yypact_value_is_default (yyn)) { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + yyn += YYSYMBOL_YYerror; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror) { yyn = yytable[yyn]; if (0 < yyn) @@ -1673,7 +1559,7 @@ yyerrlab1: yydestruct ("Error: popping", - yystos[yystate], yyvsp); + YY_ACCESSING_SYMBOL (yystate), yyvsp); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); @@ -1685,7 +1571,7 @@ yyerrlab1: /* Shift the error token. */ - YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp); yystate = yyn; goto yynewstate; @@ -1696,26 +1582,30 @@ yyerrlab1: `-------------------------------------*/ yyacceptlab: yyresult = 0; - goto yyreturn; + goto yyreturnlab; + /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ yyabortlab: yyresult = 1; - goto yyreturn; + goto yyreturnlab; -#if !defined yyoverflow || YYERROR_VERBOSE -/*-------------------------------------------------. -| yyexhaustedlab -- memory exhaustion comes here. | -`-------------------------------------------------*/ + +/*-----------------------------------------------------------. +| yyexhaustedlab -- YYNOMEM (memory exhaustion) comes here. | +`-----------------------------------------------------------*/ yyexhaustedlab: yyerror (YY_("memory exhausted")); yyresult = 2; - /* Fall through. */ -#endif + goto yyreturnlab; -yyreturn: + +/*----------------------------------------------------------. +| yyreturnlab -- parsing is finished, clean up and return. | +`----------------------------------------------------------*/ +yyreturnlab: if (yychar != YYEMPTY) { /* Make sure we have latest lookahead translation. See comments at @@ -1731,19 +1621,15 @@ yyreturn: while (yyssp != yyss) { yydestruct ("Cleanup: popping", - yystos[*yyssp], yyvsp); + YY_ACCESSING_SYMBOL (+*yyssp), yyvsp); YYPOPSTACK (1); } #ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss); #endif -#if YYERROR_VERBOSE - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); -#endif + return yyresult; } -#line 77 "QuantityParser.y" /* yacc.c:1906 */ -// clang-format on +#line 85 "Quantity.y" diff --git a/src/Base/QuantityParser.y b/src/Base/Quantity.y similarity index 100% rename from src/Base/QuantityParser.y rename to src/Base/Quantity.y diff --git a/src/Base/QuantityParser.h b/src/Base/QuantityParser.h deleted file mode 100644 index 7143ebc41e..0000000000 --- a/src/Base/QuantityParser.h +++ /dev/null @@ -1,85 +0,0 @@ -// clang-format off -/* A Bison parser, made by GNU Bison 3.0.4. */ - -/* Bison interface for Yacc-like parsers in C - - Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. - - 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 3 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 this program. If not, see . */ - -/* As a special exception, you may create a larger work that contains - part or all of the Bison parser skeleton and distribute that work - under terms of your choice, so long as that work isn't itself a - parser generator using the skeleton or a modified version thereof - as a parser skeleton. Alternatively, if you modify or redistribute - the parser skeleton itself, you may (at your option) remove this - special exception, which will cause the skeleton and the resulting - Bison output files to be licensed under the GNU General Public - License without this special exception. - - This special exception was added by the Free Software Foundation in - version 2.2 of Bison. */ - -#ifndef YY_YY_QUANTITYPARSER_H_INCLUDED -# define YY_YY_QUANTITYPARSER_H_INCLUDED -/* Debug traces. */ -#ifndef YYDEBUG -# define YYDEBUG 0 -#endif -#if YYDEBUG -extern int yydebug; -#endif - -/* Token type. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - enum yytokentype - { - UNIT = 258, - NUM = 259, - MINUSSIGN = 260, - ACOS = 261, - ASIN = 262, - ATAN = 263, - ATAN2 = 264, - COS = 265, - EXP = 266, - ABS = 267, - MOD = 268, - LOG = 269, - LOG10 = 270, - POW = 271, - SIN = 272, - SINH = 273, - TAN = 274, - TANH = 275, - SQRT = 276, - NEG = 277 - }; -#endif - -/* Value type. */ -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -typedef int YYSTYPE; -# define YYSTYPE_IS_TRIVIAL 1 -# define YYSTYPE_IS_DECLARED 1 -#endif - - -extern YYSTYPE yylval; - -int yyparse (void); - -#endif /* !YY_YY_QUANTITYPARSER_H_INCLUDED */ -// clang-format on