tester.c

changeset 0
86b7f6f9c5c0
child 5
f878a9ffa3e0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tester.c	Tue Feb 15 18:57:52 2005 +0100
@@ -0,0 +1,51 @@
+/*
+ * libtu/tester.c
+ *
+ * Copyright (c) Tuomo Valkonen 1999-2000.
+ * 
+ * This file is distributed under the terms of the "Artistic License".
+ * See the included file LICENSE for details.
+ */
+
+#include <stdio.h>
+#include "include/misc.h"
+#include "include/tokenizer.h"
+
+
+int main(void)
+{
+	Tokenizer*tokz;
+	Token tok=TOK_INIT;
+	
+	if(!(tokz=tokz_open_file(stdin)))
+		return EXIT_FAILURE;
+
+	while(tokz_get_token(tokz, &tok)){
+		switch(tok.type){
+		case TOK_LONG:
+			printf("long - %ld\n", TOK_LONG_VAL(&tok));
+			break;
+		case TOK_DOUBLE:
+			printf("double - %g\n", TOK_DOUBLE_VAL(&tok));
+			break;
+		case TOK_CHAR:
+			printf("char - '%c'\n", TOK_CHAR_VAL(&tok));
+			break;
+		case TOK_STRING:
+			printf("string - \"%s\"\n", TOK_STRING_VAL(&tok));
+			break;
+		case TOK_IDENT:
+			printf("ident - %s\n", TOK_IDENT_VAL(&tok));
+			break;
+		case TOK_COMMENT:
+			printf("comment - %s\n", TOK_COMMENT_VAL(&tok));
+			break;
+		case TOK_OP:
+			printf("operator - %03x\n", TOK_OP_VAL(&tok));
+			break;
+		}
+	}
+	   
+	return EXIT_SUCCESS;
+}
+

mercurial