text:
# Copyright (c) 2018-2021, Carnegie Mellon University
# See LICENSE for details

Declare(Compose);
Declare(ComposeDists);
Declare(ComposeStreams);

ccFunc := function(list)
      local i, l;
      l := [];
      for i in list do
          Cond(IsBound(i.createCode), Append(l, [i.createCode()]), Append(l, [i]));
      od;
      return Flat(l);
end;

# ==========================================================================
# Compose
# ==========================================================================
Class(Compose, BaseOperation, rec(
    # flatten by associativity
    abbrevs := [ arg ->
    [ Flat(List(Flat(arg),
            s -> When(IsSPL(s) and ObjId(s)=Compose, s.children(), s))) ]
    ],

    withTags := (self, tags) >> ApplyFunc(
	ObjId(self),
	List(self.children(), x -> x.withTags(tags))).takeAobj(self),

    checkDims := children -> let(chdims := List(children, c->c.dims()),
        DoForAll([1..Length(chdims)-1], i ->
            DoForAll(Zip2(chdims[i][2],chdims[i+1][1]), x->
        When( not(IsSymbolic(x[1]) or IsSymbolic(x[2])) and (x[1] <> x[2]),
            Error("Dimensions of children ",i," and ",i+1," do not match (",x[1]," <> ",x[2],") in ", children), 0)))),

    new := meth(self, L)
        local dim;
        Constraint(IsList(L) and L<>[]);
        #ForAll(L, x -> Constraint(IsSPL(x)));
        if Length(L) = 1 then return L[1]; fi;

        dim := Rows(L[1]);
        self.checkDims(L);
        L := Filtered(L, x -> not IsIdentityObj(x));
        if L = [] then   # all factors are identities
            return I(dim);
        elif Length(L) = 1 then
            return L[1];
        else
            return SPL(WithBases(self, rec(
                         _children := L,
                         dimensions := [L[1].dims()[1], L[Length(L)].dims()[2]])));
        fi;
    end,

     rng:= self>>let(c := self._children, c[1].rng()),
     dmn:= self>>let(c := self._children, Last(c).dmn()),
    #-----------------------------------------------------------------------
 #   dims := self >> let(c := self._children, [Rows(c[1]), Cols(Last(c))]),
     advdims := self >> [self._children[1].advdims()[1], Last(self._children).advdims()[2]],
    #-----------------------------------------------------------------------
    isPermutation := self >> ForAll(self._children, IsPermutationSPL),
    #-----------------------------------------------------------------------
    toAMat := self >> Product(List(self._children, AMatSPL)),
    #-----------------------------------------------------------------------
    transpose := self >>
        CopyFields(self, rec(
        _children := Reversed(List(self._children, x -> x.transpose())),
        dimensions := Reversed(self.dimensions))),
    conjTranspose := self >>
        CopyFields(self, rec(
        _children := Reversed(List(self._children, x -> x.conjTranspose())),
        dimensions := Reversed(self.dimensions))),
    inverse := self >>
        CopyFields(self, rec(
        _children := Reversed(List(self._children, x -> x.inverse())),
        dimensions := Reversed(self.dimensions))),
    #-----------------------------------------------------------------------
    printSeparationChar := " * ",
    print := meth(self, indent, indentStep)
        local s, newline;

    s := self.children();
    if Length(s) = 2 and ((IsBound(s[1]._sym) and IsBound(s[2]._mat))
                       or (IsBound(s[2]._sym) and IsBound(s[1]._mat)))
       or ForAll(s, x->IsBound(x._sym))
        then newline := Ignore;
    else newline := self._newline; fi;

        DoForAllButLast(s, c->Chain(SPLOps.Print(c, indent, indentStep),
                                Print(self.printSeparationChar),
                    newline(indent)));

    Last(s).print(indent, indentStep);

    end,
    #-----------------------------------------------------------------------
    arithmeticCost := (self, costMul, costAddMul) >>
        Sum(List(self.children(), x -> x.arithmeticCost(costMul, costAddMul))),

    createCode := self >> let (l := self._children, l2 := ccFunc(List(l)),
          Compose(l2)),

    normalizedArithCost := self >> Sum(List(self.children(), i->i.normalizedArithCost())),
    latexSymbol := "\\cdot"

 ));

Class(ComposeDists, Compose, rec(
    printSeparationChar := " |*| ",
    leftMostParScat := self >> self._children[1].leftMostParScat(),
    rightMostParGath := self >> self._children[Length(self._children)].rightMostParGath(),
));

Class(ComposeStreams, Compose, rec(
    printSeparationChar := " -*- ",
    leftMostParScat := self >> self._children[1].leftMostParScat(),
    rightMostParGath := self >> self._children[Length(self._children)].rightMostParGath(),
));


text:
# Copyright (c) 2018-2021, Carnegie Mellon University
# See LICENSE for details

IsCyclicPerm := x -> IsSPL(x) and IsBound(x.isCyclic) and x.isCyclic;

CyclicPerms := function(e)
    local beg, mid, endd, len, list, i;
    beg := I(Rows(e)); mid := I(Rows(e)); endd := I(Cols(e));
    list := e.children();
    len := Length(list);
    i := 1;
    while i <= Length(list) and IsCyclicPerm(list[i])     do
        beg:=beg*list[i]; i:=i+1;
    od;
    while i <= Length(list) and not IsCyclicPerm(list[i]) do mid:=mid*list[i]; i:=i+1; od;
    while i <= Length(list) and IsCyclicPerm(list[i])     do endd:=endd*list[i]; i:=i+1; od;
    return [beg, mid, endd];
end;

PullOutCyclicPerms := tensor ->
    SubstTopDownNR(tensor, [Tensor, @(1,Compose), @(2,Compose)],
	e -> let(p1 := CyclicPerms(@(1).val),
	         p2 := CyclicPerms(@(2).val),
		 Tensor(p1[1], p2[1]) * Tensor(p1[2], p2[2]) * Tensor(p1[3], p2[3])));

ext: gi


text:
EW schwarz,1,Projekt		//same as in cube.gap
  S(2,2,3)			//redifine edge size as (x,y,z)

ext: gap

max_stars_repo_name: rjs-codeworks/GAM-gen-graphical

max_issues_repo_name: rjs-codeworks/GAM-gen-graphical

max_forks_repo_name: rjs-codeworks/GAM-gen-graphical


text:
#
# Read("~/Workspace/groupsSB/epi/G2/generic.UU.gi");
#

type:="G";
rank:=2;
nr_pos_roots:=6;

Read("~/Workspace/groupsSB/epi/group.gi");

handleUaUbUc:=function()
	local rels, vals,i,v;
	# UaUb=Uc = U(a1+b1,a2+b2,a3+b3+a2*b1)
	rels:=Set(Concatenation(Ua*Ub-Uc));

	vals:=[];
	Append(vals,[[[vars[22]],[vars[2]+vars[12]]]]);
	Append(vals,[[[vars[21]],[vars[1]+vars[11]]]]);
	Append(vals,[[[vars[23]],[vars[3]+vars[13]+vars[2]*vars[11]]]]);
#a_{2}^2*b_{1}+2*a_{2}*b_{1}*b_{2}-2*a_{3}*b_{2}-a_{4}-b_{4}
#-a_{2}*b_{1}^2-2*a_{3}*b_{1}-a_{4}-b_{4}+c_{4},
	Append(vals,[[[vars[24]],[vars[2]*vars[11]^2+2*vars[3]*vars[11]+vars[4]+vars[14]]]]);
#a_{2}*b_{1}^3+3*a_{3}*b_{1}^2+3*a_{4}*b_{1}+a_{5}+b_{5}-c_{5}
	Append(vals,[[[vars[25]],[vars[2]*vars[11]^3+3*vars[3]*vars[11]^2+3*vars[4]*vars[11]+vars[5]+vars[15]]]]);
#a_{2}^2*b_{1}^3
#-a_{2}*b_{1}^3*b_{2}
#+3*a_{2}*a_{3}*b_{1}^2
#+3*a_{2}*b_{1}^2*b_{3}
#-3*a_{3}*b_{1}^2*b_{2}

#+3*a_{3}^2*b_{1}
#+6*a_{3}*b_{1}*b_{3}
#-3*a_{4}*b_{1}*b_{2}
#+3*a_{4}*b_{3}
#-a_{5}*b_{2}
#-a_{6}-b_{6}+c_{6}
	Append(vals,[[[vars[26]],[
-vars[2]^2*vars[11]^3
+vars[2]*vars[11]^3*vars[12]
-3*vars[2]*vars[3]*vars[11]^2
-3*vars[2]*vars[11]^2*vars[13]
+3*vars[3]*vars[11]^2*vars[12]
-3*vars[3]^2*vars[11]
-6*vars[3]*vars[11]*vars[13]
+3*vars[4]*vars[11]*vars[12]
-3*vars[4]*vars[13]
+vars[5]*vars[12]
+vars[6]+vars[16]]]]);

	for i in [1..Length(rels)] do
		for v in vals do
			Print(rels[i],"\n");
			rels[i]:=One(APR)*Value(rels[i],v[1],v[2]);
		od;
	od;
	return [vals,rels];
end;

max_stars_repo_name: iuliansimion/groupsSB

max_issues_repo_name: iuliansimion/groupsSB

max_forks_repo_name: iuliansimion/groupsSB


text:
# Built-in
A := [[1, 2], [3, 4], [5, 6], [7, 8]];
B := [[1, 2, 3], [4, 5, 6]];

PrintArray(A);
#  [ [  1,  2 ],
#    [  3,  4 ],
#    [  5,  6 ],
#    [  7,  8 ] ]

PrintArray(B);
#  [ [  1,  2,  3 ],
#    [  4,  5,  6 ] ]

PrintArray(A * B);
#  [ [   9,  12,  15 ],
#    [  19,  26,  33 ],
#    [  29,  40,  51 ],
#    [  39,  54,  69 ] ]

max_issues_repo_name: seanwallawalla-forks/RosettaCodeData

max_forks_repo_name: seanwallawalla-forks/RosettaCodeData


text:
%options la=15
%options single-productions
%options template=LexerTemplateF.gi
%options filter=LPGKWLexer.gi

%Globals
    /.

    ./
%End

%Define

    $kw_lexer_class /.$LPGKWLexer./
    $_IDENTIFIER /.$_MACRO_NAME./
%End

%Include
   LexerBasicMapF.gi
   --Utf8LexerBasicMapF.gi
%End

%Export
    SINGLE_LINE_COMMENT

    MACRO_NAME
    SYMBOL
    BLOCK
    EQUIVALENCE
    PRIORITY_EQUIVALENCE
    ARROW
    PRIORITY_ARROW
    OR_MARKER
    EQUAL
    COMMA
    LEFT_PAREN
    RIGHT_PAREN
    LEFT_BRACKET
    RIGHT_BRACKET
    SHARP
    VBAR
%End

%Terminals
    CtlCharNotWS

    LF   CR   HT   FF

    a    b    c    d    e    f    g    h    i    j    k    l    m
    n    o    p    q    r    s    t    u    v    w    x    y    z
    _

    A    B    C    D    E    F    G    H    I    J    K    L    M
    N    O    P    Q    R    S    T    U    V    W    X    Y    Z

    0    1    2    3    4    5    6    7    8    9

    AfterASCII   ::= '\u0080..\ufffe'
    Space        ::= ' '
    LF           ::= NewLine
    CR           ::= Return
    HT           ::= HorizontalTab
    FF           ::= FormFeed
    DoubleQuote  ::= '"'
    SingleQuote  ::= "'"
    Percent      ::= '%'
    VerticalBar  ::= '|'
    Exclamation  ::= '!'
    AtSign       ::= '@'
    BackQuote    ::= '`'
    Tilde        ::= '~'
    Sharp        ::= '#'
    DollarSign   ::= '$'
    Ampersand    ::= '&'
    Caret        ::= '^'
    Colon        ::= ':'
    SemiColon    ::= ';'
    BackSlash    ::= '\'
    LeftBrace    ::= '{'
    RightBrace   ::= '}'
    LeftBracket  ::= '['
    RightBracket ::= ']'
    QuestionMark ::= '?'
    Comma        ::= ','
    Dot          ::= '.'
    LessThan     ::= '<'
    GreaterThan  ::= '>'
    Plus         ::= '+'
    Minus        ::= '-'
    Slash        ::= '/'
    Star         ::= '*'
    LeftParen    ::= '('
    RightParen   ::= ')'
    Equal        ::= '='
%End

%Start
    Token
%End

%Notice
/.
////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2007 IBM Corporation.
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// which accompanies this distribution, and is available at
// http://www.eclipse.org/legal/epl-v10.html
//
//Contributors:
//    Philippe Charles (pcharles@us.ibm.com) - initial API and implementation

////////////////////////////////////////////////////////////////////////////////
./
%End

