X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?a=blobdiff_plain;f=ginac%2Fparser%2Fparser.cpp;h=009813de431113c46772487f7b6748b00b9c3652;hb=e5eeee53d814cedc12cd725e76b0eb87859cdd77;hp=2e2c9e6c1ed1a33346713f0ab0b5b69cc645972a;hpb=e710763e51b6fe11020bac880c44f426544471c2;p=ginac.git diff --git a/ginac/parser/parser.cpp b/ginac/parser/parser.cpp index 2e2c9e6c..009813de 100644 --- a/ginac/parser/parser.cpp +++ b/ginac/parser/parser.cpp @@ -3,7 +3,7 @@ * Implementation of GiNaC's parser. */ /* - * GiNaC Copyright (C) 1999-2009 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2011 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,6 +21,7 @@ */ #include "parser.h" +#include "lst.h" #include "lexer.h" #include "debug.h" #include "mul.h" @@ -120,8 +121,35 @@ ex parser::parse_paren_expr() return e; } -extern numeric* _num_1_p; -extern ex _ex0; +/// lst_expr: '{' expression { ',' expression } '}' +ex parser::parse_lst_expr() +{ + get_next_tok(); // eat {. + + lst list; + if (token != '}') { + while (true) { + ex e = parse_expression(); // expression(); + list.append(e); + + if (token == '}') { + break; + } + + if (token != ',') { + Parse_error("expected '}'"); + } + + get_next_tok(); // eat ','. + } + } + // Eat the '}'. + get_next_tok(); + + return list; +} + +extern const ex _ex0; /// unary_expr: [+-] expression ex parser::parse_unary_expr() @@ -152,6 +180,8 @@ ex parser::parse_primary() return parse_number_expr(); case '(': return parse_paren_expr(); + case '{': + return parse_lst_expr(); case '-': case '+': return parse_unary_expr();