#!/bin/csh
#
# Simple script to scan keywords.c and extract all the TK_ keywords
#	and built up a numeric mapping for them, desigend for
#	inclusion into the keywords.h file.
#
# 	Copyright (c) 2012 Gordon Henderson
#################################################################################
#  This file is part of RTB:
# 	Return To Basic
# 	http://projects.drogon.net/return-to-basic
# 
#     RTB 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 3 of the License, or
#     (at your option) any later version.
# 
#     RTB 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 RTB.  If not, see <http://www.gnu.org/licenses/>.
#################################################################################

@ n = 0

foreach token (`fgrep TK_ keywords.c | awk '{print $3}' | sed 's/,//' | uniq`)
  echo    "#define $token	$n"
  if ( $token == "TK_LAST_TOKEN" ) then
    break
  endif
  @ n += 1
end
