Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

/magnus/back_end/Group/include/PresentationParser.h

Go to the documentation of this file.
00001 /*
00002  *   $Id: PresentationParser.h,v 1.4 2000/03/03 02:44:16 bormotov Exp $
00003  */
00004 
00005 // Copyright (C) 1994 The New York Group Theory Cooperative
00006 // See magnus/doc/COPYRIGHT for the full notice.
00007 
00008 // Contents: Definition of parser for presentations.
00009 //
00010 // Principal Author: Roger Needham
00011 //
00012 // Status: useable
00013 //
00014 // Revision History:
00015 //
00016 
00017 #ifndef _PRESENTATION_PARSER_H_
00018 #define _PRESENTATION_PARSER_H_
00019 
00020 #include "Set.h"
00021 #include "WordParser.h"
00022 #include "FreeGroup.h"
00023 #include "FPGroup.h"
00024 
00025 
00026 // The grammar for Word and FPGroup:
00027 //
00028 // Literals are delimited by ''.
00029 // The symbols ., *, +, -, |, ?, [, ], (, and ) are part of regular expressions
00030 // unless quoted.
00031 //
00032 // <whitespace>     ::= ' ' | '\t' | '\n' | '#'.*'\n'
00033 // <index>          ::= 0 | [1-9]+[0-9]*
00034 // <integer>        ::= <index> | -<index>
00035 // <generator>      ::= [a-zA-Z]+<index>?
00036 // <atom>           ::= '1' | <generator> | '('<word>')' |
00037 //                      '['<word>','<word>(','<word>)*']'
00038 // <term>           ::= <atom>('^'<atom>)* | <term>'^'<integer>
00039 // <word>           ::= <term>('*'<term>)* | <term>(<whitespace><term>)*
00040 // <relator>        ::= <word>('='<word>)?
00041 // <generator list> ::= (<generator>(','<generator>)*)?
00042 // <word list>      ::= <word>(','<word list>)?
00043 // <relator list>   ::= <word>('='<word>)* |
00044 //                      (<word>('='<word>)*(','<word>('='<word>)*)?)?
00045 // <FPGroup>        ::= '<'<generator list>('|' | ';' | ':')<relator list>'>' |
00046 //                      '<'<generator list>'>'
00047 //
00048 // - whitespace may occur anywhere except within lexemes.
00049 // 
00050 // Semantic conventions:
00051 //
00052 // - x^y is y^-1 x y.
00053 // - ^ is left-associative, so a^t^2 is (a^t)^2.
00054 // - [x,y] is x^-1 y^-1 x y.
00055 // - [x1, x2, ..., xn] is left-normed: [[x1,x2], x3, ..., xn].
00056 // - Given the print name of a generator, the print name of its inverse
00057 //   has each character changed to the opposite case.
00058 //   Thus aB2^-1 is the same as Ab2.
00059 
00060 
00061 class PresentationParser : public WordParser {
00062 
00063 public:
00064 
00065   enum BraceType { SET, PAREN };
00066 
00067 public:
00068 
00069   PresentationParser(istream &istr) : WordParser(istr) { }
00070   // Initialize the parser with the istream from which to read.
00071 
00072   // Destructor supplied by compiler.
00073 
00074   VectorOf<Chars> parseGeneratorList( Chars& );
00075   // Read a generator list.
00076 
00077   SetOf<Word> parseWordSet( const VectorOf<Chars>&, Chars& );
00078   // Read a list of words in the given generator names.
00079   // The list is terminated when a word is followed by any non-whitespace
00080   // char other than ','.
00081 
00082   VectorOf<Word> parseWordList( const VectorOf<Chars>&, Chars& );
00083   // Read a list of words in the given generator names.
00084   // The list is terminated when a word is followed by any non-whitespace
00085   // char other than ','.
00086 
00087   SetOf<Word> parseSetOfWords( const VectorOf<Chars>&, Chars& );
00088   // Read a list of words in the given generator names delimited by '{', '}'.
00089 
00090   VectorOf<Word> parseVectorOfWords( const VectorOf<Chars>&, Chars&, 
00091                                      BraceType brace = SET );
00092   // Read a list of words in the given generator names delimited by '{', '}'
00093   // or '(', ')'.
00094 
00095   virtual Word parseRelator( const VectorOf<Chars>&, Chars& );
00096   // Read a relator in the given generator names.
00097 
00098   SetOf<Word> parseRelatorList( const VectorOf<Chars>&, Chars& );
00099   // Read a list of words and relations in the given generator names.
00100   // The list is terminated when anything (non-whitespace) other than
00101   // a relator or ',' is encountered.
00102 
00103   FreeGroupRep* parseFreeGroup( Chars& );
00104 
00105   FPGroupRep* parseFPGroup( Chars& );
00106   // Read a group presentation and return it as a new group rep object.
00107 private:
00108   bool getGeneratorRange( const Chars& , VectorOf<Chars>&, Chars& );
00109   bool getRangeOf( const Chars& ,Chars&, int& );
00110 };
00111 
00112 #endif

Generated at Tue Jun 19 09:49:36 2001 for Magnus Classes by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001