-
-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
234 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
root ::= (expr "=" ws term "\n")+ | ||
expr ::= term ([-+*/] term)* | ||
term ::= ident | num | "(" ws expr ")" ws | ||
ident ::= [a-z] [a-z0-9_]* ws | ||
num ::= [0-9]+ ws | ||
ws ::= [ \t\n]* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
root ::= (declaration)* | ||
|
||
declaration ::= dataType identifier "(" parameter? ")" "{" statement* "}" | ||
|
||
dataType ::= "int" ws | "float" ws | "char" ws | ||
identifier ::= [a-zA-Z_] [a-zA-Z_0-9]* | ||
|
||
parameter ::= dataType identifier | ||
|
||
statement ::= | ||
( dataType identifier ws "=" ws expression ";" ) | | ||
( identifier ws "=" ws expression ";" ) | | ||
( identifier ws "(" argList? ")" ";" ) | | ||
( "return" ws expression ";" ) | | ||
( "while" "(" condition ")" "{" statement* "}" ) | | ||
( "for" "(" forInit ";" ws condition ";" ws forUpdate ")" "{" statement* "}" ) | | ||
( "if" "(" condition ")" "{" statement* "}" ("else" "{" statement* "}")? ) | | ||
( singleLineComment ) | | ||
( multiLineComment ) | ||
|
||
forInit ::= dataType identifier ws "=" ws expression | identifier ws "=" ws expression | ||
forUpdate ::= identifier ws "=" ws expression | ||
|
||
condition ::= expression relationOperator expression | ||
relationOperator ::= ("<=" | "<" | "==" | "!=" | ">=" | ">") | ||
|
||
expression ::= term (("+" | "-") term)* | ||
term ::= factor(("*" | "/") factor)* | ||
|
||
factor ::= identifier | number | unaryTerm | funcCall | parenExpression | ||
unaryTerm ::= "-" factor | ||
funcCall ::= identifier "(" argList? ")" | ||
parenExpression ::= "(" ws expression ws ")" | ||
|
||
argList ::= expression ("," ws expression)* | ||
|
||
number ::= [0-9]+ | ||
|
||
singleLineComment ::= "//" [^\n]* "\n" | ||
multiLineComment ::= "/*" ( [^*] | ("*" [^/]) )* "*/" | ||
|
||
ws ::= ([ \t\n]+) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Specifies chess moves as a list in algebraic notation, using PGN conventions | ||
|
||
# Force first move to "1. ", then any 1-2 digit number after, relying on model to follow the pattern | ||
root ::= "1. " move " " move "\n" ([1-9] [0-9]? ". " move " " move "\n")+ | ||
move ::= (pawn | nonpawn | castle) [+#]? | ||
|
||
# piece type, optional file/rank, optional capture, dest file & rank | ||
nonpawn ::= [NBKQR] [a-h]? [1-8]? "x"? [a-h] [1-8] | ||
|
||
# optional file & capture, dest file & rank, optional promotion | ||
pawn ::= ([a-h] "x")? [a-h] [1-8] ("=" [NBKQR])? | ||
|
||
castle ::= "O-O" "-O"? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# A probably incorrect grammar for Japanese | ||
root ::= jp-char+ ([ \t\n] jp-char+)* | ||
jp-char ::= hiragana | katakana | punctuation | cjk | ||
hiragana ::= [ぁ-ゟ] | ||
katakana ::= [ァ-ヿ] | ||
punctuation ::= [、-〾] | ||
cjk ::= [一-鿿] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
root ::= object | ||
value ::= object | array | string | number | ("true" | "false" | "null") ws | ||
|
||
object ::= | ||
"{" ws ( | ||
string ":" ws value | ||
("," ws string ":" ws value)* | ||
)? "}" ws | ||
|
||
array ::= | ||
"[" ws ( | ||
value | ||
("," ws value)* | ||
)? "]" ws | ||
|
||
string ::= | ||
"\"" ( | ||
[^"\\] | | ||
"\\" (["\\/bfnrt] | "u" [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F]) # escapes | ||
)* "\"" ws | ||
|
||
number ::= ("-"? ([0-9] | [1-9] [0-9]*)) ("." [0-9]+)? ([eE] [-+]? [0-9]+)? ws | ||
|
||
# Optional space: by convention, applied in this grammar after literal chars when allowed | ||
ws ::= ([ \t\n] ws)? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# This is the same as json.gbnf but we restrict whitespaces at the end of the root array | ||
# Useful for generating JSON arrays | ||
|
||
root ::= arr | ||
value ::= object | array | string | number | ("true" | "false" | "null") ws | ||
|
||
arr ::= | ||
"[\n" ws ( | ||
value | ||
(",\n" ws value)* | ||
)? "]" | ||
|
||
object ::= | ||
"{" ws ( | ||
string ":" ws value | ||
("," ws string ":" ws value)* | ||
)? "}" ws | ||
|
||
array ::= | ||
"[" ws ( | ||
value | ||
("," ws value)* | ||
)? "]" ws | ||
|
||
string ::= | ||
"\"" ( | ||
[^"\\] | | ||
"\\" (["\\/bfnrt] | "u" [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F]) # escapes | ||
)* "\"" ws | ||
|
||
number ::= ("-"? ([0-9] | [1-9] [0-9]*)) ("." [0-9]+)? ([eE] [-+]? [0-9]+)? ws | ||
|
||
# Optional space: by convention, applied in this grammar after literal chars when allowed | ||
ws ::= ([ \t\n] ws)? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
root ::= item+ | ||
|
||
# Excludes various line break characters | ||
item ::= "- " [^\r\n\x0b\x0c\x85\u2028\u2029]+ "\n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule llmfarm_core.swift
updated
10 files