mirror of
https://github.com/tonydamage/nux-env.git
synced 2025-12-11 13:24:28 +01:00
Added taskie configuration & other stuff.
Signed-off-by: Tony Tkacik <tonydamage@gmail.com>
This commit is contained in:
parent
6dafaf5b9d
commit
fc1b5bbc87
19 changed files with 744 additions and 7 deletions
68
inc/nudsl/nuxdsl.inc.sh
Normal file
68
inc/nudsl/nuxdsl.inc.sh
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
nux.use nudsl/yanglike
|
||||
|
||||
|
||||
lang.nuxdsl.strict.def() {
|
||||
lang.yanglike.def
|
||||
|
||||
.keyword.plan() {
|
||||
nudsl.process.fail "undefined keyword: $keyword";
|
||||
}
|
||||
.block.start.plan() {
|
||||
nudsl.process.fail "undefined block: $keyword";
|
||||
}
|
||||
.block.end.plan() {
|
||||
echo "${indent}end${keyword}";
|
||||
}
|
||||
|
||||
.match._unmatched.plan() {
|
||||
nudsl.process.fail "invalid syntax: $line";
|
||||
}
|
||||
}
|
||||
|
||||
lang.nuxdsl.def() {
|
||||
lang.nuxdsl.strict.def
|
||||
|
||||
.keyword.plan() {
|
||||
echo "$indent$keyword $args";
|
||||
}
|
||||
.block.start.plan() {
|
||||
.keyword.plan
|
||||
}
|
||||
.block.end.plan() {
|
||||
echo "${indent}end${keyword}";
|
||||
}
|
||||
|
||||
.match._unmatched.plan() {
|
||||
echo "$line";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.default.plan() {
|
||||
echo "$indent$keyword $args";
|
||||
}
|
||||
.blockend.plan() {
|
||||
echo "${indent}end${keyword}";
|
||||
}
|
||||
|
||||
.block() {
|
||||
eval """
|
||||
.block.$1.start.plan() {
|
||||
.default.plan
|
||||
}
|
||||
.block.$1.end.plan() {
|
||||
.blockend.plan
|
||||
}
|
||||
.keyword.$1.plan() {
|
||||
.default.plan
|
||||
}
|
||||
"""
|
||||
}
|
||||
|
||||
.keyword() {
|
||||
eval """
|
||||
.keyword.$1.plan() {
|
||||
.default.plan
|
||||
}
|
||||
"""
|
||||
}
|
||||
10
inc/nudsl/nuxfs.inc.sh
Normal file
10
inc/nudsl/nuxfs.inc.sh
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
nux.use nudsl/nuxdsl
|
||||
|
||||
lang.nuxfs.def() {
|
||||
lang.nuxdsl.strict.def
|
||||
}
|
||||
|
||||
.block dir
|
||||
.keyword link
|
||||
.keyword git
|
||||
.keyword should-not-exists
|
||||
69
inc/nudsl/yanglike.inc.sh
Normal file
69
inc/nudsl/yanglike.inc.sh
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
nux.use nudsl/blocktrac
|
||||
|
||||
## # nudsl/yanglike - Basic skeleton for YANG-like languages
|
||||
|
||||
##
|
||||
## yanglike is barebones support for development of YANG-like languages
|
||||
## with two main concepts: blocks and simple statements.
|
||||
##
|
||||
## The syntax of language is following:
|
||||
##
|
||||
## *statement* = <*block*> | <*simple*>
|
||||
## *block* = <*keyword*> [*arg*]* **{**
|
||||
## [*statement*]*
|
||||
## *}*
|
||||
## *simple* = <*keyword*> [*arg*]*;
|
||||
## *arg* = <*uarg*> | <*darg*> | <*sarg*>
|
||||
## *uarg* - unquoted argument
|
||||
## *sarg* - single quoted argument
|
||||
## *darg* - double quoted argument
|
||||
##
|
||||
## Language support is basic with following restrictions:
|
||||
## - one statement per line
|
||||
|
||||
|
||||
##
|
||||
## lang.yanglike.def ::
|
||||
## Definition of *yanglike* language
|
||||
##
|
||||
lang.yanglike.def() {
|
||||
local comment='(( *)(#.*))?'
|
||||
local whitespace="([ ]*)"
|
||||
local uarg="([^ #\{\}\"'\"'\"';]+)";
|
||||
local sarg="('\"'\"'[^'\"'\"']+'\"'\"')";
|
||||
local darg='("[^"]*")';
|
||||
local args="((($uarg|$darg|$sarg) *)*)";
|
||||
.match.line() {
|
||||
local type="$1";
|
||||
local match="^( *)$2$comment$";
|
||||
shift;shift;
|
||||
.match "$type" "$match" indent "$@" - indent_comment comment;
|
||||
}
|
||||
|
||||
.match.line comment ''
|
||||
.match.line block_end '(\})' \
|
||||
syntax
|
||||
.match.line block_start "([^ ]+)( +)$args( *)(\{)" \
|
||||
keyword indent2 args - - - - - indent3 syntax
|
||||
.match.line keyword "([^ ]+)( +)$args?( *)(;)"\
|
||||
keyword indent2 args - - - - - indent3 syntax
|
||||
|
||||
|
||||
.highlight keyword green
|
||||
.highlight syntax blue
|
||||
.highlight args yellow
|
||||
.highlight unmatched bg_red
|
||||
}
|
||||
|
||||
|
||||
.match.comment.plan() {
|
||||
nux.exec.optional .comment.plan
|
||||
}
|
||||
|
||||
|
||||
.match.keyword.plan() {
|
||||
#nux.log trace "Executing plan for ''$keyword'"
|
||||
nux.exec.or .keyword.$keyword.plan .keyword.plan
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue