Getting Started
Install, configure and run NETS parser.
Download and Installation
To download and install use npm
.
npm -install nets-parser
The 'node_modules/nets-parser' folder contains the executables and libraries required to run NETS on all supported platforms including:
- macos-x86-64
- linux-x86-64
- wasm-wasi-32
- wasm-node-32
- wasm-web-32
Configuration
Update the paths in nets-parser.js
when using the wasm-node-32
build. If required add the node_modules/nets-parser
folder to the PATH
.
Executables and scripts are contained in the node_modules/nets-parser
root folder. Tests are contained in the tests
subfolder.
Dependencies
Native executables depend on system libraries. Use lld nets-parser
to determine these on Linux or otool -L nets-parser
on MacOS. Platform version dependencies are undocumented at present.
The wasm-wasi-32
build depends on a Web Assembly (WASM) and Web Aassembly System Interface (WASI) runtime such as Wasmtime.
The wasm-node-32
build depends on node
> v12.x.
The wasm-web-32
build depends on a WASM capable web browser.
Running
NETS is started from the command line by invoking the 'nets-parser' executable.
> nets-parser-macos-x86-64-v1.0 [arguments]
NETS3 Command Line Interface MacOS-x64-v1.0(C) Copyright 2020 NETS3 Ltd
nets-parser-macos-x86-64-v1.0d
is the executable file name on MacOS for the x86 64 bit architrecture, in debug mode.
To see more detailed logging information set -loglevel=3
> nets-parser-macos-x86-64-v1.0 -loglevel=3
NETS3 Command Line Interface MacOS-x64-v1.0.(C) Copyright 2020 NETS3 Ltd
16/10/15 18:12:45 INF 6908:3 Working directory c:\netscli
16/10/15 18:12:45 INF 6908:3 Opening grammar library nets-parser-iconv
16/10/15 18:12:45 INF 6908:3 Opening grammar library nets-parser-library
16/10/15 18:12:45 ERR 6908:3 Opening default.g file
16/10/15 18:12:45 ERR 6908:3 Cannot start parser. Parser needs to be initialised.
The Node and Wasmtime executables run in a very similar way and details are given documentation in the Command Line Interface documentation.
Version
v1.0.2462 31-01-2021 (latest)
- Initial support for linux-x86-64
v1.0.2443 26-01-2021
- Initial support for macos-x86-64, wasm-wasi-32, wasm-node-32 and wasm-web-32 architectures
- Initial feature set including ISO 14977, EBNF, PEG, Grammar XML, pipelines, input/output semantics, abstract syntax trees, logging, breakpoints, single byte characters, wide characters, echo, production terminals, predicates
- Internal libraries ctype, utility, compress, encrypt, command
- External libraries encrypt and iconv
Hello World
The parser needs an to be configured with a grammar, an input and an output.
>nets-parser -loglevel=3 -grammar="mem:start={wchar.};" -input="mem:Hello World" -output=stdout -grammar_encoding="WCHAR_T" -encoding="WCHAR_T/ASCII"
NETS3 Command Line Interface v1.0.(C) Copyright 2016 NETS3 Ltd
16/10/15 18:45:58 INF 8040:3 Working directory c:\netscli
16/10/15 18:45:58 INF 8040:3 Opening grammar library nets-parser-iconv
16/10/15 18:45:58 INF 8040:3 Opening grammar library nets-parser-library
16/10/15 18:45:58 INF 8040:3 Parser started
16/10/15 18:45:58 INF 8040:3 Parser ended
Hello World16/10/15 18:45:58 INF 8040:3 Closing error file
Notice that in addition to the -input
, -output
and -grammar
parameters the -grammar_encoding
and -encoding
parameters
are required to read the grammar and input from memory.
A Simple Grammar
Now create two files default.g
and default.in
with the following code snippets.
start={char.};
The grammar is constructed using a rule ('start'), an iteration (using '{}'), a rule reference ('char'), the echo paramater ('.') and the end of rule symbol (';'). This grammar repeatedely reads a character from the input and echos it to the output until no more characters can be found.
Hello World
Run nets-parser with default.g
as the grammar, default.in
as the input and default.out
as the output.
>nets-parser -loglevel=3 -grammar=default.g -input=default.in -output=default.out
NETS3 Command Line Interface v1.0.(C) Copyright 2016 NETS3 Ltd
16/10/15 19:02:13 INF 6820:3 Working directory c:\netscli
16/10/15 19:02:13 INF 6820:3 Opening grammar library nets-parser-iconv
16/10/15 19:02:13 INF 6820:3 Opening grammar library nets-parser-library
16/10/15 19:02:13 INF 6820:3 Opening default.g file
16/10/15 19:02:13 INF 6820:32 Parse finished before end of input by 2 bytes
16/10/15 19:02:13 INF 6820:3 Closing file default.g
16/10/15 19:02:13 INF 6820:3 Parser started
16/10/15 19:02:13 INF 6820:3 Opening default.in file
16/10/15 19:02:13 INF 6820:3 Opening default.out file
16/10/15 19:02:13 INF 6820:3 Parser ended
16/10/15 19:02:13 INF 6820:3 Closing file default.in
16/10/15 19:02:13 INF 6820:3 Closing file default.out
16/10/15 19:02:13 INF 6820:3 Closing error file
The result will be the following.
Hello World