- Bison
- yacc
- Зависимости Bison
- Saved searches
- Use saved searches to filter your results more quickly
- License
- akimd/bison
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
- Что такое bison linux
- NAME
- SYNOPSIS
- DESCRIPTION
- FILES
- SEE ALSO
Bison
bison — генератор анализаторов синтаксиса (parser) выражений (заменяет yacc — Yet Another Compiler Compiler). Что же делает bison? Это программа, генерирующая программу, анализирующую структуру текстового файла. Вместо написания собственной программы пользователь указывает, как соотносятся объекты, и основываясь на данных правилах, создается анализатор. Существует множество примеров анализа синтаксиса, например калькулятор.
Человек легко получит результат 7. Почему? Because of the structure. Наш мозг знает, как интерпретировать выражение. Компьютер этого не знает, и bison инструмент, представляющий выражение компьютеру в следующем виде:
Начиная с вершины дерева и обрабатывая 2 and 3, соединенных знаком умножения, компьютер перемножает 2 и 3. Результат умножения запоминается и следующее, что обрабатывается — 2*3 и 1, соединенные знаком сложения. Сложение 1 и предыдущего результата дает 7. Все составные выражения могут быть преобразованы в подобное дерево и вычислены. Конечно же, bison используется не только в калькуляторах.
yacc
Мы написали скрипт bash с именем yacc, вызывающий bison с опцией -y. Это необходимо для совместимости с программами, использующими yacc вместо bison.
Зависимости Bison
Последняя проверка: версия 1.31.
Bash: sh
Binutils: ar, as, ld, ranlib
Diffutils: cmp
Fileutils: chmod, cp, install, ln, ls, mkdir, mv, rm, rmdir
Gcc: cc, cc1, collect2, cpp0, gcc
Grep: egrep, fgrep, grep
Make: make
Sed: sed
Sh-utils: basename, dirname, echo, expr, hostname, sleep, uname
Texinfo: install-info
Textutils: cat, head, tr, uniq
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
License
akimd/bison
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
* src/counterexample.c (counterexample_init): Remove stray debug trace. Complain about invalid values. * tests/input.at (-Dcex.timeout): New.
Git stats
Files
Failed to load latest commit information.
README.md
GNU Bison is a general-purpose parser generator that converts an annotated context-free grammar into a deterministic LR or generalized LR (GLR) parser employing LALR(1) parser tables. Bison can also generate IELR(1) or canonical LR(1) parser tables. Once you are proficient with Bison, you can use it to develop a wide range of language parsers, from those used in simple desk calculators to complex programming languages.
Bison is upward compatible with Yacc: all properly-written Yacc grammars work with Bison with no change. Anyone familiar with Yacc should be able to use Bison with little trouble. You need to be fluent in C, C++, D or Java programming in order to use Bison.
Bison and the parsers it generates are portable, they do not require any specific compilers.
The README-hacking.md file is about building, modifying and checking Bison. See its «Working from the Repository» section to build Bison from the git repo. Roughly, run:
$ git submodule update --init $ ./bootstrap
then proceed with the usual configure && make steps.
See the INSTALL file for generic compilation and installation instructions.
Running a non installed bison
Once you ran make , you might want to toy with this fresh bison before installing it. In that case, do not use src/bison : it would use the installed files (skeletons, etc.), not the local ones. Use tests/bison .
As an experimental feature, diagnostics are now colored, controlled by the —color and —style options.
To use them, install the libtextstyle library, 0.20.5 or newer, before configuring Bison. It is available from https://alpha.gnu.org/gnu/gettext/, for instance https://alpha.gnu.org/gnu/gettext/libtextstyle-0.20.5.tar.gz, or as part of Gettext 0.21 or newer, for instance https://ftp.gnu.org/gnu/gettext/gettext-0.21.tar.gz.
The option —color supports the following arguments:
- always, yes: Enable colors.
- never, no: Disable colors.
- auto, tty (default): Enable colors if the output device is a tty.
To customize the styles, create a CSS file, say bison-bw.css , similar to
/* bison-bw.css */ .warning < >.error < font-weight: 800; text-decoration: underline; >.note
then invoke bison with —style=bison-bw.css , or set the BISON_STYLE environment variable to bison-bw.css .
In some diagnostics, bison uses libtextstyle to emit special escapes to generate clickable hyperlinks. The environment variable NO_TERM_HYPERLINKS can be used to suppress them. This may be useful for terminal emulators which produce garbage output when they receive the escape sequence for a hyperlink. Currently (as of 2020), this affects some versions of emacs, guake, konsole, lxterminal, rxvt, yakuake.
If you pass —enable-relocatable to configure , Bison is relocatable.
A relocatable program can be moved or copied to a different location on the file system. It can also be used through mount points for network sharing. It is possible to make symlinks to the installed and moved programs, and invoke them through the symlink.
See «Enabling Relocatability» in the documentation.
Bison supports two catalogs: one for Bison itself (i.e., for the maintainer-side parser generation), and one for the generated parsers (i.e., for the user-side parser execution). The requirements between both differ: bison needs ngettext, the generated parsers do not. To simplify the build system, neither are installed if ngettext is not supported, even if generated parsers could have been localized. See https://lists.gnu.org/r/bug-bison/2009-08/msg00006.html for more details.
See the section FAQ in the documentation (doc/bison.info) for frequently asked questions. The documentation is also available in PDF and HTML, provided you have a recent version of Texinfo installed: run make pdf or make html .
If you have questions about using Bison and the documentation does not answer them, please send mail to help-bison@gnu.org.
Please send bug reports to bug-bison@gnu.org. Be sure to include the version number from bison —version , and a complete, self-contained test case in each bug report.
For any copyright year range specified as YYYY-ZZZZ in this package, note that the range specifies every single year in that closed interval.
Что такое bison linux
NAME
bison - GNU Project parser generator (yacc replacement)
SYNOPSIS
bison [ -b file-prefix ] [ --file-prefix=file-prefix ] [ -d ] [ --defines ] [ -l ] [ --no- lines ] [ -o outfile ] [ --output-file=outfile ] [ -p prefix ] [ --name-prefix=prefix ] [ -t ] [ --debug ] [ -v ] [ --verbose ] [ -V ] [ --version ] [ -y ] [ --yacc ] [ --fixed- output-files ] file
DESCRIPTION
Bison is a parser generator in the style of yacc(1). It should be upwardly compatible with input files designed for yacc. Input files should follow the yacc convention of ending in .y. Unlike yacc, the generated files do not have fixed names, but instead use the prefix of the input file. For instance, a grammar description file named parse.y would produce the generated parser in a file named parse.tab.c, instead of yacc's y.tab.c. This description of the options that can be given to bison is adapted from the node Invocation in the bison.texinfo manual, which should be taken as authoritative. Bison supports both traditional single-letter options and mnemonic long option names. Long option names are indicated with -- instead of -. Abbreviations for option names are allowed as long as they are unique. When a long option takes an argument, like --file- prefix, connect the option name and the argument with =. OPTIONS -b file-prefix --file-prefix=file-prefix Specify a prefix to use for all bison output file names. The names are chosen as if the input file were named file-prefix.c. -d --defines Write an extra output file containing macro definitions for the token type names defined in the grammar and the semantic value type YYSTYPE, as well as a few extern variable declarations. If the parser output file is named name.c then this file is named name.h. This output file is essential if you wish to put the definition of yylex in a separate source file, because yylex needs to be able to refer to token type codes and the variable yylval. -l --no-lines Don't put any #line preprocessor commands in the parser file. Ordinarily bison puts them in the parser file so that the C compiler and debuggers will associate errors with your source file, the grammar file. This option causes them to associate errors with the parser file, treating it an independent source file in its own right. -o outfile --output-file=outfile Specify the name outfile for the parser file. The other output files' names are constructed from outfile as described under the -v and -d switches. -p prefix --name-prefix=prefix Rename the external symbols used in the parser so that they start with prefix instead of yy. The precise list of symbols renamed is yyparse, yylex, yyerror, yylval, yychar, and yydebug. For example, if you use -p c, the names become cparse, clex, and so on. -t --debug Output a definition of the macro YYDEBUG into the parser file, so that the debugging facilities are compiled. -v --verbose Write an extra output file containing verbose descriptions of the parser states and what is done for each type of look-ahead token in that state. This file also describes all the conflicts, both those resolved by operator precedence and the unresolved ones. The file's name is made by removing .tab.c or .c from the parser output file name, and adding .output instead. Therefore, if the input file is foo.y, then the parser file is called foo.tab.c by default. As a consequence, the verbose output file is called foo.output. -V --version Print the version number of bison. -y --yacc --fixed-output-files Equivalent to -o y.tab.c; the parser output file is called y.tab.c, and the other outputs are called y.output and y.tab.h. The purpose of this switch is to imitate yacc's output file name conventions. Thus, the following shell script can substitute for yacc: bison -y $* The long-named options can be introduced with `+' as well as `--', for compatibility with previous releases. Eventually support for `+' will be removed, because it is incompatible with the POSIX.2 standard.
FILES
/usr/local/lib/bison.simple simple parser /usr/local/lib/bison.hairy complicated parser
SEE ALSO
yacc(1) The Bison Reference Manual, included as the file bison.texinfo in the bison source distribution.