Skip to content

Instantly share code, notes, and snippets.

@Sh-ui
Created April 9, 2019 16:48
Show Gist options
  • Save Sh-ui/6ce40150249739707ce02c0240dfdb12 to your computer and use it in GitHub Desktop.
Save Sh-ui/6ce40150249739707ce02c0240dfdb12 to your computer and use it in GitHub Desktop.
testing custom syntax ideas for my own language that combines mostly stuff from ruby and python, with inspiration from coffeescript
'Joe', 'June', 'Harvey' have 'Joe' == TRUE
'Joe', 'June', 'Harvey' have 'J' == TRUE # without brackets it checks within items
'Joe', 'June', 'Harvey' have ['J'] == FALSE # with brackets to check for an item
'Joe', 'June', 'Harvey' have 1 'J' == FALSE
'Joe', 'June', 'Harvey' have 2 'J' == TRUE # these are
'Joe', 'June', 'Harvey' have 2 of 'J' == TRUE # equivalent
'Joe', 'June', 'Harvey' have 2 ('J') == TRUE # expressions
'Joe', 'June', 'Harvey' have only 'Joe' == FALSE
'Hello' have 'abc ' == FALSE
'Hello' have 'ello' == TRUE
'Hello' have any 'abcdefghijklmnopqrstuvwxyz '.split == TRUE # splits alphabet to array to check letter by letter
'Hello' have only any 'abcdefghijklmnopqrstuvwxyz '.split == TRUE
'Hello 1' have only any 'abcdefghijklmnopqrstuvwxyz '.split == FALSE
'Hello 1' have 'abcdefghijklmnopqrstuvwxyz '.split == FALSE
1..100 have 0 == FALSE # 1..100 == array from 1 to 100
1..100 not have 0 == TRUE # equivalent
1..100 exclude 0 == TRUE # expressions
[1,2,3,4,5] have 2 of 2 == FALSE
[1,1,1,2,2,2] have 2 of 2 == TRUE
[1,1,1,2,2,2] have only 2 of 2 == FALSE
[11, 22] have only 2 of 2 == TRUE # not sure if integers should work this way?
11, 22 have 2 of [2] == FALSE # theres no list item containing just 2
11, 22, 222 have only 1 of [22] == TRUE
[1,1,1,2,2,2] have ? > 1 of 2 == TRUE # has more than 1 of 2
[1,1,1,2,2,2] have ? < 4 of 2 == TRUE # has less than 4 of 2
[1,1,1,2,2,2] have ? <= 3 of 2 == TRUE # has 3 or less of 2
[1,1,1,2,2,2] have ? >= 3 of 2 == TRUE # has 3 or more of 2
[1,1,1,2,2,2] have ? >= 4 of 2 == FALSE # has 4 or more of 2
# theres gotta be a better way to format this right?
1, 2, 3 have 2 of 2 == FALSE # all of these
[1,2,3] have 2 of 2 == FALSE # expressions are
[1,2,3] have 2 of (2) == FALSE # equivalent and
[1, 2, 3] have 2 (2) == FALSE # valid
[1, 2, 3] have 2 2 == ERROR # you cannnot do
[1, 2, 3] have 2(2) == ERROR # integers like this
1, 2, 3 have Integer == TRUE
1, 2, 3 have only Integer == TRUE
'Lee', 20, 'Jon', 32 have Integer == TRUE
'Lee', 20, 'Jon', 32 have only Integer == FALSE
'Lee', 20, 'Jon', 32 have String and Integer == TRUE # equivalent
'Lee', 20, 'Jon', 32 have String, Integer == TRUE # expressions
'eggs', 8, 2.50 have String and Integer == TRUE
'eggs', 8, 2.50 have only String and Integer == FALSE # contains a float
'eggs', 8, 2.50 have String, Integer, Float == TRUE
'eggs', 8, 2 have String, Integer, Float == FALSE
'Charlie Brown' have Integer == FALSE
'Charlie Brown, 1960' have Integer == FALSE # strings cannot contain integers
['Charlie Brown', 1960] have Integer == TRUE # the array contains an Int
'Charlie Brown, 1960' have Number == TRUE # 'Number' is numeric substring
'1A 2B 3C' have Number == TRUE
'1A 2B 3C' have only Number == FALSE
'123' have only Number == TRUE
'11 22 33' have only Number or ' ' == TRUE
'11, 22, 33' have only Number or ' ' == FALSE
'11, 22, 33' have Number or ' ' == TRUE # equivalent
'11, 22, 33' have any Number, ' ' == TRUE # expressions
'11, 22, 33' have Number, ' ' == TRUE
'11bb' have only Number or 'aa' == FALSE
'11bb' have Number or 'aa' == TRUE
'aabb' have Number or 'aa' == TRUE
'aabb' have Number and 'aa' == FALSE
# example of comparing to variables that are assigned 'haveable' values
Alphabet = 'abcdefghijklmnopqrstuvwxyz'.split
'eggs and ham' have only any Number, Alphabet, ' ' == TRUE
AlphaNumeric = Number or Alphabet or ' '
'eggs and ham' have only AlphaNumeric == TRUE # AlphaNum & Alphabet would likely be built in
'foobar' have 'a','b','c' == FALSE # equivalent
'foobar' have 'a' and 'b' and 'c' == FALSE # expressions
'foobar' have any 'a','b','c' == TRUE # equivalent
'foobar' have 'a' or 'b' or 'c' == TRUE # expressions
'foobar' have 'a' and 'b' or 'c' == TRUE
'foobar' have 'a' or 'b' and 'c' == FALSE
'foobar' have 'a', 'b' == TRUE
'foobar' have 'a' or 'b' == TRUE
'foobar' have 'a' and 'b' == TRUE
'foobar' have 'a' or 'c' == TRUE # these are
'foobar' have any 'a', 'c' == TRUE # equivalent
'foobar' have any 'ac'.split == TRUE # expressions
'foobar' have 'a' and 'c' == FALSE # these are
'foobar' have 'a', 'c' == FALSE # equivalent
'foobar' have 'ac'.split == FALSE # expressions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment