diff --git a/README.md b/README.md index 301b42f..3eb9cc6 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,128 @@ -# bil -Basic Instruction Language +# BIL ➸ Basic Instruction Language + +## What is BIL? + +BIL is a superset of [HTML](https://w3c.github.io/html) that adds twelve new tags and uses doctype of ``. + + +## Why use BIL? + +BIL attempts to bridge the gap between natural languages like english, and more structured forms of language like [computer programming languages](https://en.wikipedia.org/wiki/Programming_language), [legalese](https://en.wikipedia.org/wiki/Legal_English), and [forms](https://en.wikipedia.org/wiki/Form_%28document%29). + +The challenge is to reduce ambiguity in written instructions by introducing additional markup and information about the parts of speech used, and to adhere to a consistent contextual structure for illustrating the relationships between the words. + +The goal is to arrive at an instruction language that acts both as a superset of HTML as well as a simplified subset of the natural language you are marking up as BIL. The aim is to present information in a way that a reader of the same natural language who has never seen BIL can understand it with a minimal learning curve to replace confusing instructions, verbose language, and ambiguous phrasing. + + +## BIL Reference + +### Words + +- child of: any word tag, ``, or `` +- parent of: any word tag, or `` + +Words are the elementary building blocks of BIL. You may nest word tags inside of each other infinitely deep (this is called putting words 'in the context of' another word) and this context-based nesting is the core idea of BIL. + +#### Noun + +- attribute(s): `proper` + +A `` tag wraps any noun or proper noun. Nouns are analogous to _generic objects_ in programming language. + +The `proper` attribute can be added to signify a proper noun. This is analogous to a _named variable_ in a programming language. + +#### Verb + +A `` tag wraps any verb, action, or set of actions. Verbs are analogous to _functions_ in a programming language. + +#### Number + +A `` tag wraps any numeric value. + +#### Adjective + +An `` tag wraps any adjective. These are analogous to _properties_ or _attributes_ in a programming language. + +#### Pronoun + +A `` tag wraps any pronoun. These address specific instances of nouns based on context. + +#### Preposition + +A `` tag wraps any preposition. These usually refer to the directionality, location, orientation, or state in which a verb or noun exists. + +#### Adverb + +An `` tag wraps any adverb. When used to modify verbs adverbs are analogous to _function arguments_ in programming languages. + +#### Conjunction + +A `` tag wraps any conjunction. Conjunctions are analogous to a lot of logical keywords like `if` and `while`. + +#### Interjection + +An `` tag wraps any interjection. + + +### Grouping Operators + +#### Block + +- child of: `` +- parent of: any word tags, and `` + +A `` tag is a grouping operator containing one or more words and a `` tag + +#### Context + +- child of: `` +- parent of: any word tags, and `` + +A `` tag is a grouping operator containing `` tags and and/or `` tags. + +#### Phrase + +A `` tag is a grouping operator containing multiple word tags. + + +## How to write BIL + +Always begin a BIL document with a containing `` tag: + +```html + +``` + +This containing block may contain one or more word tags, plus a `` tag. This block is a `` block and will contain more words that define something in the context of a `` called 'BIL example': + +```html + + BIL example + + +``` + +This `` tag may contain one or more word tags, more `` tags, or if there are multiple separate groupings of word tags each of these gropuings can be wrapped in `` tags: + +```html + + BIL example + + demo item 1 + demo item 2 + + +``` + +Here we could say that the `` 'item 1' is in the context of the `` 'demo', to demonstrate. We could also say that doing something with 'item 1' and 'item 2' are in the context of a `` called 'BIL example'. + +## BIL Demos + +- [How to decide which browser versions to support](examples/bil-browser.html) +- [How to make a Vegan Iced Mocha](examples/bil-mocha.html) +- [How to Make a S'more](examples/bil-smore.html) +- [How to Make a Static HTML Website](examples/bil-static.html) +- [How to Extract Audio from Youtube Videos](examples/bil-youtube.html) + + +> Made with ♥ by [@innovati](https://twitter.com/innovati) \ No newline at end of file diff --git a/examples/bil-browser.html b/examples/bil-browser.html new file mode 100644 index 0000000..6897cc7 --- /dev/null +++ b/examples/bil-browser.html @@ -0,0 +1,54 @@ + + + + +How to decide which browser versions to support + +

How to decide which browser versions to support

+

in Basic Instruction Language

+ +

Prose

+ +

For each browser version, the revenue per user is the total revenue divided by the total users.

+

The potential profit is the revenue per user multiplied by the users of this browser version.

+

The labour cost is the hourly rate multiplied by the estimated hours to support this browser version.

