Warning: Work in progress! Leave feedback on Zulip or Github if you'd like this doc to be updated.

Syntactic Concepts in Oil

Shell has these concepts.

Sigils:

echo $var
echo "$@"

Sigil Pairs:

echo ${var} 
echo $(hostname)  #
echo $((1 + 2 ))

Oil extends them.

Table of Contents
Static Parsing
Parsing Options to Take Over @, (), {}, set, and maybe =
Command vs. Expression Mode
Sigils, Sigil Pairs, and Lexer Modes

Static Parsing

Like Python, JS. See Oil language definition.

Parsing Options to Take Over @, (), {}, set, and maybe =

Another concept is parsing modes.

shopt -s all:oil  # most important thing, turns on many options

if ( ) {
}

echo @array

set x = 1
builtin set -o errexit

equals:

x = 1
equivalent to 
const x = 1

This is for Oil as a configuration language.

Command vs. Expression Mode

See Command vs. Expression Mode.

echo hi

Expression mode in three places:

echo @array
myprog --flag=$f(x, y)
var z = f(x+1, y)

Control FLow:

if grep foo if (foo) {} # replaces if [ -n $foo ]; then

while

for

switch/case -- for translation to C++ like mycpp match/case

Sigils, Sigil Pairs, and Lexer Modes

Sigils:

Sigil Pairs:

Table example:

var people = %{
  name      age:Int
  bob       10_000
  'andy c'  15_000
}
var people = {name: %(bob 'andy c'), age: %[10_000 15_000]}

Sigil pairs often change the lexer mode.


Generated on Thu Sep 3 10:28:33 PDT 2020