Skip to content

Commit

Permalink
9.2
Browse files Browse the repository at this point in the history
  • Loading branch information
itkatchev committed Aug 25, 2023
1 parent 673bdac commit f37d724
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 13 deletions.
13 changes: 7 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,18 @@ INCLUDE = \
SRC = tab.cc help.cc

CXX ?= g++
STATIC_LIBS ?=

tab: $(SRC) $(INCLUDE) $(FUNCS)
$(CXX) -std=c++11 -O3 -Wall -Iaxe -pthread -lm $(SRC) -o tab
strip tab

dist: $(SRC) $(INCLUDE) $(FUNCS)
$(CXX) -std=c++11 -O3 -Wall -Iaxe -Wl,--whole-archive -lpthread -Wl,--no-whole-archive -lm -pthread $(SRC) -static -o tab-linux-x86_64
strip tab-linux-x86_64
tab-static: $(SRC) $(INCLUDE) $(FUNCS)
$(CXX) $(STATIC_LIBS) -std=c++11 -O3 -Wall -Iaxe -Wl,--whole-archive -lpthread -Wl,--no-whole-archive -lm -pthread $(SRC) -static -o tab-static
strip tab-static

install: tab
strip tab
cp tab /usr/local/bin/
install: tab tab-static
cp tab tab-static /usr/local/bin/

