1#!/bin/sh
2
3INFILE="../../Zend/zend_language_parser.h"
4OUTFILE="tokenizer_data.c"
5AWK=awk
6
7####################################################################
8
9if test ! -f "./tokenizer.c"; then
10    echo "Please run this script from within php-src/ext/tokenizer"
11    exit 0
12fi
13
14
15echo '/*
16   +----------------------------------------------------------------------+
17   | PHP Version 5                                                        |
18   +----------------------------------------------------------------------+
19   | Copyright (c) 1997-2014 The PHP Group                                |
20   +----------------------------------------------------------------------+
21   | This source file is subject to version 3.01 of the PHP license,      |
22   | that is bundled with this package in the file LICENSE, and is        |
23   | available through the world-wide-web at the following url:           |
24   | http://www.php.net/license/3_01.txt                                  |
25   | If you did not receive a copy of the PHP license and are unable to   |
26   | obtain it through the world-wide-web, please send a note to          |
27   | license@php.net so we can mail you a copy immediately.               |
28   +----------------------------------------------------------------------+
29   | Author: Johannes Schlueter <johannes@php.net>                        |
30   +----------------------------------------------------------------------+
31*/
32
33/* $Id$ */
34
35/*
36   DO NOT EDIT THIS FILE!
37   This file is generated using tokenizer_data_gen.sh
38*/
39
40#include "php.h"
41#include "zend.h"
42#include <zend_language_parser.h>
43
44' > $OUTFILE
45
46
47echo 'void tokenizer_register_constants(INIT_FUNC_ARGS) {' >> $OUTFILE
48$AWK '/^#define T_/  { print "	REGISTER_LONG_CONSTANT(\"" $2 "\", " $2 ", CONST_CS | CONST_PERSISTENT);" }' < $INFILE >> $OUTFILE
49echo '	REGISTER_LONG_CONSTANT("T_DOUBLE_COLON", T_PAAMAYIM_NEKUDOTAYIM, CONST_CS | CONST_PERSISTENT);' >> $OUTFILE
50echo '}' >> $OUTFILE
51
52
53echo '
54char *get_token_type_name(int token_type)
55{
56	switch (token_type) {
57' >> $OUTFILE
58
59$AWK '
60	/^#define T_PAAMAYIM_NEKUDOTAYIM/ {
61		print "		case T_PAAMAYIM_NEKUDOTAYIM: return \"T_DOUBLE_COLON\";"
62		next
63	}
64	/^#define T_/ {
65		print "		case " $2 ": return \"" $2 "\";"
66	}
67' < $INFILE >> $OUTFILE
68
69echo '
70	}
71	return "UNKNOWN";
72}
73' >> $OUTFILE
74
75echo "Wrote $OUTFILE"
76