1 // Copyright (c) 1996 James Clark
2 // See the file copying.txt for copying permission.
4 #ifndef SchemeParser_INCLUDED
5 #define SchemeParser_INCLUDED 1
7 #include "Interpreter.h"
8 #include "Expression.h"
11 #ifdef DSSSL_NAMESPACE
12 namespace DSSSL_NAMESPACE {
17 class SchemeParser : public Messenger {
19 SchemeParser(Interpreter &, Owner<InputSource> &);
21 void parseStandardChars();
22 void parseMapSdataEntity(const StringC &name, const StringC &text);
23 void parseNameChars();
24 void parseSeparatorChars();
25 bool parseExpression(Owner<Expression> &);
27 SchemeParser(const SchemeParser &); // undefined
28 void operator=(const SchemeParser &); // undefined
31 allowEndOfEntity = 01,
35 allowCloseParen = 020,
36 allowIdentifier = 040,
38 allowOtherExpr = 0200, // number, character, glyph-id, quote, backquote
39 allowExpressionKey = 0400,
40 allowKeyDefine = 01000,
42 allowKeyArrow = 04000, // =>
44 allowHashOptional = 020000,
45 allowHashKey = 040000,
46 allowHashRest = 0100000,
47 allowUnquote = 0200000,
48 allowUnquoteSplicing = 0400000,
49 allowQuasiquoteKey = 01000000,
50 allowVector = 02000000,
51 allowHashContents = 04000000,
52 allowExpr = (allowFalse|allowKeyword|allowOpenParen|allowIdentifier
53 |allowString|allowHashOptional|allowHashKey|allowHashRest
88 bool doDeclareInitialValue();
89 bool doDeclareCharacteristic();
90 bool doDeclareCharCharacteristicAndProperty();
91 bool doDeclareFlowObjectClass();
92 bool doDeclareClassAttribute();
93 bool doDeclareIdAttribute();
94 bool doDeclareFlowObjectMacro();
95 bool doDeclareDefaultLanguage();
96 bool doDefineLanguage();
98 bool doMultiCollatingElement();
99 bool doCollatingSymbol();
100 bool doCollatingOrder();
104 bool doDeclareCharProperty();
105 bool doAddCharProperties();
107 bool parseSpecialQuery(Owner<Expression> &expr, const char *query);
108 bool parseExpression(unsigned allowed, Owner<Expression> &,
109 Identifier::SyntacticKey &, Token &);
110 bool parseBegin(Owner<Expression> &expr);
111 bool parseSet(Owner<Expression> &expr);
112 bool parseLambda(Owner<Expression> &);
113 bool parseLet(Owner<Expression> &);
114 bool parseLetStar(Owner<Expression> &);
115 bool parseLetrec(Owner<Expression> &);
116 bool parseBindingsAndBody(Vector<const Identifier *> &vars,
117 NCVector<Owner<Expression> > &inits,
118 Owner<Expression> &body);
119 bool parseBindingsAndBody1(Vector<const Identifier *> &vars,
120 NCVector<Owner<Expression> > &inits,
121 Owner<Expression> &body);
122 bool parseQuote(Owner<Expression> &);
123 bool parseIf(Owner<Expression> &);
124 bool parseCond(Owner<Expression> &, bool opt = 0);
125 bool parseCase(Owner<Expression> &);
126 bool parseOr(Owner<Expression> &);
127 bool parseAnd(Owner<Expression> &, bool opt = 0);
128 bool parseMake(Owner<Expression> &);
129 bool parseStyle(Owner<Expression> &);
130 bool parseWithMode(Owner<Expression> &);
131 bool parseFormals(Vector<const Identifier *> &,
132 NCVector<Owner<Expression> > &,
133 int &, bool &, int &);
134 bool parseDatum(unsigned otherAllowed, ELObj *&, Location &, Token &);
135 bool parseSelfEvaluating(unsigned otherAllowed, ELObj *&, Token &);
136 bool parseAbbreviation(const char *, ELObj *&);
137 bool parseQuasiquote(Owner<Expression> &);
138 bool parseQuasiquoteTemplate(unsigned level,
141 Identifier::SyntacticKey &,
144 void createQuasiquoteAbbreviation(const char *, Owner<Expression> &);
145 bool parseRuleBody(Owner<Expression> &, ProcessingMode::RuleType &);
146 bool getToken(unsigned, Token &);
147 bool handleNumber(unsigned, Token &);
148 bool handleIdentifier(unsigned, Token &);
152 bool tokenRecover(unsigned, Token &);
153 bool scanString(unsigned, Token &);
154 ELObj *convertAfiiGlyphId(const StringC &);
155 Identifier *lookup(const StringC &str);
156 ProcessingMode *lookupProcessingMode(const StringC &);
157 void dispatchMessage(Message &);
158 void dispatchMessage(const Message &);
159 void initMessage(Message &msg);
162 Interpreter *interp_;
163 Owner<InputSource> in_;
164 StringC currentToken_;
165 ProcessingMode *defMode_;
166 const char *afiiPublicId_;
172 Identifier *SchemeParser::lookup(const StringC &str)
174 return interp_->lookup(str);
178 ProcessingMode *SchemeParser::lookupProcessingMode(const StringC &name)
180 return interp_->lookupProcessingMode(name);
184 bool SchemeParser::dsssl2() const
189 #ifdef DSSSL_NAMESPACE
193 #endif /* not SchemeParser_INCLUDED */