clean:
rm tab
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ If you want to use a compiler other than gcc, e.g., clang, then type this:
$ CXX=clang++ make
```

A default.nix for reproducible builds is provided.

## Usage ##

The default is to read from standard input:
Expand Down Expand Up @@ -512,6 +514,8 @@ chars := ("\t" | "\n" | "\r" | "\e" | "\\" | any)*
string_interpolation = "${" expr "}"
```
Comments start with the `#` symbol and continue until the end of line. Comments are parsed as whitespace.
### Semantics ###
##### Expressions
Expand Down
22 changes: 18 additions & 4 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
{
pkgs ? import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/22.11.tar.gz") {}
pkgs ? import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/23.05.tar.gz") {}
} :
with pkgs;
mkShell.override { stdenv = gcc12Stdenv; } {
buildInputs = [ python3 ];
gcc12Stdenv.mkDerivation {
name = "tab";
version = "9.2";
src = ./.;
nativeBuildInputs = [ python3 ];
buildPhase = ''
make
STATIC_LIBS=-L${glibc.static}/lib make tab-static
'';
installPhase = ''
mkdir -p $out/bin
cp tab tab-static $out/bin
'';
doCheck = true;
checkPhase = ''
make test
'';
}

2 changes: 2 additions & 0 deletions docs/README.html
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ <h1 id="compiling-and-installing">Compiling and installing</h1>
</code></pre></div>

<p>The official git repository is found <a href="https://github.com/ivan-tkatchev/tab">here</a>.</p>
<p>A default.nix for reproducible builds is provided.</p>
<h1 id="usage">Usage</h1>
<p>The default is to read from standard input:</p>
<div class="codehilite"><pre><span></span><code><span class="err">$</span> <span class="nx">cat</span> <span class="nx">mydata</span> <span class="o">|</span> <span class="nx">tab</span> <span class="o">&lt;</span><span class="nx">expression</span><span class="o">&gt;...</span>
Expand Down Expand Up @@ -494,6 +495,7 @@ <h2 id="grammar">Grammar</h2>
<span class="nx">string_interpolation</span> <span class="nv">=</span> <span class="s2">&quot;${&quot;</span> <span class="nx">expr</span> <span class="s2">&quot;}&quot;</span>
</code></pre></div>

<p>Comments start with the <code>#</code> symbol and continue until the end of line. Comments are parsed as whitespace.</p>
<h2 id="semantics">Semantics</h2>
<h3 id="expressions">Expressions</h3>
<p>An expression is either an atomic value, an assignment or definition. Assignments and definitions do not produce a value and return nothing.</p>
Expand Down
5 changes: 5 additions & 0 deletions docs/README.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ If you want to use a compiler other than gcc, e.g., clang, then type this:

The official git repository is found [here](https://github.com/ivan-tkatchev/tab).

A default.nix for reproducible builds is provided.

# Usage #

The default is to read from standard input:
Expand Down Expand Up @@ -482,6 +484,9 @@ chars := ("\t" | "\n" | "\r" | "\e" | "\\" | any)*
string_interpolation = "${" expr "}"
```

Comments start with the `#` symbol and continue until the end of line. Comments are parsed as whitespace.


## Semantics ##

### Expressions
Expand Down
4 changes: 3 additions & 1 deletion docs/website/docs.html
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ <h1 id="compiling-and-installing">Compiling and installing</h1>
<div class="codehilite"><pre><span></span><code><span class="err">$</span> <span class="nx">CXX</span><span class="nv">=</span><span class="nx">clang</span><span class="o">++</span> <span class="nx">make</span>
</code></pre></div>

<p>The official git repository is found <a href="http://bitbucket.org/tkatchev/tab">here</a>.</p>
<p>The official git repository is found <a href="https://github.com/ivan-tkatchev/tab">here</a>.</p>
<p>A default.nix for reproducible builds is provided.</p>
<h1 id="usage">Usage</h1>
<p>The default is to read from standard input:</p>
<div class="codehilite"><pre><span></span><code><span class="err">$</span> <span class="nx">cat</span> <span class="nx">mydata</span> <span class="o">|</span> <span class="nx">tab</span> <span class="o">&lt;</span><span class="nx">expression</span><span class="o">&gt;...</span>
Expand Down Expand Up @@ -494,6 +495,7 @@ <h2 id="grammar">Grammar</h2>
<span class="nx">string_interpolation</span> <span class="nv">=</span> <span class="s2">&quot;${&quot;</span> <span class="nx">expr</span> <span class="s2">&quot;}&quot;</span>
</code></pre></div>

<p>Comments start with the <code>#</code> symbol and continue until the end of line. Comments are parsed as whitespace.</p>
<h2 id="semantics">Semantics</h2>
<h3 id="expressions">Expressions</h3>
<p>An expression is either an atomic value, an assignment or definition. Assignments and definitions do not produce a value and return nothing.</p>
Expand Down
8 changes: 8 additions & 0 deletions docs/website/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ <h1>History</h1>

<dl>

<dt>2023-08-25</dt>
<dd>Version 9.2 released. Changes:
<ul>
<li>Comments (with the <code>#</code> symbol) are now finally supported.</li>
<li>Build system modernization.</li>
</ul>
</dd>

<dt>2022-03-22</dt>
<dd>Version 9.1 released. Changes:
<ul>
Expand Down
2 changes: 2 additions & 0 deletions help.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ static const char* _help[][2] = {
"generator expression.\n"
"\n"
"Recursive calculations: << expr : start, seq >>\n"
"\n"
"Comments start with '#' and continue until end of line.\n"
},

{ "examples",
Expand Down
2 changes: 1 addition & 1 deletion infer.h
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ Type infer_expr(std::vector<Command>& commands, TypeRuntime& typer, bool allow_e
Type t = stack.back();

if (!check_integer(t))
throw std::runtime_error("Use of '~' numeric operator on something other "
throw std::runtime_error("Use of '!' numeric operator on something other "
"than integer or unsigned integer.");

break;
Expand Down
2 changes: 1 addition & 1 deletion parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ Type parse(I beg, I end, const Type& toplevel_type, TypeRuntime& typer, std::vec
axe::r_rule<I> x_expr_bit;
axe::r_rule<I> x_expr_bottom;

auto x_ws = *axe::r_any(" \t\n");
auto x_ws = *(axe::r_any(" \t\n") | (axe::r_lit('#') & axe::r_many(axe::r_any() - axe::r_lit('\n'), 0)));

auto y_int = axe::e_ref([&](I b, I e) {
try {
Expand Down
7 changes: 7 additions & 0 deletions test/comments.test.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#! hashbang
1 + # comment
count(@) # another .
# end
===>
24

0 comments on commit f37d724

Please sign in to comment.