Last active
March 14, 2016 14:36
-
-
Save wenkokke/e5f76d82939ecc9d3a4c to your computer and use it in GitHub Desktop.
Grammars for aⁿbⁿ and aⁿbⁿcⁿ using constraint grammar (using only REMOVE).
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
"<w>" | |
"a" | |
"b" | |
"opt_a" | |
"opt_b" | |
"odd" | |
"even" | |
"^" | |
"$" | |
"<w>" | |
"a" | |
"b" | |
"opt_a" | |
"opt_b" | |
"odd" | |
"even" | |
"^" | |
"$" | |
"<w>" | |
"a" | |
"b" | |
"opt_a" | |
"opt_b" | |
"odd" | |
"even" | |
"^" | |
"$" | |
"<w>" | |
"a" | |
"b" | |
"opt_a" | |
"opt_b" | |
"odd" | |
"even" | |
"^" | |
"$" | |
"<w>" | |
"a" | |
"b" | |
"opt_a" | |
"opt_b" | |
"odd" | |
"even" | |
"^" | |
"$" | |
"<w>" | |
"a" | |
"b" | |
"opt_a" | |
"opt_b" | |
"odd" | |
"even" | |
"^" | |
"$" | |
"<.>" |
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
DELIMITERS = "<.>" ; | |
LIST A = "a" ; | |
LIST B = "b" ; | |
LIST OPT_A = "opt_a" ; | |
LIST OPT_B = "opt_b" ; | |
LIST ODD = "odd" ; | |
LIST EVEN = "even" ; | |
LIST >>> = "^" ; | |
LIST <<< = "$" ; | |
SET ANY = A OR B ; | |
# create own magic tags | |
BEFORE-SECTIONS | |
REMOVE >>> (-1 ANY) | |
REMOVE <<< ( 1 ANY) | |
# mark even/odd cohorts | |
BEFORE-SECTIONS | |
REMOVE EVEN (0 >>>) | |
SECTION | |
REMOVE ODD (NOT 0 >>> LINK NOT -1 EVEN) | |
REMOVE EVEN (NOT -1 ODD) | |
AFTER-SECTIONS | |
REMCOHORT ANY (1* <<< LINK NOT 0 EVEN) | |
REMCOHORT <<< (NOT 0 EVEN) | |
# mark a/b | |
BEFORE-SECTIONS | |
SELECT A (0 >>>) | |
SELECT B (0 <<<) | |
SECTION | |
REMOVE OPT_B (-1C A) | |
REMOVE OPT_A ( 1C B) | |
SELECT A (NOT 0 OPT_B) | |
SELECT B (NOT 0 OPT_A) |
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
"<w>" | |
"a" | |
"b" | |
"c" | |
"opt_a" | |
"opt_b" | |
"opt_c" | |
"x1" | |
"x2" | |
"x3" | |
"^" | |
"$" | |
"fst" | |
"snd" | |
"opt_fst" | |
"opt_snd" | |
"<w>" | |
"a" | |
"b" | |
"c" | |
"opt_a" | |
"opt_b" | |
"opt_c" | |
"x1" | |
"x2" | |
"x3" | |
"^" | |
"$" | |
"fst" | |
"snd" | |
"opt_fst" | |
"opt_snd" | |
"<w>" | |
"a" | |
"b" | |
"c" | |
"opt_a" | |
"opt_b" | |
"opt_c" | |
"x1" | |
"x2" | |
"x3" | |
"^" | |
"$" | |
"fst" | |
"snd" | |
"opt_fst" | |
"opt_snd" | |
"<w>" | |
"a" | |
"b" | |
"c" | |
"opt_a" | |
"opt_b" | |
"opt_c" | |
"x1" | |
"x2" | |
"x3" | |
"^" | |
"$" | |
"fst" | |
"snd" | |
"opt_fst" | |
"opt_snd" | |
"<w>" | |
"a" | |
"b" | |
"c" | |
"opt_a" | |
"opt_b" | |
"opt_c" | |
"x1" | |
"x2" | |
"x3" | |
"^" | |
"$" | |
"fst" | |
"snd" | |
"opt_fst" | |
"opt_snd" | |
"<w>" | |
"a" | |
"b" | |
"c" | |
"opt_a" | |
"opt_b" | |
"opt_c" | |
"x1" | |
"x2" | |
"x3" | |
"^" | |
"$" | |
"fst" | |
"snd" | |
"opt_fst" | |
"opt_snd" | |
"<w>" | |
"a" | |
"b" | |
"c" | |
"opt_a" | |
"opt_b" | |
"opt_c" | |
"x1" | |
"x2" | |
"x3" | |
"^" | |
"$" | |
"fst" | |
"snd" | |
"opt_fst" | |
"opt_snd" | |
"<w>" | |
"a" | |
"b" | |
"c" | |
"opt_a" | |
"opt_b" | |
"opt_c" | |
"x1" | |
"x2" | |
"x3" | |
"^" | |
"$" | |
"fst" | |
"snd" | |
"opt_fst" | |
"opt_snd" | |
"<w>" | |
"a" | |
"b" | |
"c" | |
"opt_a" | |
"opt_b" | |
"opt_c" | |
"x1" | |
"x2" | |
"x3" | |
"^" | |
"$" | |
"fst" | |
"snd" | |
"opt_fst" | |
"opt_snd" | |
"<w>" | |
"a" | |
"b" | |
"c" | |
"opt_a" | |
"opt_b" | |
"opt_c" | |
"x1" | |
"x2" | |
"x3" | |
"^" | |
"$" | |
"fst" | |
"snd" | |
"opt_fst" | |
"opt_snd" | |
"<w>" | |
"a" | |
"b" | |
"c" | |
"opt_a" | |
"opt_b" | |
"opt_c" | |
"x1" | |
"x2" | |
"x3" | |
"^" | |
"$" | |
"fst" | |
"snd" | |
"opt_fst" | |
"opt_snd" | |
"<w>" | |
"a" | |
"b" | |
"c" | |
"opt_a" | |
"opt_b" | |
"opt_c" | |
"x1" | |
"x2" | |
"x3" | |
"^" | |
"$" | |
"fst" | |
"snd" | |
"opt_fst" | |
"opt_snd" | |
"<w>" | |
"a" | |
"b" | |
"c" | |
"opt_a" | |
"opt_b" | |
"opt_c" | |
"x1" | |
"x2" | |
"x3" | |
"^" | |
"$" | |
"fst" | |
"snd" | |
"opt_fst" | |
"opt_snd" | |
"<w>" | |
"a" | |
"b" | |
"c" | |
"opt_a" | |
"opt_b" | |
"opt_c" | |
"x1" | |
"x2" | |
"x3" | |
"^" | |
"$" | |
"fst" | |
"snd" | |
"opt_fst" | |
"opt_snd" | |
"<w>" | |
"a" | |
"b" | |
"c" | |
"opt_a" | |
"opt_b" | |
"opt_c" | |
"x1" | |
"x2" | |
"x3" | |
"^" | |
"$" | |
"fst" | |
"snd" | |
"opt_fst" | |
"opt_snd" | |
"<w>" | |
"a" | |
"b" | |
"c" | |
"opt_a" | |
"opt_b" | |
"opt_c" | |
"x1" | |
"x2" | |
"x3" | |
"^" | |
"$" | |
"fst" | |
"snd" | |
"opt_fst" | |
"opt_snd" | |
"<w>" | |
"a" | |
"b" | |
"c" | |
"opt_a" | |
"opt_b" | |
"opt_c" | |
"x1" | |
"x2" | |
"x3" | |
"^" | |
"$" | |
"fst" | |
"snd" | |
"opt_fst" | |
"opt_snd" | |
"<w>" | |
"a" | |
"b" | |
"c" | |
"opt_a" | |
"opt_b" | |
"opt_c" | |
"x1" | |
"x2" | |
"x3" | |
"^" | |
"$" | |
"fst" | |
"snd" | |
"opt_fst" | |
"opt_snd" | |
"<w>" | |
"a" | |
"b" | |
"c" | |
"opt_a" | |
"opt_b" | |
"opt_c" | |
"x1" | |
"x2" | |
"x3" | |
"^" | |
"$" | |
"fst" | |
"snd" | |
"opt_fst" | |
"opt_snd" | |
"<w>" | |
"a" | |
"b" | |
"c" | |
"opt_a" | |
"opt_b" | |
"opt_c" | |
"x1" | |
"x2" | |
"x3" | |
"^" | |
"$" | |
"fst" | |
"snd" | |
"opt_fst" | |
"opt_snd" | |
"<w>" | |
"a" | |
"b" | |
"c" | |
"opt_a" | |
"opt_b" | |
"opt_c" | |
"x1" | |
"x2" | |
"x3" | |
"^" | |
"$" | |
"fst" | |
"snd" | |
"opt_fst" | |
"opt_snd" | |
"<.>" |
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
DELIMITERS = "<.>" ; | |
LIST A = "a" ; | |
LIST B = "b" ; | |
LIST C = "c" ; | |
LIST OPT_A = "opt_a" ; | |
LIST OPT_B = "opt_b" ; | |
LIST OPT_C = "opt_c" ; | |
SET OPT_A_OR_B = OPT_A OR OPT_B ; | |
SET OPT_B_OR_C = OPT_B OR OPT_C ; | |
SET OPT_C_OR_A = OPT_C OR OPT_A ; | |
LIST X1 = "x1" ; | |
LIST X2 = "x2" ; | |
LIST X3 = "x3" ; | |
SET X1_OR_X2 = X1 OR X2 ; | |
SET X2_OR_X3 = X2 OR X3 ; | |
SET X3_OR_X1 = X3 OR X1 ; | |
LIST >>> = "^" ; | |
LIST <<< = "$" ; | |
LIST FST = "fst" ; | |
LIST SND = "snd" ; | |
LIST OPT_FST = "opt_fst" ; | |
LIST OPT_SND = "opt_snd" ; | |
SET NOT_FST = OPT_FST OR SND OR OPT_SND ; | |
SET NOT_SND = FST OR OPT_FST OR OPT_SND ; | |
SET ANY = A OR B OR C ; | |
# create own magic tags | |
BEFORE-SECTIONS | |
REMOVE >>> (-1 ANY) | |
REMOVE <<< ( 1 ANY) | |
# check if divisible by 3 | |
BEFORE-SECTIONS | |
REMOVE X2_OR_X3 (0 >>>) | |
REMOVE X1_OR_X2 (0 <<<) | |
SECTION | |
REMOVE X3_OR_X1 (NOT 0 >>> LINK NOT -1 X2_OR_X3) | |
REMOVE X1_OR_X2 (NOT 0 >>> LINK NOT -1 X3_OR_X1) | |
REMOVE X2_OR_X3 (NOT 0 >>> LINK NOT -1 X1_OR_X2) | |
AFTER-SECTIONS | |
REMCOHORT ANY (1* <<< LINK NOT 0 X3) | |
REMCOHORT <<< (NOT 0 X3) | |
# mark first/second half | |
BEFORE-SECTIONS | |
REMOVE NOT_FST (0 >>>) | |
REMOVE NOT_SND (0 <<<) | |
SECTION | |
REMOVE OPT_SND (-1 FST LINK (NOT 0 NOT_FST)) | |
REMOVE OPT_FST ( 1 SND LINK (NOT 0 NOT_SND)) | |
REMOVE NOT_FST (0 FST LINK 0 SND LINK 0 OPT_FST LINK NOT 0 OPT_SND) | |
REMOVE NOT_SND (0 FST LINK 0 SND LINK 0 OPT_SND LINK NOT 0 OPT_FST) | |
BEFORE-SECTIONS | |
REMOVE OPT_B_OR_C (0 >>>) | |
REMOVE OPT_A_OR_B (0 <<<) | |
SECTION | |
REMOVE OPT_C_OR_A (0 FST LINK 1 SND LINK NOT 0 FST) | |
REMOVE OPT_C_OR_A (0 SND LINK -1 FST LINK NOT 0 SND) | |
SECTION | |
REMOVE OPT_B_OR_C (-1C A) | |
REMOVE OPT_A_OR_B ( 1C C) | |
SELECT A (0 OPT_A LINK NOT 0 OPT_B_OR_C) | |
SELECT C (0 OPT_C LINK NOT 0 OPT_A_OR_B) | |
REMOVE OPT_C_OR_A ( 1C B) | |
REMOVE OPT_C_OR_A (-1C B) | |
SELECT B (0 OPT_B LINK NOT 0 OPT_C_OR_A) | |
REMOVE OPT_B_OR_C (-1C A) | |
REMOVE OPT_A_OR_B ( 1C C) | |
SELECT A (0 OPT_A LINK NOT 0 OPT_B_OR_C) | |
SELECT C (0 OPT_C LINK NOT 0 OPT_A_OR_B) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment