Changeset 2307


Ignore:
Timestamp:
Feb 10, 2010 12:02:40 AM (9 years ago)
Author:
wehart
Message:

Adding a test that is used to verify that data commands can include indexed variables with astrices
in their arguments.

Location:
coopr.pyomo/trunk/coopr/pyomo
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • coopr.pyomo/trunk/coopr/pyomo/data/parse_datacmds.py

    r2293 r2307  
    5858    "EQ",
    5959    "TR",
     60    "ASTERISK",
    6061    "NONWORD",
    6162] + reserved.values()
     
    7778t_LPAREN    = r"\("
    7879t_RPAREN    = r"\)"
     80t_ASTERISK  = r"\*"
    7981
    8082# Discard comments
     
    104106    return t
    105107
    106 t_NONWORD   = r"[^\.A-Za-z0-9,;:=<>\(\)\#{}\[\] \n\t\r]+"
     108t_NONWORD   = r"[^\.A-Za-z0-9,;:=<>\*\(\)\#{}\[\] \n\t\r]+"
    107109
    108110# Error handling rule
     
    242244def p_index_list(p):
    243245    '''index_list : COMMA WORD index_list
     246                  | COMMA ASTERISK index_list
    244247                  | COMMA WORD
     248                  | COMMA ASTERISK
    245249    '''
    246250    if len(p) == 4:
     
    251255def p_indexed_word(p):
    252256    '''indexed_word : WORD LBRACKET WORD index_list RBRACKET
     257                    | WORD LBRACKET ASTERISK index_list RBRACKET
    253258                    | WORD LBRACKET WORD RBRACKET
     259                    | WORD LBRACKET ASTERISK RBRACKET
    254260    '''
    255261    if len(p) == 6:
     
    257263    else:
    258264        p[0] = p[1]+p[2]+p[3]+p[4]
     265
     266def p_template(p):
     267    '''template : LPAREN WORD index_list RPAREN
     268                | LPAREN ASTERISK index_list RPAREN
     269                | LPAREN WORD RPAREN
     270                | LPAREN ASTERISK RPAREN
     271    '''
     272    if len(p) == 5:
     273        p[0] = p[1]+",".join([p[2]]+p[3])+p[4]
     274    else:
     275        p[0] = p[1]+p[2]+p[3]
    259276
    260277def p_items(p):
     
    278295            | LPAREN
    279296            | RPAREN
     297            | indexed_word
     298            | template
    280299    '''
    281300    p[0] = p[1]
  • coopr.pyomo/trunk/coopr/pyomo/tests/unit/data8.dat

    r1448 r2307  
    11param A := False;
    22param B := True;
     3set Z := foo[*] bar[1,*,a,*] ;
  • coopr.pyomo/trunk/coopr/pyomo/tests/unit/test_modeldata.py

    r2306 r2307  
    214214        try:
    215215            md.read(model)
    216         except ValueError:
     216        except (ValueError,IOError):
    217217            pass
    218218
     
    262262        model.A=Param(within=Boolean)
    263263        model.B=Param(within=Boolean)
     264        model.Z=Set()
    264265        md.read(model)
    265266
Note: See TracChangeset for help on using the changeset viewer.