%Rules
    Token ::= white /.$BeginJava skipToken(); $EndJava./
    Token ::= singleLineComment /.$BeginJava makeComment($_SINGLE_LINE_COMMENT); $EndJava./

    Token ::= OptionLines
    Token ::= MacroSymbol       /.$BeginJava checkForKeyWord();$EndJava./
    Token ::= Symbol            /.$BeginJava checkForKeyWord($_SYMBOL);$EndJava./
    Token ::= Block             /.$BeginJava makeToken($_BLOCK);$EndJava./
    Token ::= Equivalence       /.$BeginJava makeToken($_EQUIVALENCE);$EndJava./
    Token ::= Equivalence ?     /.$BeginJava makeToken($_PRIORITY_EQUIVALENCE);$EndJava./
    Token ::= '#'               /.$BeginJava makeToken($_SHARP);$EndJava./
    Token ::= Arrow             /.$BeginJava makeToken($_ARROW);$EndJava./
    Token ::= Arrow ?           /.$BeginJava makeToken($_PRIORITY_ARROW);$EndJava./
    Token ::= '|'               /.$BeginJava makeToken($_OR_MARKER);$EndJava./
    Token ::= '['               /.$BeginJava makeToken($_LEFT_BRACKET);$EndJava./
    Token ::= ']'               /.$BeginJava makeToken($_RIGHT_BRACKET);$EndJava./

    digit -> 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9

    aA -> a | A
    bB -> b | B
    cC -> c | C
    dD -> d | D
    eE -> e | E
    fF -> f | F
    gG -> g | G
    hH -> h | H
    iI -> i | I
    jJ -> j | J
    kK -> k | K
    lL -> l | L
    mM -> m | M
    nN -> n | N
    oO -> o | O
    pP -> p | P
    qQ -> q | Q
    rR -> r | R
    sS -> s | S
    tT -> t | T
    uU -> u | U
    vV -> v | V
    wW -> w | W
    xX -> x | X
    yY -> y | Y
    zZ -> z | Z

--  lower ::= a | b | c | d | e | f | g | h | i | j | k | l | m | n | o | p | q | r | s | t | u | v | w | x | y | z
--  upper ::= A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

    letter -> AfterASCII | '_' | aA | bB | cC | dD | eE | fF | gG | hH | iI | jJ | kK | lL | mM | nN | oO | pP | qQ | rR | sS | tT | uU | vV | wW | xX | yY | zZ

    anyNonWhiteChar -> letter | digit | special

    special -> specialNoDotOrSlash | '.' | '/'

    --    special -> '+' | '-' | '(' | ')' | '"' | '!' | '@' | '`' | '~' | '.' | '/' |
    --               '%' | '&' | '^' | ':' | ';' | "'" | '\' | '|' | '{' | '}' |
    --               '[' | ']' | '?' | ',' | '<' | '>' | '=' | '#' | '*' | '$'

    specialNoExclamationDotColonDollar -> '+' | '-' | '(' | ')' | '"' | '@' | '`' | '~' | '/' |
                                          '%' | '&' | '^' | ';' | "'" | '\' | '|' | '{' | '}' |
                                          '[' | ']' | '?' | ',' | '<' | '>' | '=' | '#' | '*'

    specialNoColonDollar -> '+' | '-' | '(' | ')' | '"' | '!' | '@' | '`' | '~' | '.' | '/' |
                            '%' | '&' | '^' | ';' | "'" | '\' | '|' | '{' | '}' |
                            '[' | ']' | '?' | ',' | '<' | '>' | '=' | '#' | '*'

    specialNoEqualDollar -> '+' | '-' | '(' | ')' | '"' | '!' | '@' | '`' | '~' | '.' | '/' |
                            '%' | '&' | '^' | ':' | ';' | "'" | '\' | '|' | '{' | '}' |
                            '[' | ']' | '?' | ',' | '<' | '>' | '#' | '*'

    specialNoQuestionDollar -> '+' | '-' | '(' | ')' | '"' | '!' | '@' | '`' | '~' | '.' | '/' |
                               '%' | '&' | '^' | ':' | ';' | "'" | '\' | '|' | '{' | '}' |
                               '[' | ']' | ',' | '<' | '>' | '=' | '#' | '*'

    specialNoMinusRightAngleDollar -> '+' | '(' | ')' | '!' | '@' | '`' | '~' | '.' | '/' |
                                      '%' | '&' | '^' | ':' | ';' | '"' | '\' | '|' | '{' | '}' |
                                      '[' | ']' | '?' | ',' | '<' | "'" | '=' | '#' | '*' | '$'

    specialNoDollar -> '+' | '-' | '(' | ')' | '"' | '!' | '@' | '`' | '~' | '.' | '/' |
                       '%' | '&' | '^' | ':' | ';' | "'" | '\' | '|' | '{' | '}' |
                       '[' | ']' | '?' | ',' | '<' | '>' | '=' | '#' | '*'

    specialNoDollarBracketSharp -> '+' | '-' | '(' | ')' | '"' | '!' | '@' | '`' | '~' | '.' | '/' |
                       '%' | '&' | '^' | ':' | ';' | "'" | '\' | '|' | '{' | '}' |
                       '?' | ',' | '<' | '>' | '=' | '*'

    specialNoDotOrSlash -> '+' | '-' | '(' | ')' | '"' | '!' | '@' | '`' | '~' |
                           '%' | '&' | '^' | ':' | ';' | "'" | '\' | '|' | '{' | '}' |
                           '[' | ']' | '?' | ',' | '<' | '>' | '=' | '#' | '*' | '$'

    specialNoColonOrSlash -> '+' | '-' | '(' | ')' | '"' | '!' | '@' | '`' | '~' | '.' |
                             '%' | '&' | '^' | ';' | "'" | '\' | '|' | '{' | '}' |
                             '[' | ']' | '?' | ',' | '<' | '>' | '=' | '#' | '*' | '$'

    specialNoExclamationOrSlash -> '+' | '-' | '(' | ')' | '"' | '@' | '`' | '~' | '.' |
                                   '%' | '&' | '^' | ':' | ';' | "'" | '\' | '|' | '{' | '}' |
                                   '[' | ']' | '?' | ',' | '<' | '>' | '=' | '#' | '*' | '$'

    specialNoDoubleQuote -> '+' | '-' | '(' | ')' | '!' | '@' | '`' | '~' | '.' | '/' |
                            '%' | '&' | '^' | ':' | ';' | "'" | '\' | '|' | '{' | '}' |
                            '[' | ']' | '?' | ',' | '<' | '>' | '=' | '#' | '*' | '$'

    specialNoSingleQuote -> '+' | '-' | '(' | ')' | '!' | '@' | '`' | '~' | '.' | '/' |
                            '%' | '&' | '^' | ':' | ';' | '"' | '\' | '|' | '{' | '}' |
                            '[' | ']' | '?' | ',' | '<' | '>' | '=' | '#' | '*' | '$'

    specialNoRightAngle -> '+' | '-' | '(' | ')' | '!' | '@' | '`' | '~' | '.' | '/' |
                           '%' | '&' | '^' | ':' | ';' | '"' | '\' | '|' | '{' | '}' |
                           '[' | ']' | '?' | ',' | '<' | "'" | '=' | '#' | '*' | '$'

    specialNoMinusSingleQuoteDoublequoteLeftAngleCommaLparenRparen -> '+' | '!' | '@' | '`' | '~' | '.' | '/' |
                                                                      '%' | '&' | '^' | ':' | ';' | '\' | '|' | '{' | '}' |
                                                                      '[' | ']' | '?' | '>' | '=' | '#' | '*' | '$'

    specialNoColonMinusSingleQuoteDoublequoteLeftAngleLRBracketOrSlashDollarPercent -> '+' | '(' | ')' | '!' | '@' | '`' | '~' | '.' |
                                                                              '&' | '^' | ';' | '\' | '{' | '}' |
                                                                              '?' | ',' | '>' | '=' | '*'

    Eol -> LF | CR

    whiteChar -> Space | Eol | HT | FF

    white ::= whiteChar
            | white whiteChar

    notEOL -> letter | digit | special | Space | HT | FF

    notEOLOrQuote -> letter | digit | specialNoSingleQuote | Space | HT | FF

    notEOLOrDoubleQuote -> letter | digit | specialNoDoubleQuote | Space | HT | FF

    notEOLOrRightAngle -> letter | digit | specialNoRightAngle | Space | HT | FF

    notEOLOrQuotes ::= %Empty
                     | notEOLOrQuotes notEOLOrQuote

    notEOLOrDoubleQuotes ::= %Empty
                           | notEOLOrDoubleQuotes notEOLOrDoubleQuote

    notEOLOrRightAngles ::= notEOLOrRightAngle
                          | notEOLOrRightAngles notEOLOrRightAngle

    singleLineComment ::= '-' '-'
                        | singleLineComment notEOL

    Equivalence ::= ':' ':' '='
    Arrow       ::= '-' '>'

    Exclamations ::= '!'
                   | Exclamations '!'

    InsideExclamationBlockChar -> letter | whiteChar | digit | specialNoExclamationOrSlash

    InsideExclamationBlock ::= %Empty
                             | InsideExclamationBlock InsideExclamationBlockChar
                             | InsideExclamationBlock Exclamations InsideExclamationBlockChar
                             | InsideExclamationBlock '/'

    Dots ::= '.'
           | Dots '.'

    InsideDotBlockChar -> letter | whiteChar | digit | specialNoDotOrSlash

    InsideDotBlock ::= %Empty
                     | InsideDotBlock InsideDotBlockChar
                     | InsideDotBlock Dots InsideDotBlockChar
                     | InsideDotBlock '/'

    Colons ::= ':'
             | Colons ':'

    InsideColonBlockChar -> letter | whiteChar | digit | specialNoColonOrSlash

    InsideColonBlock ::= %Empty
                       | InsideColonBlock InsideColonBlockChar
                       | InsideColonBlock Colons InsideColonBlockChar
                       | InsideColonBlock '/'

    Block ::= '/' '.' InsideDotBlock Dots '/'
            | '/' ':' InsideColonBlock Colons '/'
            | '/' '!' InsideExclamationBlock Exclamations '/'

    Symbol -> delimitedSymbol
            | specialSymbol
            | normalSymbol

    delimitedSymbol ::= "'" notEOLOrQuotes "'"
                      | '"' notEOLOrDoubleQuotes '"'
                      | '<' letter notEOLOrRightAngles '>'

    MacroSymbol ::= '$'
                  | MacroSymbol letter
                  | MacroSymbol digit

    anyNonWhiteNoColonMinusSingleQuoteDoublequoteLeftAngleLRBracketOrSlashDollarPercent -> letter | digit | specialNoColonMinusSingleQuoteDoublequoteLeftAngleLRBracketOrSlashDollarPercent
    normalSymbol ::= anyNonWhiteNoColonMinusSingleQuoteDoublequoteLeftAngleLRBracketOrSlashDollarPercent
                   | normalSymbol anyNonWhiteNoDollarBracketSharp

    --
    -- Below, we write special rules to recognize initial
    -- prefixes of these special metasymbols as valid symbols.
    --
    --    BLOCK            /.  ...
    --    EQUIVALENCE      ::=[?]
    --    ARROW            ->[?]
    --    COMMENT          -- ...
    --    OR_MARKER        |
    --    OPTIONS_KEY      %options
    --    bracketed symbol < ... >
    --

    letterNoOo -> AfterASCII | '_' | aA | bB | cC | dD | eE | fF | gG | hH | iI | jJ | kK | lL | mM | nN | pP | qQ | rR | sS | tT | uU | vV | wW | xX | yY | zZ
    letterNoPp -> AfterASCII | '_' | aA | bB | cC | dD | eE | fF | gG | hH | iI | jJ | kK | lL | mM | nN | oO | qQ | rR | sS | tT | uU | vV | wW | xX | yY | zZ
    letterNoTt -> AfterASCII | '_' | aA | bB | cC | dD | eE | fF | gG | hH | iI | jJ | kK | lL | mM | nN | oO | pP | qQ | rR | sS | uU | vV | wW | xX | yY | zZ
    letterNoIi -> AfterASCII | '_' | aA | bB | cC | dD | eE | fF | gG | hH | jJ | kK | lL | mM | nN | oO | pP | qQ | rR | sS | tT | uU | vV | wW | xX | yY | zZ
    letterNoNn -> AfterASCII | '_' | aA | bB | cC | dD | eE | fF | gG | hH | iI | jJ | kK | lL | mM | oO | pP | qQ | rR | sS | tT | uU | vV | wW | xX | yY | zZ
    letterNoSs -> AfterASCII | '_' | aA | bB | cC | dD | eE | fF | gG | hH | iI | jJ | kK | lL | mM | nN | oO | pP | qQ | rR | tT | uU | vV | wW | xX | yY | zZ

    anyNonWhiteNoLetterDollar -> digit | specialNoDollar
    anyNonWhiteNoExclamationDotColonDollar -> letter | digit | specialNoExclamationDotColonDollar
    anyNonWhiteNoColonDollar -> letter | digit | specialNoColonDollar
    anyNonWhiteNoEqualDollar -> letter | digit | specialNoEqualDollar
    anyNonWhiteNoQuestionDollar -> letter | digit | specialNoQuestionDollar
    anyNonWhiteNoMinusRightAngleDollar -> letter | digit | specialNoMinusRightAngleDollar
    anyNonWhiteNoDollar -> letter | digit | specialNoDollar
    anyNonWhiteNoDollarBracketSharp -> letter | digit | specialNoDollarBracketSharp

    anyNonWhiteNoOoDollar -> letterNoOo | digit | specialNoDollar
    anyNonWhiteNoPpDollar -> letterNoPp | digit | specialNoDollar
    anyNonWhiteNoTtDollar -> letterNoTt | digit | specialNoDollar
    anyNonWhiteNoIiDollar -> letterNoIi | digit | specialNoDollar
    anyNonWhiteNoNnDollar -> letterNoNn | digit | specialNoDollar
    anyNonWhiteNoSsDollar -> letterNoSs | digit | specialNoDollar

    specialSymbol -> simpleSpecialSymbol
                   | complexSpecialSymbol

    simpleSpecialSymbol ::= '<'
                          | '/'
                          | ':'
                          | ':' ':'
                          | '-'
                          | '%'
                          | '%' oO
                          | '%' oO pP
                          | '%' oO pP tT
                          | '%' oO pP tT iI
                          | '%' oO pP tT iI oO
                          | '%' oO pP tT iI oO nN

    complexSpecialSymbol ::= '<' anyNonWhiteNoLetterDollar
                           | '/' anyNonWhiteNoExclamationDotColonDollar
                           | ':' anyNonWhiteNoColonDollar
                           | ':' ':' anyNonWhiteNoEqualDollar
                           | ':' ':' '=' anyNonWhiteNoQuestionDollar
                           | ':' ':' '=' '?' anyNonWhiteNoDollar
                           | '-' anyNonWhiteNoMinusRightAngleDollar
                           | '-' '>' anyNonWhiteNoQuestionDollar
                           | '-' '>' '?' anyNonWhiteNoDollar
                           | '|' anyNonWhiteNoDollar
                           | '%' anyNonWhiteNoOoDollar
                           | '%' oO anyNonWhiteNoPpDollar
                           | '%' oO pP anyNonWhiteNoTtDollar
                           | '%' oO pP tT anyNonWhiteNoIiDollar
                           | '%' oO pP tT iI anyNonWhiteNoOoDollar
                           | '%' oO pP tT iI oO anyNonWhiteNoNnDollar
                           | '%' oO pP tT iI oO nN anyNonWhiteNoSsDollar
                           | '%' oO pP tT iI oO nN sS anyNonWhiteNoDollar
                           | complexSpecialSymbol anyNonWhiteNoDollar

    number ::= digit
             | number digit

   --
   -- The following rules are used for processing options.
   --
   OptionLines ::= OptionLineList
          /.$BeginJava
                      // What ever needs to happen after the options have been
                      // scanned must happen here.
            $EndJava
          ./

   OptionLineList ::= OptionLine
                    | OptionLineList OptionLine
   OptionLine ::= options Eol
                | OptionsHeader Eol
                | OptionsHeader optionList Eol
                | OptionsHeader OptionComment Eol
                | OptionsHeader optionList optionWhiteChar OptionComment Eol

   OptionsHeader ::= options optionWhiteChar optionWhite

   options ::= '%' oO pP tT iI oO nN sS
          /.$BeginJava
                      makeToken(getLeftSpan(), getRightSpan(), $_OPTIONS_KEY);
            $EndJava
          ./

   OptionComment ::= singleLineComment /.$BeginJava makeComment($_SINGLE_LINE_COMMENT); $EndJava./

   _opt -> %Empty
         | '_'
         | '-'

   no ::= nN oO

   none ::= nN oO nN eE

   anyNoMinusSingleQuoteDoublequoteLeftAngleCommaLparenRparen -> letter
                                                               | digit
                                                               | specialNoMinusSingleQuoteDoublequoteLeftAngleCommaLparenRparen

   optionSymbol ::= anyNoMinusSingleQuoteDoublequoteLeftAngleCommaLparenRparen
                  | '-' anyNoMinusSingleQuoteDoublequoteLeftAngleCommaLparenRparen
                  | optionSymbol '-' anyNoMinusSingleQuoteDoublequoteLeftAngleCommaLparenRparen
                  | optionSymbol anyNoMinusSingleQuoteDoublequoteLeftAngleCommaLparenRparen

   Value ::= delimitedSymbol
           | '-'
           | optionSymbol
           | optionSymbol '-'

   optionWhiteChar -> Space | HT | FF
   optionWhite ::= %Empty
                 | optionWhite optionWhiteChar

   optionList ::= option
                | optionList separator option
   separator ::= ','$comma /.$BeginJava  makeToken(getLeftSpan(), getRightSpan(), $_COMMA); $EndJava./
   --
   -- action_block
   -- ast_directory
   -- ast_type
   -- automatic_ast
   -- attributes
   --
   option ::= action_block$ab optionWhite '='$eq optionWhite '('$lp optionWhite filename$fn optionWhite ','$comma1 optionWhite block_begin$bb optionWhite ','$comma2 optionWhite block_end$be optionWhite ')'$rp optionWhite
          /.$BeginJava
                      makeToken(getRhsFirstTokenIndex($ab), getRhsLastTokenIndex($ab), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($eq), getRhsLastTokenIndex($eq), $_EQUAL);
                      makeToken(getRhsFirstTokenIndex($lp), getRhsLastTokenIndex($lp), $_LEFT_PAREN);
                      makeToken(getRhsFirstTokenIndex($fn), getRhsLastTokenIndex($fn), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($comma1), getRhsLastTokenIndex($comma1), $_COMMA);
                      makeToken(getRhsFirstTokenIndex($bb), getRhsLastTokenIndex($bb), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($comma2), getRhsLastTokenIndex($comma2), $_COMMA);
                      makeToken(getRhsFirstTokenIndex($be), getRhsLastTokenIndex($be), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($rp), getRhsLastTokenIndex($rp), $_RIGHT_PAREN);
            $EndJava
          ./
   action_block ::= aA cC tT iI oO nN _opt bB lL oO cC kK
                  | aA bB
   filename -> Value
   block_begin -> Value
   block_end -> Value

   option ::= ast_directory$ad optionWhite '='$eq optionWhite Value$val optionWhite
          /.$BeginJava
                      makeToken(getRhsFirstTokenIndex($ad), getRhsLastTokenIndex($ad), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($eq), getRhsLastTokenIndex($eq), $_EQUAL);
                      makeToken(getRhsFirstTokenIndex($val), getRhsLastTokenIndex($val), $_SYMBOL);
            $EndJava
          ./
   ast_directory ::= aA sS tT _opt dD iI rR eE cC tT oO rR yY
                   | aA dD

   option ::= ast_type$at optionWhite '='$eq optionWhite Value$val optionWhite
          /.$BeginJava
                      makeToken(getRhsFirstTokenIndex($at), getRhsLastTokenIndex($at), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($eq), getRhsLastTokenIndex($eq), $_EQUAL);
                      makeToken(getRhsFirstTokenIndex($val), getRhsLastTokenIndex($val), $_SYMBOL);
            $EndJava
          ./
   ast_type ::= aA sS tT _opt tT yY pP eE
              | aA tT

   option ::= attributes$a optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($a), getRhsLastTokenIndex($a), $_SYMBOL); $EndJava./
            | no attributes$a optionWhite  /.$BeginJava  makeToken(getRhsFirstTokenIndex($a), getRhsLastTokenIndex($a), $_SYMBOL); $EndJava./
   attributes ::= aA tT tT rR iI bB uU tT eE sS

   option ::= automatic_ast$a optionWhite  /.$BeginJava  makeToken(getRhsFirstTokenIndex($a), getRhsLastTokenIndex($a), $_SYMBOL); $EndJava./
            | no automatic_ast$a optionWhite  /.$BeginJava  makeToken(getRhsFirstTokenIndex($a), getRhsLastTokenIndex($a), $_SYMBOL); $EndJava./
   option ::= automatic_ast$aa optionWhite '='$eq optionWhite automatic_ast_value$val optionWhite
          /.$BeginJava
                      makeToken(getRhsFirstTokenIndex($aa), getRhsLastTokenIndex($aa), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($eq), getRhsLastTokenIndex($eq), $_EQUAL);
                      makeToken(getRhsFirstTokenIndex($val), getRhsLastTokenIndex($val), $_SYMBOL);
            $EndJava
          ./
   automatic_ast ::= aA uU tT oO mM aA tT iI cC _opt aA sS tT
                   | aA aA
   automatic_ast_value ::= none
                         | nN eE sS tT eE dD
                         | tT oO pP _opt lL eE vV eE lL

   --
   -- backtrack
   -- byte
   --
   option ::= backtrack$b optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($b), getRhsLastTokenIndex($b), $_SYMBOL); $EndJava./
            | no backtrack$b optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($b), getRhsLastTokenIndex($b), $_SYMBOL); $EndJava./
   backtrack ::= bB aA cC kK tT rR aA cC kK

   option ::= byte$b optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($b), getRhsLastTokenIndex($b), $_SYMBOL); $EndJava./
            | no byte$b optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($b), getRhsLastTokenIndex($b), $_SYMBOL); $EndJava./
   byte ::= bB yY tT eE

   --
   -- conflicts
   --
   option ::= conflicts$c optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($c), getRhsLastTokenIndex($c), $_SYMBOL); $EndJava./
            | no conflicts$c optionWhite  /.$BeginJava  makeToken(getRhsFirstTokenIndex($c), getRhsLastTokenIndex($c), $_SYMBOL); $EndJava./
   conflicts ::= cC oO nN fF lL iI cC tT sS

   --
   -- dat_directory
   -- dat_file
   -- dcl_file
   -- def_file
   -- debug
   --
   option ::= dat_directory$dd optionWhite '='$eq optionWhite Value$val optionWhite
          /.$BeginJava
                      makeToken(getRhsFirstTokenIndex($dd), getRhsLastTokenIndex($dd), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($eq), getRhsLastTokenIndex($eq), $_EQUAL);
                      makeToken(getRhsFirstTokenIndex($val), getRhsLastTokenIndex($val), $_SYMBOL);
            $EndJava
          ./
   dat_directory ::= dD aA tT _opt dD iI rR eE cC tT oO rR yY
                   | dD dD

   option ::= dat_file$df optionWhite '='$eq optionWhite Value$val optionWhite
          /.$BeginJava
                      makeToken(getRhsFirstTokenIndex($df), getRhsLastTokenIndex($df), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($eq), getRhsLastTokenIndex($eq), $_EQUAL);
                      makeToken(getRhsFirstTokenIndex($val), getRhsLastTokenIndex($val), $_SYMBOL);
            $EndJava
          ./
   dat_file ::= dD aA tT _opt fF iI lL eE

   option ::= dcl_file$df optionWhite '='$eq optionWhite Value$val optionWhite
          /.$BeginJava
                      makeToken(getRhsFirstTokenIndex($df), getRhsLastTokenIndex($df), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($eq), getRhsLastTokenIndex($eq), $_EQUAL);
                      makeToken(getRhsFirstTokenIndex($val), getRhsLastTokenIndex($val), $_SYMBOL);
            $EndJava
          ./
   dcl_file ::= dD cC lL _opt fF iI lL eE

   option ::= def_file$df optionWhite '='$eq optionWhite Value$val optionWhite
          /.$BeginJava
                      makeToken(getRhsFirstTokenIndex($df), getRhsLastTokenIndex($df), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($eq), getRhsLastTokenIndex($eq), $_EQUAL);
                      makeToken(getRhsFirstTokenIndex($val), getRhsLastTokenIndex($val), $_SYMBOL);
            $EndJava
          ./
   def_file ::= dD eE fF _opt fF iI lL eE

   option ::= debug$d optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($d), getRhsLastTokenIndex($d), $_SYMBOL); $EndJava./
            | no debug$d optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($d), getRhsLastTokenIndex($d), $_SYMBOL); $EndJava./
   debug ::= dD eE bB uU gG

   --
   -- edit
   -- error_maps
   -- escape
   -- export_terminals
   -- extends_parsetable
   --
   option ::= edit$e optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($e), getRhsLastTokenIndex($e), $_SYMBOL); $EndJava./
            | no edit$e optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($e), getRhsLastTokenIndex($e), $_SYMBOL); $EndJava./
   edit ::= eE dD iI tT

   option ::= error_maps$e optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($e), getRhsLastTokenIndex($e), $_SYMBOL); $EndJava./
            | no error_maps$e optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($e), getRhsLastTokenIndex($e), $_SYMBOL); $EndJava./
   error_maps ::= eE rR rR oO rR _opt mM aA pP sS
                | eE mM

   option ::= escape$e optionWhite '='$eq optionWhite anyNonWhiteChar$val optionWhite
          /.$BeginJava
                      makeToken(getRhsFirstTokenIndex($e), getRhsLastTokenIndex($e), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($eq), getRhsLastTokenIndex($eq), $_EQUAL);
                      makeToken(getRhsFirstTokenIndex($val), getRhsLastTokenIndex($val), $_SYMBOL);
            $EndJava
          ./
   escape ::= eE sS cC aA pP eE

   option ::= export_terminals$et optionWhite '='$eq optionWhite filename$fn optionWhite
          /.$BeginJava
                      makeToken(getRhsFirstTokenIndex($et), getRhsLastTokenIndex($et), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($eq), getRhsLastTokenIndex($eq), $_EQUAL);
                      makeToken(getRhsFirstTokenIndex($fn), getRhsLastTokenIndex($fn), $_SYMBOL);
            $EndJava
          ./
   option ::= export_terminals$et optionWhite '='$eq optionWhite '('$lp optionWhite filename$fn optionWhite ')'$rp optionWhite
          /.$BeginJava
                      makeToken(getRhsFirstTokenIndex($et), getRhsLastTokenIndex($et), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($eq), getRhsLastTokenIndex($eq), $_EQUAL);
                      makeToken(getRhsFirstTokenIndex($lp), getRhsLastTokenIndex($lp), $_LEFT_PAREN);
                      makeToken(getRhsFirstTokenIndex($fn), getRhsLastTokenIndex($fn), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($rp), getRhsLastTokenIndex($rp), $_RIGHT_PAREN);
            $EndJava
          ./
   option ::= export_terminals$et optionWhite '='$eq optionWhite '('$lp optionWhite filename$fn optionWhite ','$comma optionWhite export_prefix$ep optionWhite ')'$rp optionWhite
          /.$BeginJava
                      makeToken(getRhsFirstTokenIndex($et), getRhsLastTokenIndex($et), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($eq), getRhsLastTokenIndex($eq), $_EQUAL);
                      makeToken(getRhsFirstTokenIndex($lp), getRhsLastTokenIndex($lp), $_LEFT_PAREN);
                      makeToken(getRhsFirstTokenIndex($fn), getRhsLastTokenIndex($fn), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($comma), getRhsLastTokenIndex($comma), $_COMMA);
                      makeToken(getRhsFirstTokenIndex($ep), getRhsLastTokenIndex($ep), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($rp), getRhsLastTokenIndex($rp), $_RIGHT_PAREN);
            $EndJava
          ./
   option ::= export_terminals$et optionWhite '='$eq optionWhite '('$lp optionWhite filename$fn optionWhite ','$comma1 optionWhite export_prefix$ep optionWhite ','$comma2 optionWhite export_suffix$es optionWhite ')'$rp optionWhite
          /.$BeginJava
                      makeToken(getRhsFirstTokenIndex($et), getRhsLastTokenIndex($et), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($eq), getRhsLastTokenIndex($eq), $_EQUAL);
                      makeToken(getRhsFirstTokenIndex($lp), getRhsLastTokenIndex($lp), $_LEFT_PAREN);
                      makeToken(getRhsFirstTokenIndex($fn), getRhsLastTokenIndex($fn), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($comma1), getRhsLastTokenIndex($comma1), $_COMMA);
                      makeToken(getRhsFirstTokenIndex($ep), getRhsLastTokenIndex($ep), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($comma2), getRhsLastTokenIndex($comma2), $_COMMA);
                      makeToken(getRhsFirstTokenIndex($es), getRhsLastTokenIndex($es), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($rp), getRhsLastTokenIndex($rp), $_RIGHT_PAREN);
            $EndJava
          ./
   export_terminals ::= eE xX pP oO rR tT _opt tT eE rR mM iI nN aA lL sS
                      | eE tT
   export_prefix -> Value
   export_suffix -> Value

   option ::= extends_parsetable$e optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($e), getRhsLastTokenIndex($e), $_SYMBOL); $EndJava./
            | no extends_parsetable$e optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($e), getRhsLastTokenIndex($e), $_SYMBOL); $EndJava./
   option ::= extends_parsetable$ep optionWhite '='$eq optionWhite Value$val optionWhite
          /.$BeginJava
                      makeToken(getRhsFirstTokenIndex($ep), getRhsLastTokenIndex($ep), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($eq), getRhsLastTokenIndex($eq), $_EQUAL);
                      makeToken(getRhsFirstTokenIndex($val), getRhsLastTokenIndex($val), $_SYMBOL);
            $EndJava
          ./
   extends_parsetable ::= eE xX tT eE nN dD sS _opt pP aA rR sS eE tT aA bB lL eE
                        | eE pP

   --
   -- factory
   -- file_prefix
   -- filter
   -- first
   -- follow
   --
   option ::= factory$f optionWhite '='$eq optionWhite Value$val optionWhite
          /.$BeginJava
                      makeToken(getRhsFirstTokenIndex($f), getRhsLastTokenIndex($f), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($eq), getRhsLastTokenIndex($eq), $_EQUAL);
                      makeToken(getRhsFirstTokenIndex($val), getRhsLastTokenIndex($val), $_SYMBOL);
            $EndJava
          ./
   factory ::= fF aA cC tT oO rR yY

   option ::= file_prefix$fp optionWhite '='$eq optionWhite Value$val optionWhite
          /.$BeginJava
                      makeToken(getRhsFirstTokenIndex($fp), getRhsLastTokenIndex($fp), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($eq), getRhsLastTokenIndex($eq), $_EQUAL);
                      makeToken(getRhsFirstTokenIndex($val), getRhsLastTokenIndex($val), $_SYMBOL);
            $EndJava
          ./
   file_prefix ::= fF iI lL eE _opt pP rR eE fF iI xX
                 | fF pP

   option ::= filter$f optionWhite '='$eq optionWhite Value$val optionWhite
          /.$BeginJava
                      makeToken(getRhsFirstTokenIndex($f), getRhsLastTokenIndex($f), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($eq), getRhsLastTokenIndex($eq), $_EQUAL);
                      makeToken(getRhsFirstTokenIndex($val), getRhsLastTokenIndex($val), $_SYMBOL);
            $EndJava
          ./
   filter ::= fF iI lL tT eE rR

   option ::= first$f optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($f), getRhsLastTokenIndex($f), $_SYMBOL); $EndJava./
            | no first$f optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($f), getRhsLastTokenIndex($f), $_SYMBOL); $EndJava./
   first ::= fF iI rR sS tT

   option ::= follow$f optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($f), getRhsLastTokenIndex($f), $_SYMBOL); $EndJava./
            | no follow$f optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($f), getRhsLastTokenIndex($f), $_SYMBOL); $EndJava./
   follow ::= fF oO lL lL oO wW

   --
   -- goto_default
   --
   option ::= goto_default$g optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($g), getRhsLastTokenIndex($g), $_SYMBOL); $EndJava./
            | no goto_default$g optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($g), getRhsLastTokenIndex($g), $_SYMBOL); $EndJava./
   goto_default ::= gG oO tT oO _opt dD eE fF aA uU lL tT
                  | gG dD

   --
   -- Headers
   --
   option ::= headers$h optionWhite '='$eq optionWhite '('$lp optionWhite filename$fn optionWhite ','$comma1 optionWhite block_begin$bb optionWhite ','$comma2 optionWhite block_end$be optionWhite ')'$rp optionWhite
          /.$BeginJava
                      makeToken(getRhsFirstTokenIndex($h), getRhsLastTokenIndex($h), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($eq), getRhsLastTokenIndex($eq), $_EQUAL);
                      makeToken(getRhsFirstTokenIndex($lp), getRhsLastTokenIndex($lp), $_LEFT_PAREN);
                      makeToken(getRhsFirstTokenIndex($fn), getRhsLastTokenIndex($fn), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($comma1), getRhsLastTokenIndex($comma1), $_COMMA);
                      makeToken(getRhsFirstTokenIndex($bb), getRhsLastTokenIndex($bb), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($comma2), getRhsLastTokenIndex($comma2), $_COMMA);
                      makeToken(getRhsFirstTokenIndex($be), getRhsLastTokenIndex($be), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($rp), getRhsLastTokenIndex($rp), $_RIGHT_PAREN);
            $EndJava
          ./
   headers ::= hH eE aA dD eE rR sS

   --
   -- imp_file
   -- import_terminals
   -- include_directory/include_directories
   --
   option ::= imp_file$if optionWhite '='$eq optionWhite Value$val optionWhite
          /.$BeginJava
                      makeToken(getRhsFirstTokenIndex($if), getRhsLastTokenIndex($if), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($eq), getRhsLastTokenIndex($eq), $_EQUAL);
                      makeToken(getRhsFirstTokenIndex($val), getRhsLastTokenIndex($val), $_SYMBOL);
            $EndJava
          ./
   imp_file ::= iI mM pP _opt fF iI lL eE
              | iI fF

   option ::= import_terminals$it optionWhite '='$eq optionWhite Value$val optionWhite
          /.$BeginJava
                      makeToken(getRhsFirstTokenIndex($it), getRhsLastTokenIndex($it), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($eq), getRhsLastTokenIndex($eq), $_EQUAL);
                      makeToken(getRhsFirstTokenIndex($val), getRhsLastTokenIndex($val), $_SYMBOL);
            $EndJava
          ./
   import_terminals ::= iI mM pP oO rR tT _opt tT eE rR mM iI nN aA lL sS
                      | iI tT

   option ::= include_directory$id optionWhite '='$eq optionWhite Value$val optionWhite
          /.$BeginJava
                      makeToken(getRhsFirstTokenIndex($id), getRhsLastTokenIndex($id), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($eq), getRhsLastTokenIndex($eq), $_EQUAL);
                      makeToken(getRhsFirstTokenIndex($val), getRhsLastTokenIndex($val), $_SYMBOL);
            $EndJava
          ./
   include_directory ::= iI nN cC lL uU dD eE _opt dD iI rR eE cC tT oO rR yY
                       | iI nN cC lL uU dD eE _opt dD iI rR eE cC tT oO rR iI eE sS
                       | iI dD

   --
   -- lalr_level
   -- list
   --
   option ::= lalr_level$l optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($l), getRhsLastTokenIndex($l), $_SYMBOL); $EndJava./
            | no lalr_level$l optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($l), getRhsLastTokenIndex($l), $_SYMBOL); $EndJava./
   option ::= lalr_level$l optionWhite '='$eq optionWhite number$val optionWhite
          /.$BeginJava
                      makeToken(getRhsFirstTokenIndex($l), getRhsLastTokenIndex($l), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($eq), getRhsLastTokenIndex($eq), $_EQUAL);
                      makeToken(getRhsFirstTokenIndex($val), getRhsLastTokenIndex($val), $_SYMBOL);
            $EndJava
          ./
   lalr_level ::= lL aA lL rR _opt lL eE vV eE lL
                | lL aA lL rR
                | lL aA
                | lL lL

   option ::= list$l optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($l), getRhsLastTokenIndex($l), $_SYMBOL); $EndJava./
            | no list$l optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($l), getRhsLastTokenIndex($l), $_SYMBOL); $EndJava./
   list ::= lL iI sS tT

   --
   -- margin
   -- max_cases
   --
   option ::= margin$m optionWhite '='$eq optionWhite number$val optionWhite
          /.$BeginJava
                      makeToken(getRhsFirstTokenIndex($m), getRhsLastTokenIndex($m), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($eq), getRhsLastTokenIndex($eq), $_EQUAL);
                      makeToken(getRhsFirstTokenIndex($val), getRhsLastTokenIndex($val), $_SYMBOL);
            $EndJava
          ./
   margin ::= mM aA rR gG iI nN

   option ::= max_cases$mc optionWhite '='$eq optionWhite number$val optionWhite
          /.$BeginJava
                      makeToken(getRhsFirstTokenIndex($mc), getRhsLastTokenIndex($mc), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($eq), getRhsLastTokenIndex($eq), $_EQUAL);
                      makeToken(getRhsFirstTokenIndex($val), getRhsLastTokenIndex($val), $_SYMBOL);
            $EndJava
          ./
   max_cases ::= mM aA xX _opt cC aA sS eE sS
               | mM cC

   --
   -- names
   -- nt_check
   --
   option ::= names$n optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($n), getRhsLastTokenIndex($n), $_SYMBOL); $EndJava./
            | no names$n optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($n), getRhsLastTokenIndex($n), $_SYMBOL); $EndJava./
   option ::= names$n optionWhite '='$eq optionWhite names_value$val optionWhite
          /.$BeginJava
                      makeToken(getRhsFirstTokenIndex($n), getRhsLastTokenIndex($n), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($eq), getRhsLastTokenIndex($eq), $_EQUAL);
                      makeToken(getRhsFirstTokenIndex($val), getRhsLastTokenIndex($val), $_SYMBOL);
            $EndJava
          ./
   names ::= nN aA mM eE sS

   names_value ::= oO pP tT iI mM iI zZ eE dD
                 | mM aA xX iI mM uU mM
                 | mM iI nN iI mM uU mM

   option ::= nt_check$n optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($n), getRhsLastTokenIndex($n), $_SYMBOL); $EndJava./
            | no nt_check$n optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($n), getRhsLastTokenIndex($n), $_SYMBOL); $EndJava./
   nt_check ::= nN tT _opt cC hH eE cC kK
              | nN cC

   --
   -- or_marker
   -- out_directory
   --
   option ::= or_marker$om optionWhite '='$eq optionWhite anyNonWhiteChar$val optionWhite
          /.$BeginJava
                      makeToken(getRhsFirstTokenIndex($om), getRhsLastTokenIndex($om), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($eq), getRhsLastTokenIndex($eq), $_EQUAL);
                      makeToken(getRhsFirstTokenIndex($val), getRhsLastTokenIndex($val), $_SYMBOL);
            $EndJava
          ./
   or_marker ::= oO rR _opt mM aA rR kK eE rR
               | oO mM

   option ::= out_directory$dd optionWhite '='$eq optionWhite Value$val optionWhite
          /.$BeginJava
                      makeToken(getRhsFirstTokenIndex($dd), getRhsLastTokenIndex($dd), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($eq), getRhsLastTokenIndex($eq), $_EQUAL);
                      makeToken(getRhsFirstTokenIndex($val), getRhsLastTokenIndex($val), $_SYMBOL);
            $EndJava
          ./
   out_directory ::= oO uU tT _opt dD iI rR eE cC tT oO rR yY
                   | oO dD

   --
   -- package
   -- parent_saved
   -- parsetable_interfaces
   -- prefix
   -- priority
   -- programming_language
   -- prs_file
   --
   option ::= parent_saved$ps optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($ps), getRhsLastTokenIndex($ps), $_SYMBOL); $EndJava ./
            | no parent_saved$ps optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($ps), getRhsLastTokenIndex($ps), $_SYMBOL); $EndJava ./
   parent_saved ::= pP aA rR eE nN tT _opt sS aA vV eE dD
                  | pP sS

   option ::= package$p optionWhite '='$eq optionWhite Value$val optionWhite
          /.$BeginJava
                      makeToken(getRhsFirstTokenIndex($p), getRhsLastTokenIndex($p), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($eq), getRhsLastTokenIndex($eq), $_EQUAL);
                      makeToken(getRhsFirstTokenIndex($val), getRhsLastTokenIndex($val), $_SYMBOL);
            $EndJava
          ./
   package ::= pP aA cC kK aA gG eE

   option ::= parsetable_interfaces$pi optionWhite '='$eq optionWhite Value$val optionWhite
          /.$BeginJava
                      makeToken(getRhsFirstTokenIndex($pi), getRhsLastTokenIndex($pi), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($eq), getRhsLastTokenIndex($eq), $_EQUAL);
                      makeToken(getRhsFirstTokenIndex($val), getRhsLastTokenIndex($val), $_SYMBOL);
            $EndJava
          ./
   parsetable_interfaces ::= pP aA rR sS eE tT aA bB lL eE _opt iI nN tT eE rR fF aA cC eE sS
                           | pP aA rR sS eE tT aA bB lL eE
                           | pP iI

   option ::= prefix$p optionWhite '='$eq optionWhite Value$val optionWhite
          /.$BeginJava
                      makeToken(getRhsFirstTokenIndex($p), getRhsLastTokenIndex($p), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($eq), getRhsLastTokenIndex($eq), $_EQUAL);
                      makeToken(getRhsFirstTokenIndex($val), getRhsLastTokenIndex($val), $_SYMBOL);
            $EndJava
          ./
   prefix ::= pP rR eE fF iI xX

   option ::= priority$p optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($p), getRhsLastTokenIndex($p), $_SYMBOL); $EndJava./
            | no priority$p optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($p), getRhsLastTokenIndex($p), $_SYMBOL); $EndJava./
   priority ::= pP rR iI oO rR iI tT yY

   option ::= programming_language$pl optionWhite '='$eq optionWhite programming_language_value$val optionWhite
          /.$BeginJava
                      makeToken(getRhsFirstTokenIndex($pl), getRhsLastTokenIndex($pl), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($eq), getRhsLastTokenIndex($eq), $_EQUAL);
                      makeToken(getRhsFirstTokenIndex($val), getRhsLastTokenIndex($val), $_SYMBOL);
            $EndJava
          ./
   programming_language ::= pP rR oO gG rR aA mM mM iI nN gG _opt lL aA nN gG uU aA gG eE
                          | pP lL
   programming_language_value ::= none
                                | xX mM lL
                                | cC
                                | cC pP pP
                                | jJ aA vV aA
                                | pP lL xX
                                | pP lL xX aA sS mM
                                | mM lL
   option ::= prs_file$pf optionWhite '='$eq optionWhite Value$val optionWhite
          /.$BeginJava
                      makeToken(getRhsFirstTokenIndex($pf), getRhsLastTokenIndex($pf), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($eq), getRhsLastTokenIndex($eq), $_EQUAL);
                      makeToken(getRhsFirstTokenIndex($val), getRhsLastTokenIndex($val), $_SYMBOL);
            $EndJava
          ./
   prs_file ::= pP rR sS _opt fF iI lL eE
              | pP fF

   --
   -- quiet
   --
   option ::= quiet$q optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($q), getRhsLastTokenIndex($q), $_SYMBOL); $EndJava./
            | no quiet$q optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($q), getRhsLastTokenIndex($q), $_SYMBOL); $EndJava./
   quiet ::= qQ uU iI eE tT

   --
   -- read_reduce
   -- remap_terminals
   --
   option ::= read_reduce$r optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($r), getRhsLastTokenIndex($r), $_SYMBOL); $EndJava./
            | no read_reduce$r optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($r), getRhsLastTokenIndex($r), $_SYMBOL); $EndJava./
   read_reduce ::= rR eE aA dD _opt rR eE dD uU cC eE
                 | rR rR

   option ::= remap_terminals$r optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($r), getRhsLastTokenIndex($r), $_SYMBOL); $EndJava./
            | no remap_terminals$r optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($r), getRhsLastTokenIndex($r), $_SYMBOL); $EndJava./
   remap_terminals ::= rR eE mM aA pP _opt tT eE rR mM iI nN aA lL sS
                     | rR tT

   --
   -- scopes
   -- serialize
   -- shift_default
   -- single_productions
   -- slr
   -- soft_keywords
   -- states
   -- suffix
   -- sym_file
   --
   option ::= scopes$s optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($s), getRhsLastTokenIndex($s), $_SYMBOL); $EndJava ./
            | no scopes$s optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($s), getRhsLastTokenIndex($s), $_SYMBOL); $EndJava ./
   scopes ::= sS cC oO pP eE sS

   option ::= serialize$s optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($s), getRhsLastTokenIndex($s), $_SYMBOL); $EndJava ./
            | no serialize$s optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($s), getRhsLastTokenIndex($s), $_SYMBOL); $EndJava ./
   serialize ::= sS eE rR iI aA lL iI zZ eE

   option ::= shift_default$s optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($s), getRhsLastTokenIndex($s), $_SYMBOL); $EndJava ./
            | no shift_default$s optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($s), getRhsLastTokenIndex($s), $_SYMBOL); $EndJava ./
   shift_default ::= sS hH iI fF tT _opt dD eE fF aA uU lL tT
                   | sS dD

   option ::= single_productions$s optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($s), getRhsLastTokenIndex($s), $_SYMBOL); $EndJava ./
            | no single_productions$s optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($s), getRhsLastTokenIndex($s), $_SYMBOL); $EndJava ./
   single_productions ::= sS iI nN gG lL eE _opt pP rR oO dD uU cC tT iI oO nN sS
                        | sS pP

   option ::= slr$s optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($s), getRhsLastTokenIndex($s), $_SYMBOL); $EndJava ./
            | no slr$s optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($s), getRhsLastTokenIndex($s), $_SYMBOL); $EndJava ./
   slr ::= sS lL rR

   option ::= soft_keywords$s optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($s), getRhsLastTokenIndex($s), $_SYMBOL); $EndJava ./
            | no soft_keywords$s optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($s), getRhsLastTokenIndex($s), $_SYMBOL); $EndJava ./
   soft_keywords ::= sS oO fF tT _opt kK eE yY wW oO rR dD sS
                   | sS oO fF tT
                   | sS kK

   option ::= states$s optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($s), getRhsLastTokenIndex($s), $_SYMBOL); $EndJava ./
            | no states$s optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($s), getRhsLastTokenIndex($s), $_SYMBOL); $EndJava ./
   states ::= sS tT aA tT eE sS

   option ::= suffix$s optionWhite '='$eq optionWhite Value$val optionWhite
          /.$BeginJava
                      makeToken(getRhsFirstTokenIndex($s), getRhsLastTokenIndex($s), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($eq), getRhsLastTokenIndex($eq), $_EQUAL);
                      makeToken(getRhsFirstTokenIndex($val), getRhsLastTokenIndex($val), $_SYMBOL);
            $EndJava
          ./
   suffix ::= sS uU fF fF iI xX

   option ::= sym_file$sf optionWhite '='$eq optionWhite Value$val optionWhite
          /.$BeginJava
                      makeToken(getRhsFirstTokenIndex($sf), getRhsLastTokenIndex($sf), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($eq), getRhsLastTokenIndex($eq), $_EQUAL);
                      makeToken(getRhsFirstTokenIndex($val), getRhsLastTokenIndex($val), $_SYMBOL);
            $EndJava
          ./
   sym_file ::= sS yY mM _opt fF iI lL eE
              | sS fF

   --
   -- tab_file
   -- table
   -- template
   -- trace
   --
   option ::= tab_file$tf optionWhite '='$eq optionWhite Value$val optionWhite
          /.$BeginJava
                      makeToken(getRhsFirstTokenIndex($tf), getRhsLastTokenIndex($tf), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($eq), getRhsLastTokenIndex($eq), $_EQUAL);
                      makeToken(getRhsFirstTokenIndex($val), getRhsLastTokenIndex($val), $_SYMBOL);
            $EndJava
          ./
   tab_file ::= tT aA bB _opt fF iI lL eE
              | tT fF

   option ::= template$t optionWhite '='$eq optionWhite Value$val optionWhite
          /.$BeginJava
                      makeToken(getRhsFirstTokenIndex($t), getRhsLastTokenIndex($t), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($eq), getRhsLastTokenIndex($eq), $_EQUAL);
                      makeToken(getRhsFirstTokenIndex($val), getRhsLastTokenIndex($val), $_SYMBOL);
            $EndJava
          ./
   template ::= tT eE mM pP lL aA tT eE

   option ::= trailers$t optionWhite '='$eq optionWhite '('$lp optionWhite filename$fn optionWhite ','$comma1 optionWhite block_begin$bb optionWhite ','$comma2 optionWhite block_end$be optionWhite ')'$rp optionWhite
          /.$BeginJava
                      makeToken(getRhsFirstTokenIndex($t), getRhsLastTokenIndex($t), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($eq), getRhsLastTokenIndex($eq), $_EQUAL);
                      makeToken(getRhsFirstTokenIndex($lp), getRhsLastTokenIndex($lp), $_LEFT_PAREN);
                      makeToken(getRhsFirstTokenIndex($fn), getRhsLastTokenIndex($fn), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($comma1), getRhsLastTokenIndex($comma1), $_COMMA);
                      makeToken(getRhsFirstTokenIndex($bb), getRhsLastTokenIndex($bb), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($comma2), getRhsLastTokenIndex($comma2), $_COMMA);
                      makeToken(getRhsFirstTokenIndex($be), getRhsLastTokenIndex($be), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($rp), getRhsLastTokenIndex($rp), $_RIGHT_PAREN);
            $EndJava
          ./
   trailers ::= tT rR aA iI lL eE rR sS

   option ::= table$t optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($t), getRhsLastTokenIndex($t), $_SYMBOL); $EndJava ./
            | no table$t optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($t), getRhsLastTokenIndex($t), $_SYMBOL); $EndJava ./
   option ::= table$t optionWhite '='$eq optionWhite programming_language_value$val optionWhite
          /.$BeginJava
                      makeToken(getRhsFirstTokenIndex($t), getRhsLastTokenIndex($t), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($eq), getRhsLastTokenIndex($eq), $_EQUAL);
                      makeToken(getRhsFirstTokenIndex($val), getRhsLastTokenIndex($val), $_SYMBOL);
            $EndJava
          ./
   table ::= tT aA bB lL eE

   option ::= trace$t optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($t), getRhsLastTokenIndex($t), $_SYMBOL); $EndJava ./
            | no trace$t optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($t), getRhsLastTokenIndex($t), $_SYMBOL); $EndJava ./
   option ::= trace$t optionWhite '='$eq optionWhite trace_value$val optionWhite
          /.$BeginJava
                      makeToken(getRhsFirstTokenIndex($t), getRhsLastTokenIndex($t), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($eq), getRhsLastTokenIndex($eq), $_EQUAL);
                      makeToken(getRhsFirstTokenIndex($val), getRhsLastTokenIndex($val), $_SYMBOL);
            $EndJava
          ./
   trace ::= tT rR aA cC eE

   trace_value ::= none
                 | cC oO nN fF lL iI cC tT sS
                 | fF uU lL lL

   --
   -- variables
   -- verbose
   -- visitor
   -- visitor_type
   --
   option ::= variables$v optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($v), getRhsLastTokenIndex($v), $_SYMBOL); $EndJava ./
            | no variables$v optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($v), getRhsLastTokenIndex($v), $_SYMBOL); $EndJava ./
   option ::= variables$v optionWhite '='$eq optionWhite variables_value$val optionWhite
          /.$BeginJava
                      makeToken(getRhsFirstTokenIndex($v), getRhsLastTokenIndex($v), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($eq), getRhsLastTokenIndex($eq), $_EQUAL);
                      makeToken(getRhsFirstTokenIndex($val), getRhsLastTokenIndex($val), $_SYMBOL);
            $EndJava
          ./
   variables ::= vV aA rR iI aA bB lL eE sS
   variables_value ::= none
                     | bB oO tT hH
                     | tT eE rR mM iI nN aA lL sS
                     | nN oO nN _opt tT eE rR mM iI nN aA lL sS
                     | nN tT

   option ::= verbose$v optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($v), getRhsLastTokenIndex($v), $_SYMBOL); $EndJava ./
            | no verbose$v optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($v), getRhsLastTokenIndex($v), $_SYMBOL); $EndJava ./
   verbose ::= vV eE rR bB oO sS eE

   option ::= visitor$v optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($v), getRhsLastTokenIndex($v), $_SYMBOL); $EndJava ./
            | no visitor$v optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($v), getRhsLastTokenIndex($v), $_SYMBOL); $EndJava ./
   option ::= visitor$v optionWhite '='$eq optionWhite visitor_value$val optionWhite
          /.$BeginJava
                      makeToken(getRhsFirstTokenIndex($v), getRhsLastTokenIndex($v), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($eq), getRhsLastTokenIndex($eq), $_EQUAL);
                      makeToken(getRhsFirstTokenIndex($val), getRhsLastTokenIndex($val), $_SYMBOL);
            $EndJava
          ./
   visitor ::= vV iI sS iI tT oO rR
   visitor_value ::= none
                   | dD eE fF aA uU lL tT
                   | pP rR eE oO rR dD eE rR

   option ::= visitor_type$vt optionWhite '='$eq optionWhite Value$val optionWhite
          /.$BeginJava
                      makeToken(getRhsFirstTokenIndex($vt), getRhsLastTokenIndex($vt), $_SYMBOL);
                      makeToken(getRhsFirstTokenIndex($eq), getRhsLastTokenIndex($eq), $_EQUAL);
                      makeToken(getRhsFirstTokenIndex($val), getRhsLastTokenIndex($val), $_SYMBOL);
            $EndJava
          ./
   visitor_type ::= vV iI sS iI tT oO rR _opt tT yY pP eE
                  | vV tT

   --
   -- warnings
   --
   option ::= warnings$w optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($w), getRhsLastTokenIndex($w), $_SYMBOL); $EndJava ./
            | no warnings$w optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($w), getRhsLastTokenIndex($w), $_SYMBOL); $EndJava ./
   warnings ::= wW aA rR nN iI nN gG sS

   --
   -- xref
   --
   option ::= xreference$x optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($x), getRhsLastTokenIndex($x), $_SYMBOL); $EndJava ./
            | no xreference$x optionWhite /.$BeginJava  makeToken(getRhsFirstTokenIndex($x), getRhsLastTokenIndex($x), $_SYMBOL); $EndJava ./
   xreference ::= xX rR eE fF
                | xX rR eE fF eE rR eE nN cC eE