+

If the potential profit is greater than the labour cost, support this browser version.

+ +

Syntax

+ +

For each browser version, the revenue per user is the total revenue divided by the total users.

+

The potential profit is the revenue per user multiplied by the users of this browser version.

+

The labour cost is the hourly rate multiplied by the estimated hours to support this browser version.

+

If the potential profit is greater than the labour cost, support this browser version.

+ +

BIL

+ + + for each browser version + + + revenue per user + + divide total revenue by total users + + + + potential profit + + multiply revenue per user by this browser version users + + + + labour cost + + multiply hourly rate by estimate hours to support this browser version + + + + if greater potential profit than labour cost + + support this browser version + + + + \ No newline at end of file diff --git a/examples/bil-mocha.html b/examples/bil-mocha.html new file mode 100644 index 0000000..1335637 --- /dev/null +++ b/examples/bil-mocha.html @@ -0,0 +1,49 @@ + + + + +How to make a Vegan Iced Mocha + +

How to make a Vegan Iced Mocha

+

in Basic Instruction Language

+ +

Prose

+ +

How to make a vegan iced mocha.

+

For materials you will need a cup, a spoon, 250 ml of chocolate almond milk, and 250 ml of iced coffee.

+

The instructions are to put the milk and coffee inside the cup and mix with the spoon for 15 seconds.

+ +

Syntax

+ +

How to make a vegan iced mocha.

+

For materials you will need a cup, a spoon, 250 ml of chocolate almond milk, and 250 ml of iced coffee.

+

The instructions are to put the milk and coffee inside the cup and mix with the spoon for 15 seconds.

+ +

BIL

+ + + mocha vegan iced + + + make + + + materials + + cup + spoon + milk almond chocolate 250 ml + coffee iced 250 ml + + + + instructions + + put milk and coffee inside cup + mix with spoon 15 seconds + + + + + + \ No newline at end of file diff --git a/examples/bil-smore.html b/examples/bil-smore.html new file mode 100644 index 0000000..1196caa --- /dev/null +++ b/examples/bil-smore.html @@ -0,0 +1,77 @@ + + + + +How to Make a S'more + +

How to Make a S'more

+

in Basic Instruction Language

+ +

Prose

+ +

How to make a s'more.

+

For materials you'll need a fire, a skewer, and the following ingredients: a marshmallow, 2 graham crackers, and 2 chocolate wafers.

+

Instructions: To make the bottom layer put 2 chocolate wafers on a graham cracker. Then put the skewer inside the middle of the marshmallow. Next put the skewer near the fire. Rotate the skewer slowly until the marshmallow's color is equal to golden brown. Then remove the skewer from the fire and put the skewer on the bottom layer. Finally put the graham cracker on top of the marshmallow and remove the skewer from the marshmallow.

+ +

Syntax

+ +

How to make a s'more.

+

For materials you'll need a fire, a skewer, and the following ingredients: a marshmallow, 2 graham crackers, and 2 chocolate wafers.

+

Instructions: To make the bottom layer put 2 chocolate wafers on a graham cracker. Then put the skewer inside the middle of the marshmallow. Next put the skewer near the fire. Rotate the skewer slowly until the marshmallow's color is equal to golden brown. Then remove the skewer from the fire and put the skewer on the bottom layer. Finally put the graham cracker on top of the marshmallow and remove the skewer from the marshmallow.

+ +

BIL

+ + + s'more + + + make + + + materials + + fire + skewer + + ingredients + + marshmallow + graham cracker 2 + chocolate wafer 2 + + + + + + instructions + + + bottom layer + + + make + + put chocolate wafer 2 on graham cracker + + + + + bottom layer make + put skewer inside marshmallow middle + put skewer near fire + + until equal marshmallow color to golden brown + + rotate skewer slowly + + + remove skewer from fire + put skewer on bottom layer + put graham cracker on marshmallow + remove skewer from marshmallow + + + + + + \ No newline at end of file diff --git a/examples/bil-static.html b/examples/bil-static.html new file mode 100644 index 0000000..748988b --- /dev/null +++ b/examples/bil-static.html @@ -0,0 +1,178 @@ + + + + +How to Make a Static HTML Website + +

How to Make a Static HTML Website

+

in Basic Instruction Language

