From f37d72421b0e08135c65d95aa17b70de195e0648 Mon Sep 17 00:00:00 2001 From: Ivan Tkatchev Date: Fri, 25 Aug 2023 23:38:36 +0300 Subject: [PATCH] 9.2 --- Makefile | 13 +++++++------ README.md | 4 ++++ default.nix | 22 ++++++++++++++++++---- docs/README.html | 2 ++ docs/README.html.md | 5 +++++ docs/website/docs.html | 4 +++- docs/website/index.html | 8 ++++++++ help.cc | 2 ++ infer.h | 2 +- parse.h | 2 +- test/comments.test.in | 7 +++++++ 11 files changed, 58 insertions(+), 13 deletions(-) create mode 100644 test/comments.test.in diff --git a/Makefile b/Makefile index ecfd410..5aa703f 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/README.md b/README.md index a14a11a..639969b 100644 --- a/README.md +++ b/README.md @@ -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: @@ -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 diff --git a/default.nix b/default.nix index 3a72caa..cce62e8 100644 --- a/default.nix +++ b/default.nix @@ -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 + ''; } - diff --git a/docs/README.html b/docs/README.html index 9393420..10eb179 100644 --- a/docs/README.html +++ b/docs/README.html @@ -148,6 +148,7 @@

Compiling and installing

The official git repository is found here.

+

A default.nix for reproducible builds is provided.

Usage

The default is to read from standard input:

$ cat mydata | tab <expression>...
@@ -494,6 +495,7 @@ 

Grammar

string_interpolation = "${" expr "}"
+

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

Semantics

Expressions

An expression is either an atomic value, an assignment or definition. Assignments and definitions do not produce a value and return nothing.

diff --git a/docs/README.html.md b/docs/README.html.md index 054718b..d17dd1f 100644 --- a/docs/README.html.md +++ b/docs/README.html.md @@ -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: @@ -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 diff --git a/docs/website/docs.html b/docs/website/docs.html index 1eecde1..10eb179 100644 --- a/docs/website/docs.html +++ b/docs/website/docs.html @@ -147,7 +147,8 @@

Compiling and installing

$ CXX=clang++ make
 
-

The official git repository is found here.

+

The official git repository is found here.

+

A default.nix for reproducible builds is provided.

Usage

The default is to read from standard input:

$ cat mydata | tab <expression>...
@@ -494,6 +495,7 @@ 

Grammar

string_interpolation = "${" expr "}"
+

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

Semantics

Expressions

An expression is either an atomic value, an assignment or definition. Assignments and definitions do not produce a value and return nothing.

diff --git a/docs/website/index.html b/docs/website/index.html index ad924ef..1a172d5 100644 --- a/docs/website/index.html +++ b/docs/website/index.html @@ -120,6 +120,14 @@

History

+
2023-08-25
+
Version 9.2 released. Changes: +
    +
  • Comments (with the # symbol) are now finally supported.
  • +
  • Build system modernization.
  • +
+
+
2022-03-22
Version 9.1 released. Changes:
    diff --git a/help.cc b/help.cc index 210f4f9..dcea786 100644 --- a/help.cc +++ b/help.cc @@ -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", diff --git a/infer.h b/infer.h index 68d6fe7..c9924c9 100644 --- a/infer.h +++ b/infer.h @@ -587,7 +587,7 @@ Type infer_expr(std::vector& 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; diff --git a/parse.h b/parse.h index 2feb83b..2688fc6 100644 --- a/parse.h +++ b/parse.h @@ -166,7 +166,7 @@ Type parse(I beg, I end, const Type& toplevel_type, TypeRuntime& typer, std::vec axe::r_rule x_expr_bit; axe::r_rule 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 { diff --git a/test/comments.test.in b/test/comments.test.in new file mode 100644 index 0000000..998b90a --- /dev/null +++ b/test/comments.test.in @@ -0,0 +1,7 @@ +#! hashbang +1 + # comment + count(@) # another . + # end +===> +24 +