Skip to content

Commit

Permalink
Track the codefigs things. Will likely be removed from tracking
Browse files Browse the repository at this point in the history
in the future.
  • Loading branch information
DNGros committed May 6, 2019
1 parent b674d59 commit 9ce6b8d
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 0 deletions.
1 change: 1 addition & 0 deletions builtin_types/cp_examples.ainix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ defines:
y:
- cp -r [-[$1]-] [-[$2]-]
- x:
# TODO fix
- copy everything in [-[1=ENGWORD]-]s dir to [-[$1]-]copy
y:
- cp -r [-[$1]-]/* [-[$1]-]copy
Expand Down
21 changes: 21 additions & 0 deletions figures/codefigs/condensed_cp_examples.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
defines:
- define_new: example_set
y_type: CommandSequence
examples:
- x:
- make a copy of [-[FILENAME]-] in parent dir
- copy [-[FILENAME]-] to parent directory
- copy [-[FILENAME]-] up one directory
y:
- cp [-[FILENAME]-] ..
- x:
- copy [-[1=DIRNAME]-] to [-[2=DIRNAME]-]
- recursive copy [-[1=DIRNAME]-] to [-[2=DIRNAME]-]
- cp for directories [-[1=DIRNAME]-] [-[2=DIRNAME]-]
y:
- cp -r [-[$1]-] [-[$2]-]
- x:
- copy everything in [-[1=ENGWORD]-] dir to [-[$1]-]copy
y:
- cp -r [-[$1]-]/* [-[$1]-]copy
# ...Other examples ommitted for conciseness.............................
13 changes: 13 additions & 0 deletions figures/codefigs/condensed_ls_examples.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
defines:
- define_new: example_set
y_type: CommandSequence
examples:
- x:
- list files here with smallest file first
- display files smallest to largest
- list files small to big
- show files. Sort by file size small first
y:
- ls -lSr
- ls -Sr
# ...Other examples ommitted for conciseness.............................
23 changes: 23 additions & 0 deletions figures/codefigs/condensed_numbers.ainix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
defines:
- define_new: type
name: Number
- define_new: object
name: decimal_number
type: Number
children:
- name: SignArg
type: Sign
required: False
- name: BeforeDecimal
type: IntBase
required: True
- name: AfterDecimal
type: IntBase
required: False
- name: Exponent
type: IntBase
required: False
preferred_object_parser:
grammar: |
SignArg? BeforeDecimal ("." AfterDecimal)? ("e" Exponent)?
# Definition of Sign type and IntBase type omitted ..........................
27 changes: 27 additions & 0 deletions figures/codefigs/condensed_wc.ainix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
defines:
- define_new: object
name: wc
type: Program
# We must provide type data so the default TypeParser for Programs knows
# how to recognize this object in strings.
type_data: {invoke_name: "wc"}
children:
- name: l
arg_data: {short_name: "l", long_name: "lines"}
- name: c
# By default arguments are optional.
# We can also explicitly specify this for clarity.
required: False
# The default ObjectParser for Program's knows how to parse
# POSIX-compliant program argument conventions. To do this the parser
# examines the arg_data that the user provides for the arguments.
arg_data: {short_name: "c", long_name: "bytes"}
- name: m
arg_data: {short_name: "m", long_name: "chars"}
- name: w
arg_data: {short_name: "w", long_name: "words"}
- name: files_list
# The previous arguments had None type (were just flags)
# However, this positional argument has a Type which needs to be parsed
type: PathList
arg_data: {position: 0, multiword_pos_arg: True}
29 changes: 29 additions & 0 deletions figures/codefigs/condensed_wc_examples.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
defines:
- define_new: example_set
# All example_set definitions must include a root y_type. For Unix commands,
# the root type is CommandSequence. However, this framework could also be
# used with a root type of RegularExp, SQL, or something else more domain
# specific. This allows AInix to be used in multitask settings.
y_type: CommandSequence
examples:
- x:
- how many lines are in [-[FILENAME]-]
- Counts lines of [-[FILENAME]-]
- line count of [-[FILENAME]-]
- get line count of [-[FILENAME]-]
y:
- wc -l [-[FILENAME]-]
risk: 0
- x:
- how many words are in [-[FILENAME]-]
- get the word count of [-[FILENAME]-]
- word count [-[FILENAME]-]
y:
- wc -w [-[FILENAME]-]
risk: 0
- x:
- how many letters are in "[-[ENGWORD]-]"
y:
- echo "[-[ENGWORD]-]" | wc -c
risk: 0
# ...Examples ommitted for conciseness...
7 changes: 7 additions & 0 deletions figures/codefigs/makecodeimgs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

for file in $(ls *.yaml)
do
echo ${file}
pygmentize -f png -O style=lovelace,font_size=30 ${file} > ${file}.png
done

0 comments on commit 9ce6b8d

Please sign in to comment.