+ + + + + website static HTML + + + make + + + ftp software + + + edit file with code + + download file + open file with code editor + web developer write code + code editor save file + upload file + + + + + + instructions + + + register domain name + + browser navigate to IWantMyName.com + keyboard write domain name inside search field + website search + + if domain name is available inside search results + + purchase domain name + + + + if domain name is not available inside search results + + register new domain name + + + + + + default site files + + index.html + style.css + script.js + .htaccess + + + + default HTML + +
<!DOCTYPE html>
+<meta charset=utf-8>
+<meta name=viewport content="width=device-width, initial-scale=1">
+<title></title>
+<link href=style.css rel=stylesheet>
+<script src=script.js></script>
+
+
+ + default CSS + +
* {
+box-sizing: border-box;
+text-rendering: optimizeLegibility;
+-webkit-font-smoothing: antialiased;
+-moz-osx-font-smoothing: grayscale;
+font-kerning: auto;
+}
+html {
+font-size: 10pt;
+line-height: 1.4;
+font-weight: 400;
+font-family: 'Source Sans Pro', sans-serif;
+-webkit-text-size-adjust: 100%;
+}
+body {
+margin: 0;
+}
+
+
+ register domain name + ftp software connect to domain name + ftp software create default site files + ftp software edit index.html to equal default HTML + ftp software edit style.css to equal default CSS +
+
+
+
+
+
\ No newline at end of file diff --git a/examples/bil-youtube.html b/examples/bil-youtube.html new file mode 100644 index 0000000..e9d9e4b --- /dev/null +++ b/examples/bil-youtube.html @@ -0,0 +1,32 @@ + + + + +How to Extract Audio from Youtube Videos + +

How to Extract Audio from Youtube Videos

+ + + extract data audio from video youtube + + + instructions + + web browser navigate to youtube.com video + web browser copy page url + VLC media player as network source open page url
+ VLC media player view Media Information + VLC media player Media Information copy Location + web browser navigate to Location + web browser save video youtube + ffmpeg convert video youtubewith command + + command + +
ffmpeg -i video youtube.mp4 -vn -acodec copy data audio.m4a
+
+
+ +
+ + \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..8b37f27 --- /dev/null +++ b/index.html @@ -0,0 +1,326 @@ + + + + +BIL ➸ Basic Instruction Language + + + + +

Basic Instruction Language

+

What is BIL?

+

BIL is a superset of HTML that adds twelve new tags and uses doctype of <!DOCTYPE bil>.

+

Why use BIL?

+

BIL attempts to bridge the gap between natural languages like english, and more structured forms of language like computer programming languages, legalese, and forms.

+

The challenge is to reduce ambiguity in written instructions by introducing additional markup and information about the parts of speech used, and to adhere to a consistent contextual structure for illustrating the relationships between the words.

+

The goal is to arrive at an instruction language that acts both as a superset of HTML as well as a simplified subset of the natural language you are marking up as BIL. The aim is to present information in a way that a reader of the same natural language who has never seen BIL can understand it with a minimal learning curve to replace confusing instructions, verbose language, and ambiguous phrasing.

+

BIL Reference

+

Words

+ +

Words are the elementary building blocks of BIL. You may nest word tags inside of each other infinitely deep (this is called putting words 'in the context of' another word) and this context-based nesting is the core idea of BIL.

+

Noun

+ +

A <noun> tag wraps any noun or proper noun. Nouns are analogous to generic objects in programming language.

+

The proper attribute can be added to signify a proper noun. This is analogous to a named variable in a programming language.

+

Verb

+

A <verb> tag wraps any verb, action, or set of actions. Verbs are analogous to functions in a programming language.

+

Number

+

A <number> tag wraps any numeric value.

+

Adjective

+

An <adjective> tag wraps any adjective. These are analogous to properties or attributes in a programming language.

+

Pronoun

+

A <pronoun> tag wraps any pronoun. These address specific instances of nouns based on context.

+

Preposition

+

A <preposition> tag wraps any preposition. These usually refer to the directionality, location, orientation, or state in which a verb or noun exists.

+

Adverb

+

An <adverb> tag wraps any adverb. When used to modify verbs adverbs are analogous to function arguments in programming languages.

+

Conjunction

+

A <conjunction> tag wraps any conjunction. Conjunctions are analogous to a lot of logical keywords like if and while.

+

Interjection

+

An <interjection> tag wraps any interjection.

+

Grouping Operators

+

Block

+ +

A <block> tag is a grouping operator containing one or more words and a <context> tag

+

Context

+ +

A <context> tag is a grouping operator containing <phrase> tags and and/or <block> tags.

+

Phrase

+

A <phrase> tag is a grouping operator containing multiple word tags.

+

How to write BIL

+

Always begin a BIL document with a containing <block> tag:

+
<block></block>
+

This containing block may contain one or more word tags, plus a <context> tag. This block is a <noun> block and will contain more words that define something in the context of a <noun> called 'BIL example':