%End

max_stars_repo_name: kuafuwang/LPG-VScode

max_issues_repo_name: kuafuwang/LPG-VScode

max_forks_repo_name: kuafuwang/LPG-VScode


text:
# Copyright (c) 2018-2021, Carnegie Mellon University
# See LICENSE for details

Import(profiler, rewrite, code);

Class(CompilerDefaults, rec(
    alignmentSpecifier := "",
    modes := [""],
    version := "",
    major := 0,
    minor := 0,
    compiler := "",
    package := "",
    build := "",
    info := self >> Print(self.compiler, " ", self.version),
    default := self >> self.(self.modes[1])(),
    SIMD := () -> spiral.platforms.SIMDArchitectures
));

Class(IntelC, CompilerDefaults, rec(
    alignmentSpecifier := meth(arg)
		local bytes;

		if Length(arg) > 1 then
			bytes := arg[2];
		else
			bytes := 16;
		fi;

		return "__declspec(align("::String(bytes)::"))";
	end,

    postalign := (self, a,i,is) >> Print(Blanks(i), "__assume_aligned(", a, ", 16);\n"),
    restrict := self >> "restrict",

    looppragma := (self, o,i,is) >> When(Collect(o.cmd, loop)=[],
        Print(Blanks(i), "#pragma vector always\n", Blanks(i), "#pragma ivdep\n"),
        Print(Blanks(i), "#pragma novector\n")),

    compiler := "Intel C++ Compiler",

    SIMD := self >> CopyFields(platforms.SIMDArchitectures, rec(
        hasMMX    := True,
		hasSSE    := True,
		hasSSE2   := True,
		hasSSE3   := True,
        hasSSSE3  := () -> self.major >= 10,
		hasSSE4_1 := () -> self.major >= 10,
		hasSSE4_2 := () -> self.major >= 10)),

    modes := ["ia32", "em64t"],

    # WinGetValue is only defined under windows. If the call works, it takes
    # the returned path, adds "bin" onto it, and then appends
    # the iclvars batch file redirected to nul.
    ia32 := self >> CopyFields(default_profiles.win_x86_icc, rec(
        premake := Concat(
            "\"",
            let(a := Try(WinGetValue("SYSTEM/CurrentControlSet/Control/Session Manager/Environment/ICPP_COMPILER15")),
                b := Try(WinGetValue("SYSTEM/CurrentControlSet/Control/Session Manager/Environment/ICPP_COMPILER14")),
                When(a[1],
                    Concat(a[2], "bin\\"),
                    When(b[1],
                        Concat(b[2], "bin\\"),
                        ""
                    )
                )
            ),
            "iclvars.bat\" > nul"
        )
    )),

    em64t := self >> CopyFields(default_profiles.win_x64_icc, rec(
        premake := Concat(
            "\"",
            let(a := Try(WinGetValue("SYSTEM/CurrentControlSet/Control/Session Manager/Environment/ICPP_COMPILER15")),
                b := Try(WinGetValue("SYSTEM/CurrentControlSet/Control/Session Manager/Environment/ICPP_COMPILER14")),
                When(a[1],
                    Concat(a[2], "bin\\"),
                    When(b[1],
                        Concat(b[2], "bin\\"),
                        ""
                    )
                )
            ),
            "iclvars.bat\" intel64 > nul"
        )
    ))
));

