bool

Програм за тестирање логичких израза
git clone https://git.sr.ht/~strahinja/bool
Дневник | Датотеке | Референце | ПРОЧИТАЈМЕ | ЛИЦЕНЦА

bool.1.in (3569B)


      1 .\" This program is licensed under the terms of GNU GPL v3 or (at your option)
      2 .\" any later version. Copyright (C) 2026 Страхиња Радић.
      3 .\" See the file LICENSE for exact copyright and license details.
      4 .Dd %DATE%
      5 .Dt BOOL 1
      6 .Os
      7 .Sh NAME
      8 .Nm bool
      9 .Nd Logical expression tester
     10 .Sh SYNOPSIS
     11 .Nm
     12 .Fl hVv
     13 .Nm
     14 .Op Fl dt
     15 .Op Ar filename
     16 .Sh DESCRIPTION
     17 .Nm
     18 is a logical expression tester.
     19 It takes a logical expression as input, containing logical variable names,
     20 parentheses and logical operators, and for each combination of values of
     21 different variables outputs the values of variables and the evaluated value of
     22 the expression, separated by TAB characters (like a TSV table).
     23 The logical expression is read from the file
     24 .Ar filename ,
     25 or, if the argument is omitted, from stdin.
     26 .Bl -tag -width Ds
     27 .It Fl d
     28 Debug mode: output extended debug information in addition to the simulation
     29 output.
     30 .It Fl h
     31 Show option summary.
     32 .It Fl t
     33 Output syntax tree instead of the simulation output.
     34 AST is output in the format which can be piped to
     35 .Xr dtree 1 .
     36 .It Fl V
     37 Show full version information: like
     38 .Fl v ,
     39 followed by copyright notice.
     40 .It Fl v
     41 Show version information: program version and source git repository commit date.
     42 .El
     43 .
     44 .Ss Expression description language
     45 An expression
     46 .Ar expr
     47 can be one of the following:
     48 .Bl -tag -width "A AND B" -offset indent
     49 .It Ar ident
     50 Variable identifier.
     51 Identifiers consist of one or more uppercase and lowercase latin letters and
     52 digits.
     53 An identifier cannot start with a digit.
     54 .It Ar expr Ms \[or] Ar expr
     55 Logical OR (disjunction).
     56 .It Ar expr Ms & Ar expr
     57 Logical AND (conjunction).
     58 .It Ar expr Ms ^ Ar expr
     59 Logical XOR (exclusive or).
     60 .It Ar expr Ms => Ar expr
     61 Logical implication.
     62 .It Ms ~ Ar expr
     63 Logical NOT (negation).
     64 .It Ms (\& Ar expr Ms )\&
     65 Parentheses (force operator precedence).
     66 .El
     67 .
     68 .Sh EXIT STATUS
     69 .Ex -std
     70 .Pp
     71 For errors caused by the unsuccessful calls to libc functions setting
     72 .Va errno ,
     73 that value is returned as the exit status.
     74 Otherwise, the exit status is one of the following:
     75 .Bl -tag -width Ds -offset indent -compact
     76 .It Li 201
     77 Command line argument is not recognized.
     78 .It Li 202
     79 .Fn va_arg
     80 returned NULL (should not happen).
     81 .It Li 203
     82 There was an error during the parsing of input, or the root node of AST is NULL.
     83 .El
     84 .
     85 .Sh EXAMPLES
     86 .Bd -literal
     87 $ printf "~A1 | A2 & A3\(rsn" | bool | tsvtable -n -saa
     88 +------------------+------------------+------------------+------------------+
     89 |A1                |A2                |A3                |Result            |
     90 |F                 |F                 |F                 |T                 |
     91 |F                 |F                 |T                 |T                 |
     92 |F                 |T                 |F                 |T                 |
     93 |F                 |T                 |T                 |T                 |
     94 |T                 |F                 |F                 |F                 |
     95 |T                 |F                 |T                 |F                 |
     96 |T                 |T                 |F                 |F                 |
     97 |T                 |T                 |T                 |T                 |
     98 +------------------+------------------+------------------+------------------+
     99 .Ed
    100 .Bd -literal
    101 $ printf "~A1 | A2 & A3\(rsn" | bool -t | dtree -sa
    102 OR
    103 +--NOT
    104 |  `--[ID(0) = "A1"]
    105 `--AND
    106    +--[ID(1) = "A2"]
    107    `--[ID(2) = "A3"]
    108 .Ed
    109 .
    110 .Sh AUTHORS
    111 .An Strahinya Radich Aq Mt sr@strahinja.org ,
    112 2026
    113 .
    114 .Sh BUGS
    115 Bugs can be reported using the ticket tracker at:
    116 .Lk https://\:todo.sr.ht/\:~strahinja/\:bool