### Running Specific Example Tests with Make Source: https://github.com/akimd/bison/blob/master/README-hacking.md This command runs a specific test from the examples suite. It uses `make check-examples` and filters the tests using the `TESTS` environment variable to target a single test file. ```Shell make check-examples TESTS='examples/c/bistromathic/bistromathic.test' ``` -------------------------------- ### Installing Build Dependencies on Debian/Ubuntu Source: https://github.com/akimd/bison/blob/master/README-hacking.md This shell command installs the necessary development tools and libraries required to build Bison from source on Debian-based GNU/Linux systems like Ubuntu. It includes tools such as Autoconf, Automake, Flex, Gperf, Graphviz, Help2man, Texinfo, and Valgrind. ```shell sudo apt-get install \ autoconf automake autopoint flex gperf graphviz help2man texinfo valgrind ``` -------------------------------- ### Installing GCC 4.6 on Ubuntu Xenial via APT Source: https://github.com/akimd/bison/blob/master/README-hacking.md This series of `apt-get` commands updates package lists, adds the Ubuntu toolchain test PPA, and then installs GCC 4.6, G++ 4.6, m4, and make, providing an environment for compiling with an older GCC version. ```Shell apt-get update apt-get install software-properties-common apt-add-repository -y "ppa:ubuntu-toolchain-r/test" apt-get update apt-get install -y gcc-4.6 g++-4.6 m4 make ``` -------------------------------- ### Installing Multiple Bison Versions with GNU Stow (Shell) Source: https://github.com/akimd/bison/blob/master/README-hacking.md This shell script automates the process of downloading, configuring, and installing multiple specified versions of GNU Bison. It uses `wget` to fetch source archives, `tar` to extract them, and then configures each version with a `--prefix` suitable for GNU Stow, followed by compilation and installation. ```Shell for v in 3.7 3.7.1 do cd /tmp wget https://ftp.gnu.org/gnu/bison/bison-$v.tar.xz tar xf bison-$v.tar.xz cd bison-$v ./configure --prefix /usr/local/stow/bison-$v make -j4 sudo make install done ``` -------------------------------- ### Testing Gnulib Components (Basic) Source: https://github.com/akimd/bison/blob/master/README-hacking.md This snippet demonstrates how to run basic tests for a specific Gnulib component, such as 'bitset-tests', by navigating to the 'gnulib' directory and executing the 'gnulib-tool' with the '--test' option. ```Shell cd gnulib ./gnulib-tool --test bitset-tests ``` -------------------------------- ### Listing All Main Test Suite Tests Source: https://github.com/akimd/bison/blob/master/README-hacking.md This command executes the `testsuite` script directly to list all available tests and their associated keywords. This is useful for identifying tests to run with the `-k` option. ```Shell ./tests/testsuite -l ``` -------------------------------- ### Configuring, Building, and Testing Bison Source: https://github.com/akimd/bison/blob/master/README-hacking.md These commands perform the standard build process for Bison. `./configure` prepares the build system, `make` compiles the source code, and `make check` runs the test suite to verify the build's integrity and functionality. ```shell ./configure make make check ``` -------------------------------- ### Initializing Git Submodules for First Checkout Source: https://github.com/akimd/bison/blob/master/README-hacking.md This Git command initializes and updates the submodules (like gnulib) required by the Bison repository. It's a crucial step after the initial clone to ensure all dependencies are checked out to their correct versions. ```git git submodule update --init ``` -------------------------------- ### Example Syntax Error Output - Bistromathic Shell Source: https://github.com/akimd/bison/blob/master/examples/c/bistromathic/README.md This snippet illustrates a syntax error message generated by the bistromathic parser during an interactive session. It showcases the custom error reporting feature, which includes the error location, a list of expected tokens, and a visual underline (squiggles) indicating the exact point of the error in the input source line. ```Shell > 123 456 1.5-7: syntax error: expected end of file or + or - or * or / or ^ before number 1 | 123 456 | ^~~ ``` -------------------------------- ### Configuring and Running Gnulib Tests with Symlinks Source: https://github.com/akimd/bison/blob/master/README-hacking.md This sequence of commands sets up a test environment for Gnulib components using symlinks for re-runnability and immediate updates. It configures the build with a specific C compiler and debug flags, then runs the tests. ```Shell ./gnulib-tool --symlink --create-test --dir=/tmp/gnutest bitset-tests cd /tmp/gnutest ./configure -C CC='gcc-mp-8 -fsanitize=undefined' CFLAGS='-ggdb' make check ``` -------------------------------- ### ASAN Leak Sanitizer Suppression File Content Source: https://github.com/akimd/bison/blob/master/README-hacking.md This is an example content for a leak suppression file (`leak.supp`) used with Address Sanitizer (ASAN) and Leak Sanitizer (LSAN). It instructs the sanitizer to ignore leaks originating from `std::clog`, which might be necessary on certain platforms like Mac with G++. ```Text leak:std::clog ``` -------------------------------- ### Customizing Bison Diagnostic Styles with CSS Source: https://github.com/akimd/bison/blob/master/README.md This CSS snippet demonstrates how to define custom styles for Bison's colored diagnostics. It shows an example `bison-bw.css` file where `.warning`, `.error`, and `.note` classes can be styled. The example applies a bold font weight and underline to error messages. ```CSS /* bison-bw.css */ .warning { } .error { font-weight: 800; text-decoration: underline; } .note { } ``` -------------------------------- ### Testing Gnulib Components with Custom Compiler Source: https://github.com/akimd/bison/blob/master/README-hacking.md This command shows how to run Gnulib component tests using a specified C compiler and flags, in this case, 'gcc-mp-8' with undefined behavior sanitization, by setting the 'CC' environment variable. ```Shell CC='gcc-mp-8 -fsanitize=undefined' ./gnulib-tool --test bitset-tests ``` -------------------------------- ### Running Specific Category of Main Test Suite Tests Source: https://github.com/akimd/bison/blob/master/README-hacking.md This command runs the main test suite, filtering tests by a specific category or keyword using the `-k` option passed via `TESTSUITEFLAGS`. In this example, it runs only tests categorized as 'c++'. ```Shell make check-tests TESTSUITEFLAGS='-k c++' ``` -------------------------------- ### Running Bison Bootstrap Script Source: https://github.com/akimd/bison/blob/master/README-hacking.md This command executes the bootstrap script, which prepares the build environment by updating submodules to the versions registered in the top-level directory and generating necessary build files. It's essential for setting up the project after a fresh checkout or when gnulib is updated. ```shell ./bootstrap ``` -------------------------------- ### Updating a Git Submodule (gnulib) - Bash Source: https://github.com/akimd/bison/blob/master/README-hacking.md This snippet outlines the steps to navigate into a submodule directory, fetch the latest changes from the remote repository, and then check out or create a new 'master' branch that tracks the 'origin/master' branch, ensuring the submodule is up-to-date. ```bash cd gnulib git fetch git checkout -b master --track origin/master ``` -------------------------------- ### Generating Debug Symbols for Bison Executable Source: https://github.com/akimd/bison/blob/master/README-hacking.md This command uses `dsymutil` to generate debug symbols for the `bison` executable. This is crucial for effective debugging with tools like `lldb`, especially when using sanitizers. ```Shell dsymutil src/bison ``` -------------------------------- ### Rerunning Failed Tests in Parallel Source: https://github.com/akimd/bison/blob/master/README-hacking.md This command reruns only the tests that previously failed. The `-j5` flag enables parallel execution with 5 jobs, speeding up the re-checking process. ```Shell make recheck -j5 ``` -------------------------------- ### Verifying Bison Compatibility with Updated Submodule - Bash Source: https://github.com/akimd/bison/blob/master/README-hacking.md After updating a submodule, these commands are used to return to the parent directory, re-bootstrap the project (which might regenerate configuration files), and then run 'make distcheck' to ensure the project builds and passes all distribution checks with the updated submodule. ```bash cd .. ./bootstrap make distcheck ``` -------------------------------- ### Running Tests with ASAN Leak Detection Enabled Source: https://github.com/akimd/bison/blob/master/README-hacking.md This command runs a specific subset of the main test suite (`-k cex`) in parallel (`-j5`) while enabling Address Sanitizer's leak detection. The `ASAN_OPTIONS=detect_leaks=1` environment variable activates this feature. ```Shell make check-tests TESTSUITEFLAGS='-j5 -k cex' ASAN_OPTIONS=detect_leaks=1 ``` -------------------------------- ### Registering Submodule Changes - Git/Bash Source: https://github.com/akimd/bison/blob/master/README-hacking.md This command is a placeholder indicating that changes made to the submodule (e.g., updating its commit reference in the parent repository) should be committed to the main repository's Git history. The '...' implies adding a commit message. ```bash git commit ... ``` -------------------------------- ### Running Docker Container with Shared Volume Source: https://github.com/akimd/bison/blob/master/README-hacking.md This Docker command launches an interactive Ubuntu Xenial container, mounting the host's '/tmp' directory to the container's '/tmp' directory, facilitating file sharing between host and guest for testing old compilers. ```Shell docker run -v /tmp:/tmp -it ubuntu:xenial ``` -------------------------------- ### Checking for Local Git Differences Source: https://github.com/akimd/bison/blob/master/README-hacking.md This Git command displays the differences between the working directory and the index, or between two tree-ish objects. After a successful build and test, it's used to confirm that there are no unexpected local modifications compared to the repository's master copy. ```git git diff ``` -------------------------------- ### Running Debugger (lldb) with Sanitizers and Suppressions Source: https://github.com/akimd/bison/blob/master/README-hacking.md This command launches `lldb` to debug a specific test case, enabling various sanitizer options and leak suppression. It sets environment variables for `YYDEBUG`, `UBSAN_OPTIONS` (to print stack traces), `LSAN_OPTIONS` (with suppression file and no suppression printing), and `ASAN_OPTIONS` (for leak detection), then executes the test binary under the debugger. ```Shell YYDEBUG=1 \ UBSAN_OPTIONS=print_stacktrace=1 \ LSAN_OPTIONS=suppressions=$PWD/leak.supp,print_suppressions=0 \ ASAN_OPTIONS=detect_leaks=1 \ lldb -- ./_build/tests/testsuite.dir/712/glr-regr2a ./_build/tests/testsuite.dir/712/input1.txt ``` -------------------------------- ### Running Specific Category of Main Test Suite Tests in Parallel Source: https://github.com/akimd/bison/blob/master/README-hacking.md This command combines parallel execution (`-j8`) and keyword-based filtering (`-k c++`) for the main test suite. It runs only 'c++' categorized tests concurrently with 8 jobs. ```Shell make check-tests TESTSUITEFLAGS='-j8 -k c++' ``` -------------------------------- ### Configuring Bison with Address and Undefined Behavior Sanitizers (GCC/MacPorts) Source: https://github.com/akimd/bison/blob/master/README-hacking.md This `configure` command sets up the Bison build system to use Address Sanitizer (ASAN) and Undefined Behavior Sanitizer (UBSAN) with GCC 10 on MacPorts. It specifies compiler flags (`-fsanitize=address -fsanitize=undefined`) for both C and C++ compilers, includes paths, and debug symbols (`-ggdb`). ```Shell ./configure -C --enable-gcc-warnings \ CPPFLAGS='-isystem /opt/local/include' \ CC='gcc-mp-10 -fsanitize=address -fsanitize=undefined' \ CFLAGS='-ggdb' \ CXX='g++-mp-10.0 -fsanitize=address -fsanitize=undefined' \ CXXFLAGS='-ggdb' \ LDFLAGS='-L/opt/local/lib' ``` -------------------------------- ### Updating Git Submodules Recursively (Git 1.8.2+) Source: https://github.com/akimd/bison/blob/master/README-hacking.md For Git versions 1.8.2 and later, this command updates all submodules recursively to their latest versions as tracked by their respective remote repositories. It simplifies the process of keeping all nested dependencies up-to-date. ```git git submodule update --recursive --remote ``` -------------------------------- ### Running a Java Parser Test Case Source: https://github.com/akimd/bison/blob/master/README-hacking.md This command executes a specific Java parser test case using the `javaexec.sh` script. It sets the classpath (`-cp`) to the directory containing the compiled Java classes for test case 504 and specifies the main class `Calc` to run. ```Shell sh ./_build/javaexec.sh -cp ./_build/tests/testsuite.dir/504 Calc ``` -------------------------------- ### Running Main Test Suite in Parallel (TESTSUITEFLAGS) Source: https://github.com/akimd/bison/blob/master/README-hacking.md This command executes the main test suite (`make check-tests`) and uses the `TESTSUITEFLAGS` variable to pass options to the underlying Autotest framework. Here, `-j8` enables parallel execution with 8 jobs, speeding up the test run. ```Shell make check-tests TESTSUITEFLAGS='-j8' ``` -------------------------------- ### Updating Test Expectations Manually Source: https://github.com/akimd/bison/blob/master/README-hacking.md This command uses the `update-test` utility to automatically update test expectations based on the generated `testsuite.log` files. It should be run from the source tree after a test suite run, with `$build` replaced by the actual build directory path. ```Shell ./build-aux/update-test $build/tests/testsuite.dir/*/testsuite.log ``` -------------------------------- ### Updating Bison and Submodules After Pull Source: https://github.com/akimd/bison/blob/master/README-hacking.md These commands are used to update the Bison repository and its submodules. `git pull` fetches and integrates changes from the remote repository, and `git submodule update` ensures that any submodule references updated by the pull are checked out to their correct versions. ```git git pull git submodule update ``` -------------------------------- ### Running Main Test Suite in Parallel (Make -j) Source: https://github.com/akimd/bison/blob/master/README-hacking.md This command runs the main test suite (`make check-tests`) and directly passes the `-j8` flag to GNU Make. When using GNU Make, `TESTSUITEFLAGS` defaults to the `-jN` passed to it, achieving parallel execution with 8 jobs. ```Shell make check-tests -j8 ``` -------------------------------- ### Refreshing Generated Parser Files - Bash Source: https://github.com/akimd/bison/blob/master/README-hacking.md If the generated parser files (src/parse-gram.c and src/parse-gram.h) are older than their source (src/parse-gram.y) and cause issues, this command updates their modification timestamps. This forces the build system to regenerate them, resolving potential version mismatches with the current Bison. ```bash touch src/parse-gram.[ch] ``` -------------------------------- ### Indenting C Preprocessor Directives in Skeletons Source: https://github.com/akimd/bison/blob/master/README-hacking.md This snippet illustrates the recommended indentation style for C Preprocessor (CPP) directives within Bison skeletons. Each nested `#if`, `#ifdef`, `#ifndef`, or `#elif` block is indented by an additional space. This specific indentation applies to skeletons, while different rules may apply to `%code {...}` blocks in grammar files. ```CPP #if FOO # if BAR # define BAZ # endif #endif ``` -------------------------------- ### Recovering and Regenerating Parser Files - Git/Make/Bash Source: https://github.com/akimd/bison/blob/master/README-hacking.md This sequence of commands is used to recover from a corrupted parser state. It first reverts the generated parser files (src/parse-gram.c and src/parse-gram.h) to their previous version, then compiles Bison, updates the timestamp of the parser's source file (src/parse-gram.y) to force regeneration, and finally recompiles Bison to create new parser files. ```bash git checkout HEAD^ src/parse-gram.[ch] make -C _build touch src/parse-gram.y make -C _build ``` -------------------------------- ### Building Bison from Git Repository Source: https://github.com/akimd/bison/blob/master/README.md This snippet shows the initial commands required to prepare the Bison source repository for compilation when building from a Git clone. It initializes submodules and runs the bootstrap script to generate necessary build files before the standard configure and make steps. ```Shell $ git submodule update --init $ ./bootstrap ``` -------------------------------- ### Running calc++ Interactively with Standard Input Source: https://github.com/akimd/bison/blob/master/examples/c++/calc++/README.md This snippet demonstrates how to run the `calc++` program interactively, reading input from standard input. Users define variables and then provide an expression to be evaluated. The input is terminated by `Ctrl-d`, and the program outputs the result of the expression. The `calc++` executable is a prerequisite. ```Shell $ ./calc++ - one := 1 two := 2 three := 3 (one + two * three) * two * three 42 ``` -------------------------------- ### Running Benchmarks with Custom Bison and GCC in Shell Source: https://github.com/akimd/bison/blob/master/etc/README.md This command executes the `bench.pl` script, setting the `BISON` environment variable to use a specific Bison build from `_build/tests/bison` and the `CC` environment variable to use `gcc` with `-O2` optimization. This allows for benchmarking a non-installed Bison version with specific compiler flags. ```Shell BISON=_build/tests/bison CC='gcc -O2' ./bench.pl ``` -------------------------------- ### Parsing String Token Recursively in Bison (C) Source: https://github.com/akimd/bison/blob/master/examples/c/reccalc/README.md This Bison rule defines how an `exp` (expression) is handled when it's a `STR` (string token). It recursively parses the string token using `parse_string`, frees the allocated memory for the string, and handles any parsing errors by incrementing the error count and invoking `YYERROR`. If parsing is successful, the result's value is assigned to the current rule's semantic value. ```C exp: STR { result r = parse_string ($1); free ($1); if (r.nerrs) { res->nerrs += r.nerrs; YYERROR; } else $$ = r.value; } ``` -------------------------------- ### Retrieving Semantic Values with b4_symbol_value (C/C++) Source: https://github.com/akimd/bison/blob/master/data/README.md This macro is used for expanding semantic value references like `$$`, `$1`, or `3`. It takes a semantic value storage (`VAL`), an optional `SYMBOL-NUM` to infer the type tag, and an optional `TYPE-TAG` if explicitly provided by the user. The result is safely parenthesized to prevent precedence issues. ```C b4_symbol_value(VAL, [SYMBOL-NUM], [TYPE-TAG]) ``` -------------------------------- ### Accessing Symbol Properties with b4_symbol (C/C++) Source: https://github.com/akimd/bison/blob/master/data/README.md This macro unifies the handling of various symbol aspects (tag, type name, terminal status, etc.) within Bison. It takes a symbol number (`NUM`) and a `FIELD` identifier to retrieve specific properties. `NUM` refers to the final internal symbol number, while `FIELD` specifies the desired attribute, such as `id`, `tag`, `code`, `kind`, `number`, or semantic value related properties. ```C b4_symbol(NUM, FIELD) ``` -------------------------------- ### Accessing RHS Symbol Data with b4_rhs_data (C/C++) Source: https://github.com/akimd/bison/blob/master/data/README.md This macro provides access to the data corresponding to a specific symbol on the right-hand side (RHS) of a grammar rule. It takes the `RULE-LENGTH` (total number of symbols on the RHS) and the `POS` (position of the desired symbol, 0-indexed) to retrieve its associated data. ```C b4_rhs_data(RULE-LENGTH, POS) ``` -------------------------------- ### Accessing LHS Semantic Value with b4_lhs_value (C/C++) Source: https://github.com/akimd/bison/blob/master/data/README.md This macro facilitates the expansion of the left-hand side (LHS) semantic value, typically represented as `$$` or `$$`. It requires the `SYMBOL-NUM` of the LHS nonterminal and an optional `TYPE` if a specific type is forced. This ensures correct type access for the result of a grammar rule. ```C b4_lhs_value(SYMBOL-NUM, [TYPE]) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.