Class(GnuC, IntelC, rec(
    compiler := "gcc (GNU Compiler Collection)",

	SIMD := self >> CopyFields(platforms.SIMDArchitectures, rec(
        hasMMX    := True,
		hasSSE    := True,
		hasSSE2   := True,
		hasSSE3   := True,
        hasSSSE3  := True,
		hasSSE4_1 := True,
		hasSSE4_2 := True)),

	alignmentSpecifier := meth(arg)
		local bytes;

		if Length(arg) > 1 then
			bytes := arg[2];
		else
			bytes := 16;
		fi;

		return "__attribute__((aligned("::String(bytes)::")))";
	end,
));

 Class(Llvm_Clang, IntelC, rec(
    compiler := "clang (LLVM Compiler Collection)",

	SIMD := self >> CopyFields(platforms.SIMDArchitectures, rec(
        hasMMX    := True,
		hasSSE    := True,
		hasSSE2   := True,
		hasSSE3   := True,
        hasSSSE3  := True,
		hasSSE4_1 := True,
		hasSSE4_2 := True)),

	alignmentSpecifier := meth(arg)
		local bytes;

		if Length(arg) > 1 then
			bytes := arg[2];
		else
			bytes := 16;
		fi;

		return "__attribute__((aligned("::String(bytes)::")))";
	end,
));

Class(GnuC_ARM, IntelC, rec(
    compiler := "gcc (GNU Compiler Collection)",

	SIMD := self >> CopyFields(platforms.SIMDArchitectures, rec(
        hasMMX    := False,
		hasSSE    := False,
		hasSSE2   := False,
		hasSSE3   := False,
        hasSSSE3  := False,
		hasSSE4_1 := False,
		hasSSE4_2 := False)),

	alignmentSpecifier := meth(arg)
		local bytes;

		if Length(arg) > 1 then
			bytes := arg[2];
		else
			bytes := 16;
		fi;

		return "__attribute__((aligned("::String(bytes)::")))";
	end,
));

Class(VisualC, CompilerDefaults, rec(
    compiler := "MS VisualStudio.NET C++ compiler",
    modes := ["ia32"],
    SIMD := () -> CopyFields(platforms.SIMDArchitectures, rec(hasMMX := True, hasSSE:=True, hasSSE2:=True, hasSSE3:=True)),

	alignmentSpecifier := meth(arg)
		local bytes;

		if Length(arg) > 1 then
			bytes := arg[2];
		else
			bytes := 16;
		fi;

		return "__declspec(align("::String(bytes)::"))";
	end,

    ia32 := self >> CopyFields(default_profiles.win_x86_vcc),
));

Class(VisualC_12, VisualC, rec(
    compiler := "MS VisualStudio.NET C++ 12.0 compiler",
    modes    := ["x86", "x64"],
    SIMD := () -> CopyFields(platforms.SIMDArchitectures, rec(hasMMX := True, hasSSE:=True, hasSSE2:=True, hasSSE3:=True, hasSSE4_1 := True)),
    x86 := self >> CopyFields(default_profiles.win_x86_vcc, rec(
        premake := () -> "call \"%VS120COMNTOOLS%..\\..\\VC\\vcvarsall.bat\" x86 > nul"
    )),
    x64 := self >> CopyFields(default_profiles.win_x64_vcc, rec(
        premake := () -> "call \"%VS120COMNTOOLS%..\\..\\VC\\vcvarsall.bat\" x64 > nul"
    ))
));

Class(NvidiaCuda, IntelC, rec(
    compiler := "NVIDIA Cuda compiler",

	SIMD := self >> CopyFields(platforms.SIMDArchitectures, rec(
        hasMMX    := True,
		hasSSE    := True,
		hasSSE2   := True,
		hasSSE3   := True,
        hasSSSE3  := True,
		hasSSE4_1 := True,
		hasSSE4_2 := True)),

	alignmentSpecifier := meth(arg)
		local bytes;

		if Length(arg) > 1 then
			bytes := arg[2];
		else
			bytes := 16;
		fi;

		return "__attribute__((aligned("::String(bytes)::")))";
	end,
));

SupportedCompilers := rec(
    IntelC := IntelC,
    VisualC := VisualC,
    VisualC_12 := VisualC_12,
    GnuC := GnuC,
    GnuC_ARM := GnuC_ARM,
    Llvm_Clang := Llvm_Clang,
    NvidiaCuda := NvidiaCuda
);


text:
ok Merge branch 'master' of github.com:INFINITY-RUBER/Machine_Learning_A-Z_Hands-On-Python-R-In-Data-Science

# Por favor ingrese un mensaje de commit que explique por qué es necesaria esta fusión,
# especialmente si esto fusiona un upstream actualizado en una rama de tópico.
#
# Líneas comenzando con '#' serán ignoradas, y un mensaje vacío aborta
# el commit.

max_stars_repo_path: .gi

max_issues_repo_path: .gi

max_forks_repo_path: .gi


text:
DZ2 schwarz,1,Projekt		//creates a zylinder
  S(1,1,2)			//redifines edges as (r,r,h)


text:
# Copyright (c) 2018-2021, Carnegie Mellon University
# See LICENSE for details

Class(PrunedDFT, TaggedNonTerminal, rec(
    abbrevs := [
        (n,blk,pat) -> Checked(IsPosIntSym(n), IsPosIntSym(blk), IsList(pat),
            AnySyms(n,blk) or (IsInt(_unwrap(n)/_unwrap(blk)) and ForAll(pat, i->IsInt(i) and i < n/blk)),
            [_unwrap(n), 1, _unwrap(blk), pat]),
        (n,k,blk,pat) -> Checked(IsPosIntSym(n), IsIntSym(k), IsPosIntSym(blk), IsList(pat),
            AnySyms(n,k) or Gcd(_unwrap(n),_unwrap(k))=1,
            AnySyms(n,blk) or (IsInt(_unwrap(n)/_unwrap(blk)) and ForAll(pat, i->IsInt(i) and i < n/blk)),
            [_unwrap(n), When(AnySyms(n,k), k, k mod _unwrap(n)), _unwrap(blk), pat])
        ],

    dims := self >> let(
        size := self.params[1],
        d := [size, self.params[3]*Length(self.params[4])],
        When(self.transposed, [d[2], d[1]], d)
    ),

    terminate := self >> let(
        size := self.params[1], blk := self.params[3], pat := self.params[4],
        res := DFT(size, self.params[2]).terminate() *
               Tensor(Mat(List(pat, i->BasisVec(size/blk, i))).transpose(), I(blk)).terminate(),
        When(self.transposed, res.transpose(), res)
    ),

    isReal    := self >> false,
    normalizedArithCost := self >> let(n := self.params[1], IntDouble(5 * n * d_log(n) / d_log(2))),
    TType := T_Complex(T_Real(64))
));

Class(PrunedIDFT, TaggedNonTerminal, rec(
    abbrevs := [
        (n,blk,pat) -> Checked(IsPosIntSym(n), IsPosIntSym(blk), IsList(pat),
            AnySyms(n,blk) or (IsInt(_unwrap(n)/_unwrap(blk)) and ForAll(pat, i->IsInt(i) and i < n/blk)),
            [_unwrap(n), 1, _unwrap(blk), pat]),
        (n,k,blk,pat) -> Checked(IsPosIntSym(n), IsIntSym(k), IsPosIntSym(blk), IsList(pat),
            AnySyms(n,k) or Gcd(_unwrap(n),_unwrap(k))=1,
            AnySyms(n,blk) or (IsInt(_unwrap(n)/_unwrap(blk)) and ForAll(pat, i->IsInt(i) and i < n/blk)),
            [_unwrap(n), When(AnySyms(n,k), k, k mod _unwrap(n)), _unwrap(blk), pat])
        ],

    dims := self >> let(
        size := self.params[1],
        d := [size, self.params[3]*Length(self.params[4])],
        When(not self.transposed, [d[2], d[1]], d)
    ),

    terminate := self >> let(
        size := self.params[1], blk := self.params[3], pat := self.params[4],
        res := DFT(size, self.params[2]).terminate() *
               Tensor(Mat(List(pat, i->BasisVec(size/blk, i))).transpose(), I(blk)).terminate(),
        When(not self.transposed, res.transpose(), res)
    ),

    isReal    := self >> false,
    normalizedArithCost := self >> let(n := self.params[1], IntDouble(5 * n * d_log(n) / d_log(2))),
    TType := T_Complex(T_Real(64))
));

_pruned_children := function(m, n, scatpat, pdft)
    local pdfts, scatpats, iterparts, uspats, uuspats, uspats, spats;
    spats := Map([0..m-1], i->List(Intersection(scatpat, i+m*[0..n-1]), j->j));
    uspats := Map([0..Length(spats)-1], i->(spats[i+1]-i)/m);
    uuspats := Set(uspats);

    # partition iterations into unique patterns
    iterparts := List([1..Length(uuspats)], j->Filtered([1..m], i->uspats[i] = uuspats[j])-1);
    Sort(iterparts);

    scatpats := List(iterparts, lst->uspats[lst[1]+1]);
    pdfts := Map(scatpats, sp->pdft(n, sp));
    return pdfts;
end;

_ctpr_applicable := function(m, n, scatpat)
    local spats, gpats, strides;
    spats := Map([0..m-1], i->List(Intersection(scatpat, i+m*[0..n-1]), j->j));
    gpats := Map(spats, lst->Map(lst, i->Position(scatpat, i)-1));
    strides := Set(Flat(Map(gpats, lst->Map([1..Length(lst)-1], j->lst[j+1]-lst[j]))));
    return ForAll(spats, i->i<>[]) and  (Length(strides) in [0, 1]);
end;

_build_basef := lst -> When(lst = lst[1] + [0..Length(lst)-1], let(i := Ind(Length(lst)), Lambda(i, lst[1] + i)), FData(Map(lst, V)));

_build_stack := function(m, n, scatpat, pdfts, NI, gsop, istck, stck, cmpse)
    local stack, isu, is, itervars, gatscats, lbds, lbdvars, itercounts, iterbasesf, iterbases, iterparts, uuspats, uspats, bases, strides, stride, spats, gpats;
    spats := Map([0..m-1], i->List(Intersection(scatpat, i+m*[0..n-1]), j->j));
    gpats := Map(spats, lst->Map(lst, i->Position(scatpat, i)-1));
    #When(ForAny(spats, i->i=[]), Error("need at least one element per child DFT"));
    strides := Set(Flat(Map(gpats, lst->Map([1..Length(lst)-1], j->lst[j+1]-lst[j]))));
    stride := When(Length(strides) = 1, strides[1], 1);
    bases := Map(gpats, i->i[1]);

    uspats := Map([0..Length(spats)-1], i->(spats[i+1]-i)/m);
    uuspats := Set(uspats);

    iterparts := List([1..Length(uuspats)], j->Filtered([1..m], i->uspats[i] = uuspats[j])-1);
    Sort(iterparts);
    iterbases := Map(iterparts, lst->Map(lst, i->bases[i+1]));
    iterbasesf := List(iterbases, _build_basef);
    itercounts := List(iterparts, Length);
    itervars := List(iterparts, lst->Ind(Length(lst)));
    lbdvars := List(iterparts, lst->Ind(Length(gpats[lst[1]+1])));
    lbds := List([1..Length(itervars)], i->Lambda(lbdvars[i], stride*lbdvars[i]+iterbasesf[i].at(itervars[i])).setRange(NI));
    gatscats := List(lbds, i->ApplyFunc(gsop, [i]));

    is := List([1..Length(itervars)], i->ApplyFunc(istck, [itervars[i], cmpse(pdfts[i], gatscats[i])]));
    isu := Map([1..Length(is)], i->When(itervars[i].range=1, is[i].unroll().child(1), is[i]));
    stack := When(Length(isu) = 1, isu[1], ApplyFunc(stck, isu));
    return stack;
end;

NewRulesFor(PrunedDFT, rec(
    PrunedDFT_base := rec(
       forTransposition := false,
       maxSize := 256,
       applicable := (self, nt) >> not nt.hasTags() and nt.params[1] <= self.maxSize and nt.params[3] = 1,
       children := nt -> [[DFT(nt.params[1], nt.params[2])]],
       apply := (nt, C, cnt) -> let(size := nt.params[1], blk := nt.params[3], pat := nt.params[4],
            C[1] * Tensor(Mat(List(pat, i->BasisVec(size/blk, i))).transpose(), I(blk)).terminate())
    ),
    PrunedDFT_DFT := rec(
       forTransposition := true,
       applicable := (self, nt) >> nt.params[1] = nt.params[3] and nt.params[4] = [0],
       children := nt -> [[ DFT(nt.params[1], nt.params[2]).withTags(nt.getTags()) ]],
       apply := (nt, C, cnt) -> C[1]
    ),
    PrunedDFT_CT := rec(
       forTransposition := true,
       applicable := (self, nt) >> nt.params[1] > 2
            and not nt.hasTags()
            and not IsPrime(nt.params[1])
            and nt.params[3] > 1,
        children  := nt -> Map2(Filtered(DivisorPairs(nt.params[1]), (l) -> IsInt(nt.params[3]/l[1])),
            (m,n) -> [ DFT(m, nt.params[2] mod m), PrunedDFT(n, nt.params[2] mod n, nt.params[3]/m, nt.params[4]) ]
        ),
        apply := (nt, C, cnt) -> let(mn := nt.params[1], m := Rows(C[1]), n := Rows(C[2]),
            Tensor(C[1], I(n)) *
            Diag(fPrecompute(Tw1(mn, n, nt.params[2]))) *
            L(mn, m) * Tensor(C[2], I(m))
        )),
    PrunedDFT_CT_rec_block := rec(
       forTransposition := true,
       applicable := (self, nt) >> nt.params[1] > 2
            and not nt.hasTags()
            and not IsPrime(nt.params[1])
            and nt.params[3] = 1
            and Last(nt.params[4])+1-nt.params[4][1] = Length(Set(nt.params[4]))
            and ForAny(Map2(DivisorPairs(nt.params[1]), (m,n)->_ctpr_applicable(m, n, nt.params[4])), i->i),
       children := (nt) -> Filtered(Map2(DivisorPairs(nt.params[1]), (m, n) -> [ DFT(m, nt.params[2] mod m) ]::
                              _pruned_children(m, n, nt.params[4], (r, sp) -> PrunedDFT(r, nt.params[2] mod n, nt.params[3], sp))),
                              lst -> ForAll(Filtered(lst, i->ObjId(i) = PrunedDFT), j->j.params[4] <> [])),
        apply := (nt, C, cnt) -> let(mn := nt.params[1], m := Rows(C[1]), n := Rows(C[2]),
            Tensor(C[1], I(n)) *
            Diag(fPrecompute(Tw1(mn, n, nt.params[2]))) *
            _build_stack(m, n, nt.params[4], Drop(C, 1), nt.dims()[2], Gath, IterVStack, VStack, (a,b)->a*b)
        )
    )
));

NewRulesFor(PrunedIDFT, rec(
    PrunedIDFT_base := rec(
       forTransposition := false,
       maxSize :=256,
       applicable := (self, nt) >> not nt.hasTags() and nt.params[1] <= self.maxSize and nt.params[3] = 1,
       children := nt -> [[DFT(nt.params[1], nt.params[2])]],
       apply := (nt, C, cnt) -> let(size := nt.params[1], blk := nt.params[3], pat := nt.params[4],
            Tensor(Mat(List(pat, i->BasisVec(size/blk, i))) * C[1], I(blk)).terminate())
    ),
    PrunedIDFT_CT_rec_block := rec(
       forTransposition := true,
       applicable := (self, nt) >> nt.params[1] > 2
            and not nt.hasTags()
            and not IsPrime(nt.params[1])
            and nt.params[3] = 1
            and Last(nt.params[4])+1-nt.params[4][1] = Length(Set(nt.params[4]))
            and ForAny(Map2(DivisorPairs(nt.params[1]), (m,n)->_ctpr_applicable(m, n, nt.params[4])), i->i),
       children := (nt) -> Filtered(Map2(DivisorPairs(nt.params[1]), (n, m) ->
                              _pruned_children(m, n, nt.params[4], (r, sp) -> PrunedIDFT(r, nt.params[2] mod n, nt.params[3], sp)) ::
                              [ DFT(m, nt.params[2] mod m) ]),
                              lst -> ForAll(Filtered(lst, i->ObjId(i) = PrunedIDFT), j->j.params[4] <> [])),
        apply := (nt, C, cnt) -> let(mn := nt.params[1], m := Rows(Last(C)), n := Cols(C[1]),
            _build_stack(m, n, nt.params[4], DropLast(C, 1), nt.dims()[1], Scat, IterHStack1, HStack1, (a,b)->b*a) *
            Diag(fPrecompute(Tw1(mn, n, nt.params[2]))) *
            Tensor(Last(C), I(n))
        )
    )
));

Class(IOPrunedDFT, TaggedNonTerminal, rec(
    abbrevs := [
        (n,oblk,opat,iblk,ipat) -> Checked(IsPosIntSym(n), IsPosIntSym(oblk), IsList(opat), IsPosIntSym(iblk), IsList(ipat),
            AnySyms(n,iblk,oblk) or (IsInt(_unwrap(n)/_unwrap(iblk)) and IsInt(_unwrap(n)/_unwrap(oblk)) and
                ForAll(ipat, i->IsInt(i) and i < n/iblk) and ForAll(opat, i->IsInt(i) and i < n/oblk)),
            [_unwrap(n), 1, _unwrap(oblk), opat, _unwrap(iblk), ipat]),

        (n,k,oblk,opat,iblk,ipat) -> Checked(IsPosIntSym(n), IsIntSym(k), IsPosIntSym(oblk), IsList(opat), IsPosIntSym(iblk), IsList(ipat),
            AnySyms(n,k) or Gcd(_unwrap(n),_unwrap(k))=1,
            AnySyms(n,iblk,oblk) or (IsInt(_unwrap(n)/_unwrap(iblk)) and IsInt(_unwrap(n)/_unwrap(oblk)) and
                ForAll(ipat, i->IsInt(i) and i < n/iblk) and ForAll(opat, i->IsInt(i) and i < n/oblk)),
            [_unwrap(n), When(AnySyms(n,k), k, k mod _unwrap(n)), _unwrap(oblk), opat, _unwrap(iblk), ipat])
        ],
    dims      := self >> [self.params[3]*Length(self.params[4]), self.params[5]*Length(self.params[6])],
    terminate := self >> let(size := self.params[1],
        oblk := self.params[3], opat := self.params[4], iblk := self.params[5], ipat := self.params[6],
        Tensor(Mat(List(opat, i->BasisVec(size/oblk, i))), I(oblk)).terminate() *
        DFT(size, self.params[2]).terminate() *
        Tensor(Mat(List(ipat, i->BasisVec(size/iblk, i))).transpose(), I(iblk)).terminate()),
    isReal    := self >> false,
    normalizedArithCost := self >> let(n := self.params[1], IntDouble(5 * n * d_log(n) / d_log(2))),
    TType := T_Complex(T_Real(64))
));

NewRulesFor(IOPrunedDFT, rec(
    IOPrunedDFT_base := rec(
       forTransposition := true,
       maxSize := 16,
       applicable := (self, nt) >> not nt.hasTags() and nt.params[1] <= self.maxSize and nt.params[3] = 1 and nt.params[5] = 1,
       children := nt -> [[DFT(nt.params[1], nt.params[2])]],
       apply := (nt, C, cnt) -> let(size := nt.params[1], oblk := nt.params[3], opat := nt.params[4], iblk := nt.params[5], ipat := nt.params[6],
            Tensor(Mat(List(opat, i->BasisVec(size/oblk, i))), I(oblk)).terminate() *
            C[1] *
            Tensor(Mat(List(ipat, i->BasisVec(size/iblk, i))).transpose(), I(iblk)).terminate())
    ),

    IOPrunedDFT__PrunedDFT := rec(
       forTransposition := true,
       applicable := (self, nt) >> nt.params[1] = nt.params[3] and nt.params[4] = [0],
       children := nt -> [[ PrunedDFT(nt.params[1], nt.params[2], nt.params[5], nt.params[6]).withTags(nt.getTags()) ]],
       apply := (nt, C, cnt) -> C[1]
    ),

    IOPrunedDFT__PrunedDFT_T := rec(
       forTransposition := true,
       applicable := (self, nt) >> nt.params[1] = nt.params[5] and nt.params[6] = [0],
       children := nt -> [[ PrunedDFT(nt.params[1], nt.params[2], nt.params[3], nt.params[4]).transpose().withTags(nt.getTags()) ]],
       apply := (nt, C, cnt) -> C[1]
    ),

    IOPrunedDFT__Gath_PrunedDFT := rec(
       forTransposition := true,
       maxSize := 16,
       applicable := (self, nt) >> not nt.hasTags() and nt.params[1] <= self.maxSize and
           ((nt.params[3] = 1 and not (nt.params[5] = 1)) or (nt.params[3] * nt.params[5] < nt.params[1])),
       children := nt -> [[ PrunedDFT(nt.params[1], nt.params[2], nt.params[5], nt.params[6]) ]],
       apply := (nt, C, cnt) -> let(size := nt.params[1], oblk := nt.params[3], opat := nt.params[4], iblk := nt.params[5], ipat := nt.params[6],
            Tensor(Mat(List(opat, i->BasisVec(size/oblk, i))), I(oblk)).terminate() * C[1])
    ),

    IOPrunedDFT__PrunedDFT_T_Scat := rec(
       forTransposition := true,
       maxSize := 16,
       applicable := (self, nt) >> not nt.hasTags() and nt.params[1] <= self.maxSize and
           (((not nt.params[3] = 1) and nt.params[5] = 1) or(nt.params[3] * nt.params[5] < nt.params[1])),
       children := nt -> [[ PrunedDFT(nt.params[1], nt.params[2], nt.params[3], nt.params[4]).transpose() ]],
       apply := (nt, C, cnt) -> let(size := nt.params[1], oblk := nt.params[3], opat := nt.params[4], iblk := nt.params[5], ipat := nt.params[6],
            C[1] * Tensor(Mat(List(ipat, i->BasisVec(size/iblk, i))).transpose(), I(iblk)).terminate())
    ),

    IOPrunedDFT_CT := rec(
       forTransposition := true,
       applicable := (self, nt) >> nt.params[1] > 2 and nt.params[3] * nt.params[5] >= nt.params[1]
            and not nt.hasTags()
            and not IsPrime(nt.params[1])
            and nt.params[3] > 1,
        children  := nt -> Map2(Filtered(DivisorPairs(nt.params[1]), (mn) -> IsInt(nt.params[3]/mn[2]) and IsInt(nt.params[5]/mn[1])),
            (m,n) -> [
                PrunedDFT(m, nt.params[2] mod m, nt.params[3]/n, nt.params[4]).transpose(),
                PrunedDFT(n, nt.params[2] mod n, nt.params[5]/m, nt.params[6]) ]
        ),
        apply := (nt, C, cnt) -> let(mn := nt.params[1], m := Cols(C[1]), n := Rows(C[2]),
            Tensor(C[1], I(n)) *
            Diag(fPrecompute(Tw1(mn, n, nt.params[2]))) *
            L(mn, m) * Tensor(C[2], I(m))
        ))
));


text:
# Solution in '''RPN'''
Play24 := function()
	local input, digits, line, c, chars, stack, stackptr, cur, p, q, ok, a, b, run;
	input := InputTextUser();
	run := true;
	while run do
		digits := List([1 .. 4], n -> Random(1, 9));
		while true do
			Display(digits);
			line := ReadLine(input);
			line := Chomp(line);
			if line = "end" then
				run := false;
				break;
			elif line = "next" then
				break;
			else
				ok := true;
				stack := [ ];
				stackptr := 0;
				chars := "123456789+-*/ ";
				cur := ShallowCopy(digits);
				for c in line do
					if c = ' ' then
						continue;
					fi;
					p := Position(chars, c);
					if p = fail then
						ok := false;
						break;
					fi;
					if p < 10 then
						q := Position(cur, p);
						if q = fail then
							ok := false;
							break;
						fi;
						Unbind(cur[q]);
						stackptr := stackptr + 1;
						stack[stackptr] := p;
					else
						if stackptr < 2 then
							ok := false;
							break;
						fi;
						b := stack[stackptr];
						a := stack[stackptr - 1];
						stackptr := stackptr - 1;
						if c = '+' then
							a := a + b;
						elif c = '-' then
							a := a - b;
						elif c = '*' then
							a := a * b;
						elif c = '/' then
							if b = 0 then
								ok := false;
								break;
							fi;
							a := a / b;
						else
							ok := false;
							break;
						fi;
						stack[stackptr] := a;
					fi;
				od;
				if ok and stackptr = 1 and Size(cur) = 0 then
					if stack[1] = 24 then
						Print("Good !\n");
						break;
					else
						Print("Bad value: ", stack[1], "\n");
						continue;
					fi;
				fi;
				Print("Invalid expression\n");
			fi;
		od;
	od;
	CloseStream(input);
end;

# example session
# type "end" to quit the game, "next" to try another list of digits
gap> Play24();
[ 7, 6, 8, 5 ]
86*75-/
Good !
[ 5, 9, 2, 7 ]
end
gap>

max_stars_repo_name: djgoku/RosettaCodeData

max_issues_repo_name: djgoku/RosettaCodeData

max_forks_repo_name: djgoku/RosettaCodeData


text:
--
-- An LPG Parser Template Using lpg.jar
--
-- Macros that may be redefined in an instance of this template
--
--     %additional_interfaces
--     %super_stream_class
--
-- B E G I N N I N G   O F   T E M P L A T E   dtUnifiedTemplateF
--
%Options programming_Language=typescript
%Options table
%Options margin=4
%Options prefix=Char_
%Options action-block=("*.ts", "/.", "./")
%Options ParseTable=ParseTable

--
-- The EOF and ERROR symbols are assigned a default here as a
-- convenience.
--
%EOF
    EOF
%End

%Define
    $Header
    /.
                //
                // Rule %rule_number:  %rule_text
                //
                ./

    $BeginAction
    /.%Header%case %rule_number: {./

    $EndAction
    /.          break;
                }./

    $BeginJava
    /.%BeginAction
                    %symbol_declarations./

    $EndJava /.%EndAction./

    $NoAction
    /.%Header%case %rule_number:
                    break;./

    $NullAction
    /.%Header%case %rule_number:
                    %setResult(null);
                    break;./

    $BeginActions
    /.
        public void ruleAction(ruleNumber : number )
        {
            switch (ruleNumber)
            {./

    $SplitActions
    /.
	            default:
	                ruleAction%rule_number(ruleNumber);
	                break;
	        }
	        return;
	    }

	    public void ruleAction%rule_number(ruleNumber : number )
	    {
	        switch (ruleNumber)
	        {./

    $EndActions
    /.
                default:
                    break;
            }
            return;
        }./

    $additional_interfaces /../
    $super_stream_class /.LpgLexStream./
%End

%Globals
    /.
    import {BadParseException, RuleAction, PrsStream, ParseTable, BacktrackingParser, IToken, ErrorToken, ILexStream, NullExportedSymbolsException,
UnimplementedTerminalsException, Lpg, UndefinedEofSymbolException, NotBacktrackParseTableException, BadParseSymFileException,
IPrsStream, Monitor, DiagnoseParser, IAst, IAstVisitor, IAbstractArrayList, NotDeterministicParseTableException,
 DeterministicParser, NullTerminalSymbolsException } from "lpg2ts";
    ./
%End

%Headers
    /.
    export class %action_type extends %super_stream_class implements %sym_type, RuleAction%additional_interfaces
    {
        private static  prs : ParseTable = new %prs_type();
        private  this.dtParser : DeterministicParser;

        private void setResult(object1 : any ) { this.dtParser.setSym1(object1); }
        public  getParser()  : DeterministicParser { return this.dtParser; }
        public  getRhsSym(i : number) : any { return this.dtParser.getSym(i); }
        public  getRhsTokenIndex(i : number) : number { return this.dtParser.getToken(i); }
        public  getRhsFirstTokenIndex(i : number) : number { return this.dtParser.getFirstToken(i); }
        public  getRhsLastTokenIndex(i : number) : number { return this.dtParser.getLastToken(i); }

        public  getLeftSpan() : number{ return this.dtParser.getFirstToken(); }
        public  getRightSpan() : number{ return this.dtParser.getLastToken(); }

       constructor(filename : string, number tab)
        {
            super(filename,null, tab);
        }

        public  orderedExportedSymbols() : string[]{ return this.orderedTerminalSymbols; }
        public  getEOFTokenKind() : number { return %prs_type.EOFT_SYMBOL; }

        public  getILexStream() : ILexStream{ return <%super_stream_class> this; }

        /**
         * @deprecated replaced by {@link #getILexStream()}
         */
        public  getLexStream()  : ILexStream{ return <%super_stream_class> this; }

         public parser(error_repair_count : number = 0 ,  monitor? : Monitor) :  %ast_class | null
        {
            try
            {
                this.dtParser = new DeterministicParser(this, prs, this);
            }
            catch (e)
            {
                if( e instanceof NotDeterministicParseTableException){
                    Lpg.Lang.System.Out.println("****Error: Regenerate %prs_type.ts with -NOBACKTRACK option");
                    process.exit(1);
                }
                if( e instanceof NotDeterministicParseTableException){
                    Lpg.Lang.System.Out.println("****Error: Bad Parser Symbol File -- %sym_type.ts. Regenerate %prs_type.ts");
                    process.exit(1);
                }
            }

            this.dtParser.setMonitor(monitor);

            try
            {
                return <%ast_type> this.dtParser.parse();
            }
            catch (ex)
            {

               if( ex instanceof BadParseException)
               {
                    let e = <BadParseException>(e);
                    reset(e.error_token); // point to error token
                    Lpg.Lang.System.Out.print("Error detected on character " + e.error_token);
                    if (e.error_token < getStreamLength())
                        Lpg.Lang.System.Out.print(" at line " + getLine(e.error_token) + ", column " + this.getColumn(e.error_token));
                    else Lpg.Lang.System.Out.print(" at end of file ");
                    Lpg.Lang.System.Out.println(" with kind " + getKind(e.error_token));
               }
               else{
                    throw ex;
               }
            }

            return null;
        }

    ./

%End

%Rules
    /.%BeginActions./
%End

%Trailers
    /.
        %EndActions
    }
    ./
%End

--
-- E N D   O F   T E M P L A T E
--


text:
PolynomialRegression := function(x, y, n)
	local a;
	a := List([0 .. n], i -> List(x, s -> s^i));
	return TransposedMat((a * TransposedMat(a))^-1 * a * TransposedMat([y]))[1];
end;

x := [0,  1,  2,  3,  4,  5,  6,   7,   8,   9,   10];
y := [1,  6,  17, 34, 57, 86, 121, 162, 209, 262, 321];

# Return coefficients in ascending degree order
PolynomialRegression(x, y, 2);
# [ 1, 2, 3 ]


text:
# Copyright (c) 2018-2021, Carnegie Mellon University
# See LICENSE for details

prep_hex_perm_spu := function(p)
    local retval;
    retval :=  ConcatenationString(
                "0x", p{[  1 ..  8]}, ", ",
                "0x", p{[  9 .. 16]}, ", ",
                "0x", p{[ 17 .. 24]}, ", ",
                "0x", p{[ 25 .. 32]});
    return(retval);
end;

prep_perm_string_spu := function(p)
    local base_string, final_string, i_counter, zeroOutString, v;
    # This handles both 4x32f and 2x64f perm strings
    v := Length(p);
    base_string := [0..((16/v)-1)];
    zeroOutString := List([1..(16/v)], i->128);
    final_string := [];
    # A value of '128' in the permutation param list causes the spu_shuffle to zero out the corresponding bytes.
    for i_counter in (p-1) do # changed Reversed(p-1) to (p-1)
       if i_counter = 127 then
          Append(final_string, zeroOutString);
        else
           Append(final_string, (base_string + i_counter * (16/v)));
        fi;
    od;
    return final_string;
end;

# NOTE: The first section is Intel SSE/2/3 specific, and has to be ported
# over to SPU

unpacklo := (l1,l2,n,k) -> Flat(List([1..n/(2*k)], i-> [
        List([1..k], j->l1[(i-1)*k+j]),
        List([1..k], j->l2[(i-1)*k+j])
]));

unpackhi := (l1,l2,n,k) -> Flat(List([1..n/(2*k)], i -> [
        List([1..k], j->l1[n/2+(i-1)*k+j]),
        List([1..k], j->l2[n/2+(i-1)*k+j])
]));

sparams := (l,n) -> List([1..l], i->[1..n]);

shuffle := (in1, in2, p, n, k) -> Flat([
    List([1..n/(2*k)],     i->List([1..k], j->in1[(p[i]-1)*k+j])),
    List([n/(2*k)+1..n/k], i->List([1..k], j->in2[(p[i]-1)*k+j]))
]);

iperm4 := self >> Filtered(Cartesian(self.params()), i->i[1]<>i[2] and i[3] <> i[4]);

# Generic instructions
#
Class(vop_new_mixin, rec(
    params := self >> [],
    permparams := self >> Cartesian(self.params()),
    isBinop := self >> self.numargs = 2,
    isUnop := self >> self.numargs = 1,
    isLoadop := False,
    isStoreop := False,
));

Class(vop_new, vop_new_mixin, Exp, rec(
    __call__ := arg >> let(self:=arg[1],
    _computeExpType(WithBases(self, rec(
        p          := When(Length(arg) >= self.numargs+2, arg[self.numargs+2], []),
        args       := Concat(List(Sublist(arg, [2..self.numargs+1]), toExpArg),
                        When(Length(arg) >= self.numargs+2 and arg[self.numargs+2] <> [],
                        [vparam(arg[self.numargs+2])], [])),
        operations := ExpOps
    )))
    ),
));

Class(vbinop_new, vop_new, rec(numargs:=2));
Class(vunop_new, vop_new, rec(numargs:=1));

Class(vunbinop_new, vop_new, rec(
    numargs := 1,
    params := self >> self.binop.params(),
    v := self >> self.binop.v,
    semantic := (self, in1, p) >> self.binop.semantic(in1, in1, p)
));

Class(vloadop_new, vop_new, rec(
    numargs := 0,
    isLoadop := True,
    # in case of explicit type cast (YSV modification), we don't need getNoScalar,
    # and below returns [], compiler understands not to mess with typecasts
    getNoScalar := self >> When(IsBound(self.noscalar) and IsBound(self.args[self.noScalar].loc),
	self.args[self.noScalar].loc, [])
));

Class(vstoreop_new, assign, vop_new_mixin, rec(
    isStoreop := True,
    # in case of explicit type cast (YSV modification), we don't need getNoScalar,
    # and below returns [], compiler understands not to mess with typecasts
    getNoScalar := self >> let(s := self.loc,
    When(IsBound(s.loc), s.loc, []))
));

Class(vstoremsk, assign, vop_new_mixin, rec(
    isStoreop := True,
   __call__ := (self, loc, exp, p) >> WithBases(self,
       rec(operations := CmdOps,
       loc := toAssignTarget(loc),
       exp := toExpArg(exp),
       p := p)),

    print := (self,i,is) >> Print(Blanks(i), self.name, "(",
    self.loc.print(), ", ", self.exp.print(), ", ", self.p, ");\n"),

    # in case of explicit type cast (YSV modification), we don't need getNoScalar,
    # and below returns [], compiler understands not to mess with typecasts
    getNoScalar := self >> When(IsBound(self.noscalar) and IsBound(self.args[self.noScalar].loc),
	self.args[self.noScalar].loc, [])
));