Skip to content

Instantly share code, notes, and snippets.

@victoredwardocallaghan
Last active December 26, 2015 10:29
Show Gist options
  • Save victoredwardocallaghan/7137189 to your computer and use it in GitHub Desktop.
Save victoredwardocallaghan/7137189 to your computer and use it in GitHub Desktop.
--
-- apsh(1) interpreter specification in LBNF notation.
----------------------------------
-- The core statement language. --
----------------------------------
Prog. Program ::= [Function] ;
Fun. Function ::= Stm Exp Block ;
Block. Decl ::= [Decl] ;
--------------
-- Comments --
--------------
comment "!!" ;
comment "<" ">" ;
----------------
-- Terminator --
----------------
terminator Function "!" ;
terminator Stm "" ;
separator Decl ";" ;
---------------
-- Functions --
---------------
Dns. Fun ::= "dns" mode DnsRules ;
-- We now want to have some syntactic sugar. Note that the labels for
-- these rule all start with a lowercase letter, indicating that they
-- correspond to defined functions rather than nodes in the abstract
-- syntax tree.
-- help. Stm ::= "show" Stm "!" ;
-- hostname. Stm ::= "hostname" Ident "!" ;
-- Functions are defined using the 'define' keyword. Definitions have
-- the form 'define f x1 .. xn = e' where e is an expression on applicative
-- form using labels, other defined functions, lists and literals.
define dns m b = Dns m b ;
-----------------
-- Expressions --
-----------------
mode. Exp ::= ("enable" | "disable" | "reload" | "rules");
--------------------
-- Declaratations --
--------------------
DnsRules. Block ::= [DnsDomain ";" DnsNS] ;
DnsDomain. Decl ::= "search" Ident ;
DnsNS. Decl ::= "nameserver" Ident ";" DnsNS ;
------------
-- Tokens --
------------
token Hexadecimal '0' ('x'|'X') (digit | ["abcdef"] | ["ABCDEF"])+ ;
hexadec. Constant ::= Hexadecimal ;
int. Constant ::= Integer ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment