summaryrefslogtreecommitdiff
path: root/src/lmparse.kh
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2013-06-08 09:38:26 -0400
committerAdrian Thurston <thurston@complang.org>2013-06-08 09:38:26 -0400
commitcf47ae207efbf6727cc883c2a8309ff061060f3e (patch)
tree29e5209e9280b4d05c65b74a5ad94d413ea47cca /src/lmparse.kh
parent7002bb72bda6c59e247df51bcf93d39bc40ecb30 (diff)
downloadcolm-cf47ae207efbf6727cc883c2a8309ff061060f3e.tar.gz
renamed colm dir to src
Renamed 'colm' dir to 'src'. To allow colm to work out of the installed location or the source tree, while the installed includes reference <colm/include.h>, a symlink to '..' is placed at src/include/colm.
Diffstat (limited to 'src/lmparse.kh')
-rw-r--r--src/lmparse.kh85
1 files changed, 85 insertions, 0 deletions
diff --git a/src/lmparse.kh b/src/lmparse.kh
new file mode 100644
index 00000000..416ba41f
--- /dev/null
+++ b/src/lmparse.kh
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2001-2007, 2013 Adrian Thurston <thurston@complang.org>
+ */
+
+/* This file is part of Colm.
+ *
+ * Colm 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.
+ *
+ * Colm 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 Colm; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef LMPARSE_H
+#define LMPARSE_H
+
+#include <iostream>
+#include "avltree.h"
+#include "parsedata.h"
+#include "parser.h"
+
+struct ColmParser
+:
+ public BaseParser
+{
+ ColmParser( Compiler *pd )
+ : BaseParser( pd )
+ {}
+
+ %%{
+ parser ColmParser;
+
+ # Use a class for tokens.
+ token uses class Token;
+
+ # Atoms.
+ token TK_Word, TK_Literal, TK_SingleLit, TK_DoubleLit, TK_Number, TK_UInt,
+ TK_Hex, KW_Nil, KW_True, KW_False;
+
+ # General tokens.
+ token TK_DotDot, TK_ColonGt, TK_ColonGtGt, TK_LtColon,
+ TK_DoubleArrow, TK_StarStar, TK_NameSep, TK_DashDash, TK_DoubleEql,
+ TK_NotEql, TK_DoubleColon, TK_LessEql, TK_GrtrEql, TK_RightArrow,
+ TK_LitPat, TK_AmpAmp, TK_BarBar, TK_SqOpen, TK_SqOpenNeg, TK_SqClose,
+ TK_Dash, TK_ReChar, TK_LtLt;
+
+ # Defining things.
+ token KW_Rl, KW_Def, KW_Lex, KW_Context, KW_Ignore, KW_Token, KW_Commit, KW_Namespace, KW_End,
+ KW_Literal, KW_ReduceFirst, KW_Map, KW_List, KW_Vector, KW_Parser, KW_Global, KW_Export,
+ KW_Iter, KW_Reject, KW_Ptr, KW_Ref, KW_Deref;
+
+ # Language.
+ token KW_If, KW_While, KW_Else, KW_Elsif, KW_For, KW_Return, KW_Yield, KW_In,
+ KW_Break, KW_PrintXMLAC, KW_PrintXML, KW_Print, KW_PrintStream, KW_Require;
+
+ # Patterns.
+ token KW_Match, KW_Construct, KW_Parse, KW_ParseStop, KW_New, KW_MakeToken,
+ KW_MakeTree, KW_TypeId, KW_Alias, KW_Send, KW_Ni;
+
+ token KW_Include, KW_Preeof;
+
+ token KW_Left, KW_Right, KW_Nonassoc, KW_Prec;
+
+ }%%
+
+ %% write instance_data;
+
+ /* Report an error encountered by the parser. */
+ ostream &parse_error( int tokId, Token &token );
+ void init();
+ int parseLangEl( int type, const Token *token );
+ int token( InputLoc &loc, int tokId, char *tokstart, int toklen );
+};
+
+%% write token_defs;
+
+#endif