X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fparser%2Flexer.cpp;h=437db17542ca6175e5c68ca42780f4bfe6e453b6;hp=7c3e6c84aecf5ac6d62db29452de77f981791a95;hb=866b3eb23253a272788d8791b1ed023e63674d50;hpb=3324b2f0f035490940b1a9d7cf5dc210776f6d87 diff --git a/ginac/parser/lexer.cpp b/ginac/parser/lexer.cpp index 7c3e6c84..437db175 100644 --- a/ginac/parser/lexer.cpp +++ b/ginac/parser/lexer.cpp @@ -1,11 +1,35 @@ -#include +/** @file lexer.cpp + * + * Implementation of GiNaC's lexer. */ + +/* + * GiNaC Copyright (C) 1999-2010 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "lexer.h" +#include "compiler.h" + #include #include -#include "lexer.hpp" -#include "compiler.h" +#include +#include + +namespace GiNaC { -namespace GiNaC -{ /// Skip to the end of line static int skipline(std::istream* s); /// Skip to the next non-whitespace character @@ -19,12 +43,12 @@ int lexer::gettok() // Skip any whitespace. c = skipspace(input, c, line_num); - // identifier: [a-zA-Z][a-zA-Z0-9]* + // identifier: [a-zA-Z][a-zA-Z0-9_]* if (isalpha(c)) { str = c; do { c = input->get(); - if (isalnum(c)) + if ( isalnum(c) || c=='_' ) str += c; else break; @@ -154,4 +178,3 @@ std::string lexer::tok2str(const int tok) const } } // namespace GiNaC -