+
<block>
+  <noun>BIL example</noun>
+  <context></context>
+</block>
+

This <context> tag may contain one or more word tags, more <block> tags, or if there are multiple separate groupings of word tags each of these gropuings can be wrapped in <phrase> tags:

+
<block>
+  <noun>BIL example</noun>
+  <context>
+    <phrase><verb>demo <noun>item 1</noun></verb></phrase>
+    <phrase><verb>demo <noun>item 2</noun></verb></phrase>
+  </context>
+</block>
+

Here we could say that the <noun> 'item 1' is in the context of the <verb> 'demo', to demonstrate. We could also say that doing something with 'item 1' and 'item 2' are in the context of a <noun> called 'BIL example'.

+

BIL Demos

+ + + \ No newline at end of file diff --git a/interpreter/bil.js b/interpreter/bil.js new file mode 100644 index 0000000..b488b8c --- /dev/null +++ b/interpreter/bil.js @@ -0,0 +1,621 @@ +/* + +# BIL Interpreter +version 0.0.1 + +A JavaScript interpreter for the BIL Basic Instruction Language + +- website: https://github.com/tomhodgins/bil +- author: Tommy Hodgins +- license: MIT + +*/ + +// Step 1: Add CSS + +window.addEventListener('load', addCSS) + +// Step 2: Add Level Slider + +window.addEventListener('load', addSlider) + +// Step 3: Add Legend + +window.addEventListener('load', addLegend) + +// Step 4: Analyze Nouns + +window.addEventListener('load', function(){analyze('noun')}) + +// Step 5: Analyze Verbs + +window.addEventListener('load', function(){analyze('verb')}) + +// Step 6: Analyze Numbers + +window.addEventListener('load', function(){analyzeNumbers()}) + +// Step 7: Mark up tag names with titles + +window.addEventListener('load', addTitle) + +function addCSS() { + + var style = document.createElement('style') + + style.innerHTML = ` + + * { + box-sizing: border-box; + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + font-kerning: auto; + } + html { + font-size: 12pt; + line-height: 1.4; + font-weight: 400; + -webkit-text-size-adjust: 100%; + } + body { + margin: 2em; + } + h1, h2, h3, h4, h5, h6 { + font-weight: 600; + line-height: 1.2; + font-family: sans-serif; + } + pre { + white-space: pre-wrap; + } + ${matches('', ` + display: inline-block; + padding: .5em; + border-radius: .125em; + line-height: 1.5; + margin: 0; + border: 1px solid rgba(0,0,0,.2); + transition: + box-shadow .2s ease-in-out, + border-color .2s ease-in-out + ; + box-shadow: + inset rgba(255,255,255,0) 0 0 0, + rgba(0,0,0,0) 0 0 0 + ; + `)} + ${matchesInside('', ` + margin: 0 .25em; + `)} + ${matchesDouble('', ` + margin-left: 0 !important; + `)} + ${matches(':hover', ` + cursor: default; + border-color: rgba(0,0,0,.5); + box-shadow: + inset rgba(255,255,255,.5) 0 1px 0, + rgba(0,0,0,.5) 0 1px 2px + ; + `)} + ${matches(':active', ` + cursor: default; + border-color: rgba(0,0,0,.5); + box-shadow: + inset rgba(255,255,255,.5) 0 1px 0, + rgba(0,0,0,.5) 0 1px 2px + ; + `)} + ${matchesTwo(` + line-height: 100%; + border-radius: .5em; + `)} + ${matchesThree(` + border-radius: .35em; + `)} + ${matchesFour(` + border-radius: .25em; + `)} + ${matchesBefore('p >', ` + margin: 0 .25em !important; + `)} + ${matchesBefore('li >', ` + margin: 0 .25em !important; + `)} + ${matchesBefore('p', ` + margin: 0 .25em; + padding-top: .25em; + padding-bottom: .25em; + `)} + ${matchesBefore('li', ` + margin: 0 .25em; + padding-top: .25em; + padding-bottom: .25em; + `)} + p, li { + font-size: 14pt; + line-height: 2.5; + } + noun { + background: #ccf; + } + noun[proper], + noun[proper] noun[proper] { + font-weight: bold; + } + noun[proper] * { + font-weight: 400; + } + verb { + background: #cfc; + } + number { + background: #fcc; + } + adjective { + background: #fcf; + } + pronoun { + background: #ffc; + } + preposition { + background: #cff; + } + adverb { + background: #9ed; + } + conjunction { + background: #de9; + } + interjection { + background: #d9e; + } + phrase { + display: block; + margin: .75em 0; + padding-left: .75em; + } + block block { + margin-left: .75em; + margin-right: 0; + } + block { + margin: .75em .25em; + padding: .75em; + font-weight: 400; + font-size: 13pt; + display: block; + border-radius: .25em; + line-height: 1.5; + border: 1px solid rgba(0,0,0,.2); + } + block + block { + margin-top: .75em; + } + ${parent('block > noun', ` + background: rgb(224,224,255); + `)} + ${parent('block > verb', ` + background: rgb(224,255,224); + `)} + ${parent('block > number', ` + background: rgb(255,224,224); + `)} + ${parent('block > adjective', ` + background: rgb(255,224,255); + `)} + ${parent('block > pronoun', ` + background: rgb(255,255,224); + `)} + ${parent('block > preposition', ` + background: rgb(224,255,255); + `)} + ${parent('block > adverb', ` + background: rgb(192,234,246); + `)} + ${parent('block > conjunction', ` + background: rgb(246,234,192); + `)} + ${parent('block > interjection', ` + background: rgb(246,192,234); + `)} + block * + * { + margin-left: 0; + } + phrase > :first-child { + margin-left: 0; + } + block *:last-child { + margin-right: 0; + } + block block:last-child, + block phrase:last-child { + margin-bottom: .25em; + } + context > phrase:not(:last-child):after { + content: ','; + font-size: 18pt; + margin-left: .25em; + } + .legend li { + margin: 1em; + } + block pre { + font-size: 12pt; + font-weight: 400; + line-height: 1.5; + } + context:before, + context:after { + font-size: 18pt; + } + context:before { + content: '('; + margin-left: .25em; + } + context:after { + content: ')'; + } + + @media print { + block { + font-size: 12pt; + } + h2, ul { + display: none; + visibility:hidden; + } + ${matches(':before', ` + text-transform: uppercase; + font-size: 8pt; + font-family: sans-serif; + font-weight: 300; + `)} + noun:before { + content: 'noun: '; + } + verb:before { + content: 'verb: '; + } + number:before { + content: 'number: '; + } + adjective:before { + content: 'adjective: '; + } + adverb:before { + content: 'adverb: '; + } + pronoun:before { + content: 'pronoun: '; + } + preposition:before { + content: 'preposition: '; + } + conjunction:before { + content: 'conjunction: '; + } + interjection:before { + content: 'interjection: '; + } + } + + ` + + function parent(selector, rule) { + + var tag = document.querySelectorAll(selector) + var style = '' + var count = 0 + + for (var i=0; i ${selector[j]}`) + + } + + } + + style = `${permutations} { ${rule} }` + + return style + + } + + function matchesTwo(rule) { + + var selector = ['noun', 'verb', 'number', 'adjective', 'adverb', 'pronoun', 'preposition', 'conjunction', 'interjection'] + + var style = '' + + var permutations = [] + + for (var i=0; i${part[i]}` + + list.appendChild(item) + + } + + document.body.appendChild(list) + +} + +function analyze(type) { + + var heading = document.createElement('h2') + + heading.innerHTML = `Encountered ${type}s` + + var list = document.createElement('ul') + var tag = document.querySelectorAll('block ' + type) + + list.className = 'legend' + + for (var i=0; i.*\<.*\>/g, '') + + if (tag[i].parentNode.parentNode.parentNode.tagName == 'BLOCK') { + + var parentText = tag[i].parentNode.parentNode.parentNode.querySelector('*').outerHTML + + } + + if (list.textContent.indexOf(text) == -1) { + + item.innerHTML = `<${type}>${text} ${parentText ? 'in the context of ' + parentText : ''}` + + list.appendChild(item) + + } + + } + + } + + if (list.children.length) { + document.body.appendChild(heading) + document.body.appendChild(list) + } + +} + +function analyzeNumbers() { + + var heading = document.createElement('h2') + + heading.innerHTML = `Encountered numbers` + + var list = document.createElement('ul') + var tag = document.querySelectorAll('block number') + + list.className = 'legend' + + for (var i=0; i.*\<.*\>/g, '') + + var parentText = tag[i].parentNode.outerHTML + + item.innerHTML = `${text} ${parentText ? 'in the context of ' + parentText : ''}` + + console.log(list.textContent.indexOf(item.textContent)) + + if (list.textContent.indexOf(item.textContent) == -1) { + + list.appendChild(item) + + } + + } + + } + + if (list.children.length) { + document.body.appendChild(heading) + document.body.appendChild(list) + } + +} + +function addTitle() { + + var tag = document.querySelectorAll('noun, verb, number, adjective, adverb, pronoun, preposition, conjunction, interjection') + + for (var i=0; i *:first-child') + + for (var i=0; i