mirror of https://github.com/Cisco-Talos/clamav
parent
b0c7e984a8
commit
fd08e02ea3
@ -0,0 +1,31 @@ |
||||
abstract |
||||
boolean |
||||
byte |
||||
char |
||||
class |
||||
const |
||||
debugger |
||||
double |
||||
enum |
||||
export |
||||
extends |
||||
final |
||||
float |
||||
goto |
||||
implements |
||||
import |
||||
int |
||||
interface |
||||
long |
||||
native |
||||
package |
||||
private |
||||
protected |
||||
public |
||||
short |
||||
static |
||||
super |
||||
synchronized |
||||
throws |
||||
transient |
||||
volatile |
||||
@ -0,0 +1,194 @@ |
||||
/* ANSI-C code produced by gperf version 3.0.3 */ |
||||
/* Command-line: gperf -E -t -L ANSI-C -C -F ', TOK_ERROR' -c jsparse-keywords.gperf */ |
||||
/* Computed positions: -k'1-2' */ |
||||
|
||||
#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ |
||||
&& ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
|
||||
&& (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
|
||||
&& ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
|
||||
&& ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
|
||||
&& ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
|
||||
&& ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
|
||||
&& ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
|
||||
&& ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
|
||||
&& ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
|
||||
&& ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
|
||||
&& ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
|
||||
&& ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
|
||||
&& ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
|
||||
&& ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
|
||||
&& ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
|
||||
&& ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
|
||||
&& ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
|
||||
&& ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
|
||||
&& ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
|
||||
&& ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
|
||||
&& ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
|
||||
&& ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)) |
||||
/* The character set is not based on ISO-646. */ |
||||
#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>." |
||||
#endif |
||||
|
||||
struct keyword { const char *name; int val; }; |
||||
/* maximum key range = 100, duplicates = 0 */ |
||||
|
||||
#ifdef __GNUC__ |
||||
__inline |
||||
#else |
||||
#ifdef __cplusplus |
||||
inline |
||||
#endif |
||||
#endif |
||||
static unsigned int |
||||
hash (const char *str, unsigned int len) |
||||
{ |
||||
static const unsigned char asso_values[] = |
||||
{ |
||||
103, 103, 103, 103, 103, 103, 103, 103, 103, 103, |
||||
103, 103, 103, 103, 103, 103, 103, 103, 103, 103, |
||||
103, 103, 103, 103, 103, 103, 103, 103, 103, 103, |
||||
103, 103, 103, 103, 103, 103, 103, 103, 103, 103, |
||||
103, 103, 103, 103, 103, 103, 103, 103, 103, 103, |
||||
103, 103, 103, 103, 103, 103, 103, 103, 103, 103, |
||||
103, 103, 103, 103, 103, 103, 103, 103, 103, 103, |
||||
103, 103, 103, 103, 103, 103, 103, 103, 103, 103, |
||||
103, 103, 103, 103, 103, 103, 103, 103, 103, 103, |
||||
103, 103, 103, 103, 103, 103, 103, 30, 5, 0, |
||||
5, 0, 10, 50, 35, 5, 103, 103, 25, 55, |
||||
0, 20, 35, 103, 0, 40, 15, 5, 45, 55, |
||||
45, 50, 103, 103, 103, 103, 103, 103, 103, 103, |
||||
103, 103, 103, 103, 103, 103, 103, 103, 103, 103, |
||||
103, 103, 103, 103, 103, 103, 103, 103, 103, 103, |
||||
103, 103, 103, 103, 103, 103, 103, 103, 103, 103, |
||||
103, 103, 103, 103, 103, 103, 103, 103, 103, 103, |
||||
103, 103, 103, 103, 103, 103, 103, 103, 103, 103, |
||||
103, 103, 103, 103, 103, 103, 103, 103, 103, 103, |
||||
103, 103, 103, 103, 103, 103, 103, 103, 103, 103, |
||||
103, 103, 103, 103, 103, 103, 103, 103, 103, 103, |
||||
103, 103, 103, 103, 103, 103, 103, 103, 103, 103, |
||||
103, 103, 103, 103, 103, 103, 103, 103, 103, 103, |
||||
103, 103, 103, 103, 103, 103, 103, 103, 103, 103, |
||||
103, 103, 103, 103, 103, 103, 103, 103, 103, 103, |
||||
103, 103, 103, 103, 103, 103 |
||||
}; |
||||
return len + asso_values[(unsigned char)str[1]] + asso_values[(unsigned char)str[0]]; |
||||
} |
||||
|
||||
#ifdef __GNUC__ |
||||
__inline |
||||
#ifdef __GNUC_STDC_INLINE__ |
||||
__attribute__ ((__gnu_inline__)) |
||||
#endif |
||||
#endif |
||||
static const struct keyword * |
||||
in_word_set (const char *str, unsigned int len) |
||||
{ |
||||
enum |
||||
{ |
||||
TOTAL_KEYWORDS = 59, |
||||
MIN_WORD_LENGTH = 2, |
||||
MAX_WORD_LENGTH = 12, |
||||
MIN_HASH_VALUE = 3, |
||||
MAX_HASH_VALUE = 102 |
||||
}; |
||||
|
||||
static const struct keyword wordlist[] = |
||||
{ |
||||
{"", TOK_ERROR}, {"", TOK_ERROR}, {"", TOK_ERROR}, |
||||
{"new", TOK_NEW}, |
||||
{"enum", TOK_FUTURE_RESERVED_WORD}, |
||||
{"", TOK_ERROR}, |
||||
{"return", TOK_RETURN}, |
||||
{"in", TOK_IN}, |
||||
{"int", TOK_FUTURE_RESERVED_WORD}, |
||||
{"null", TOK_NULL}, |
||||
{"break", TOK_BREAK}, |
||||
{"delete", TOK_DELETE}, |
||||
{"default", TOK_DEFAULT}, |
||||
{"debugger", TOK_FUTURE_RESERVED_WORD}, |
||||
{"interface", TOK_FUTURE_RESERVED_WORD}, |
||||
{"instanceof", TOK_INSTANCEOF}, |
||||
{"", TOK_ERROR}, |
||||
{"if", TOK_IF}, |
||||
{"try", TOK_TRY}, |
||||
{"true", TOK_TRUE}, |
||||
{"final", TOK_FUTURE_RESERVED_WORD}, |
||||
{"", TOK_ERROR}, |
||||
{"finally", TOK_FINALLY}, |
||||
{"function", TOK_FUNCTION}, |
||||
{"transient", TOK_FUTURE_RESERVED_WORD}, |
||||
{"const", TOK_FUTURE_RESERVED_WORD}, |
||||
{"", TOK_ERROR}, |
||||
{"do", TOK_DO}, |
||||
{"continue", TOK_CONTINUE}, |
||||
{"else", TOK_ELSE}, |
||||
{"class", TOK_FUTURE_RESERVED_WORD}, |
||||
{"double", TOK_FUTURE_RESERVED_WORD}, |
||||
{"boolean", TOK_FUTURE_RESERVED_WORD}, |
||||
{"for", TOK_FOR}, |
||||
{"case", TOK_CASE}, |
||||
{"catch", TOK_CATCH}, |
||||
{"native", TOK_FUTURE_RESERVED_WORD}, |
||||
{"", TOK_ERROR}, {"", TOK_ERROR}, |
||||
{"char", TOK_FUTURE_RESERVED_WORD}, |
||||
{"float", TOK_FUTURE_RESERVED_WORD}, |
||||
{"", TOK_ERROR}, |
||||
{"private", TOK_FUTURE_RESERVED_WORD}, |
||||
{"abstract", TOK_FUTURE_RESERVED_WORD}, |
||||
{"protected", TOK_FUTURE_RESERVED_WORD}, |
||||
{"false", TOK_FALSE}, |
||||
{"public", TOK_FUTURE_RESERVED_WORD}, |
||||
{"", TOK_ERROR}, {"", TOK_ERROR}, |
||||
{"long", TOK_FUTURE_RESERVED_WORD}, |
||||
{"super", TOK_FUTURE_RESERVED_WORD}, |
||||
{"export", TOK_FUTURE_RESERVED_WORD}, |
||||
{"extends", TOK_FUTURE_RESERVED_WORD}, |
||||
{"", TOK_ERROR}, |
||||
{"this", TOK_THIS}, |
||||
{"throw", TOK_THROW}, |
||||
{"throws", TOK_FUTURE_RESERVED_WORD}, |
||||
{"", TOK_ERROR}, {"", TOK_ERROR}, |
||||
{"byte", TOK_FUTURE_RESERVED_WORD}, |
||||
{"", TOK_ERROR}, |
||||
{"static", TOK_FUTURE_RESERVED_WORD}, |
||||
{"", TOK_ERROR}, {"", TOK_ERROR}, |
||||
{"with", TOK_WITH}, |
||||
{"", TOK_ERROR}, |
||||
{"import", TOK_FUTURE_RESERVED_WORD}, |
||||
{"", TOK_ERROR}, {"", TOK_ERROR}, |
||||
{"void", TOK_VOID}, |
||||
{"implements", TOK_FUTURE_RESERVED_WORD}, |
||||
{"typeof", TOK_TYPEOF}, |
||||
{"package", TOK_FUTURE_RESERVED_WORD}, |
||||
{"volatile", TOK_FUTURE_RESERVED_WORD}, |
||||
{"goto", TOK_FUTURE_RESERVED_WORD}, |
||||
{"", TOK_ERROR}, {"", TOK_ERROR}, {"", TOK_ERROR}, |
||||
{"var", TOK_VAR}, |
||||
{"", TOK_ERROR}, |
||||
{"short", TOK_FUTURE_RESERVED_WORD}, |
||||
{"", TOK_ERROR}, {"", TOK_ERROR}, {"", TOK_ERROR}, |
||||
{"", TOK_ERROR}, {"", TOK_ERROR}, {"", TOK_ERROR}, |
||||
{"", TOK_ERROR}, {"", TOK_ERROR}, {"", TOK_ERROR}, |
||||
{"", TOK_ERROR}, {"", TOK_ERROR}, {"", TOK_ERROR}, |
||||
{"", TOK_ERROR}, {"", TOK_ERROR}, |
||||
{"while", TOK_WHILE}, |
||||
{"", TOK_ERROR}, {"", TOK_ERROR}, {"", TOK_ERROR}, |
||||
{"", TOK_ERROR}, {"", TOK_ERROR}, |
||||
{"switch", TOK_SWITCH}, |
||||
{"synchronized", TOK_FUTURE_RESERVED_WORD} |
||||
}; |
||||
|
||||
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) |
||||
{ |
||||
int key = hash (str, len); |
||||
|
||||
if (key <= MAX_HASH_VALUE && key >= 0) |
||||
{ |
||||
const char *s = wordlist[key].name; |
||||
|
||||
if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0') |
||||
return &wordlist[key]; |
||||
} |
||||
} |
||||
return 0; |
||||
} |
||||
@ -0,0 +1,186 @@ |
||||
/* ANSI-C code produced by gperf version 3.0.3 */ |
||||
/* Command-line: gperf -E -t -L ANSI-C -C -F ', TOK_ERROR' -c -H op_hash -N in_op_set -W oplist ../../../trunk/libclamav/jsparse/operators.gperf */ |
||||
/* Computed positions: -k'1,$' */ |
||||
|
||||
#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ |
||||
&& ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
|
||||
&& (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
|
||||
&& ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
|
||||
&& ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
|
||||
&& ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
|
||||
&& ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
|
||||
&& ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
|
||||
&& ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
|
||||
&& ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
|
||||
&& ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
|
||||
&& ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
|
||||
&& ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
|
||||
&& ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
|
||||
&& ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
|
||||
&& ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
|
||||
&& ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
|
||||
&& ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
|
||||
&& ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
|
||||
&& ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
|
||||
&& ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
|
||||
&& ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
|
||||
&& ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)) |
||||
/* The character set is not based on ISO-646. */ |
||||
#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>." |
||||
#endif |
||||
|
||||
struct operator { |
||||
const char *name; |
||||
int val; |
||||
}; |
||||
/* maximum key range = 121, duplicates = 0 */ |
||||
|
||||
#ifdef __GNUC__ |
||||
__inline |
||||
#else |
||||
#ifdef __cplusplus |
||||
inline |
||||
#endif |
||||
#endif |
||||
static unsigned int |
||||
op_hash (const char *str, unsigned int len) |
||||
{ |
||||
static const unsigned char asso_values[] = |
||||
{ |
||||
122, 122, 122, 122, 122, 122, 122, 122, 122, 122, |
||||
122, 122, 122, 122, 122, 122, 122, 122, 122, 122, |
||||
122, 122, 122, 122, 122, 122, 122, 122, 122, 122, |
||||
122, 122, 122, 50, 122, 122, 122, 31, 40, 122, |
||||
122, 122, 21, 30, 122, 25, 122, 16, 122, 122, |
||||
122, 122, 122, 122, 122, 122, 122, 122, 45, 122, |
||||
10, 5, 0, 35, 122, 122, 122, 122, 122, 122, |
||||
122, 122, 122, 122, 122, 122, 122, 122, 122, 122, |
||||
122, 122, 122, 122, 122, 122, 122, 122, 122, 122, |
||||
122, 122, 122, 122, 60, 122, 122, 122, 122, 122, |
||||
122, 122, 122, 122, 122, 122, 122, 122, 122, 122, |
||||
122, 122, 122, 122, 122, 122, 122, 122, 122, 122, |
||||
122, 122, 122, 122, 20, 122, 15, 122, 122, 122, |
||||
122, 122, 122, 122, 122, 122, 122, 122, 122, 122, |
||||
122, 122, 122, 122, 122, 122, 122, 122, 122, 122, |
||||
122, 122, 122, 122, 122, 122, 122, 122, 122, 122, |
||||
122, 122, 122, 122, 122, 122, 122, 122, 122, 122, |
||||
122, 122, 122, 122, 122, 122, 122, 122, 122, 122, |
||||
122, 122, 122, 122, 122, 122, 122, 122, 122, 122, |
||||
122, 122, 122, 122, 122, 122, 122, 122, 122, 122, |
||||
122, 122, 122, 122, 122, 122, 122, 122, 122, 122, |
||||
122, 122, 122, 122, 122, 122, 122, 122, 122, 122, |
||||
122, 122, 122, 122, 122, 122, 122, 122, 122, 122, |
||||
122, 122, 122, 122, 122, 122, 122, 122, 122, 122, |
||||
122, 122, 122, 122, 122, 122, 122, 122, 122, 122, |
||||
122, 122, 122, 122, 122, 122 |
||||
}; |
||||
return len + asso_values[(unsigned char)str[len - 1]] + asso_values[(unsigned char)str[0]]; |
||||
} |
||||
|
||||
#ifdef __GNUC__ |
||||
__inline |
||||
#ifdef __GNUC_STDC_INLINE__ |
||||
__attribute__ ((__gnu_inline__)) |
||||
#endif |
||||
#endif |
||||
static const struct operator * |
||||
in_op_set (const char *str, unsigned int len) |
||||
{ |
||||
enum |
||||
{ |
||||
TOTAL_KEYWORDS = 39, |
||||
MIN_WORD_LENGTH = 1, |
||||
MAX_WORD_LENGTH = 4, |
||||
MIN_HASH_VALUE = 1, |
||||
MAX_HASH_VALUE = 121 |
||||
}; |
||||
|
||||
static const struct operator oplist[] = |
||||
{ |
||||
{"", TOK_ERROR}, |
||||
{">", TOK_GREATER}, |
||||
{">>", TOK_SHIFT_RIGHT}, |
||||
{">>>", TOK_DOUBLESHIFT_RIGHT}, |
||||
{"", TOK_ERROR}, {"", TOK_ERROR}, {"", TOK_ERROR}, |
||||
{">=", TOK_GREATEREQUAL}, |
||||
{">>=", TOK_ASSIGNMENT_OPERATOR_NOEQUAL}, |
||||
{">>>=", TOK_ASSIGNMENT_OPERATOR_NOEQUAL}, |
||||
{"", TOK_ERROR}, |
||||
{"=", TOK_EQUAL}, |
||||
{"==", TOK_EQUAL_EQUAL}, |
||||
{"===", TOK_TRIPLE_EQUAL}, |
||||
{"", TOK_ERROR}, {"", TOK_ERROR}, {"", TOK_ERROR}, |
||||
{"<=", TOK_LESSEQUAL}, |
||||
{"<<=", TOK_ASSIGNMENT_OPERATOR_NOEQUAL}, |
||||
{"", TOK_ERROR}, {"", TOK_ERROR}, |
||||
{"<", TOK_LESS}, |
||||
{"<<", TOK_SHIFT_LEFT}, |
||||
{"/=", TOK_ASSIGNMENT_OPERATOR_NOEQUAL}, |
||||
{"", TOK_ERROR}, {"", TOK_ERROR}, {"", TOK_ERROR}, |
||||
{"|=", TOK_ASSIGNMENT_OPERATOR_NOEQUAL}, |
||||
{"*=", TOK_ASSIGNMENT_OPERATOR_NOEQUAL}, |
||||
{"", TOK_ERROR}, {"", TOK_ERROR}, |
||||
{"~", TOK_TILDE}, |
||||
{"-=", TOK_ASSIGNMENT_OPERATOR_NOEQUAL}, |
||||
{"/", TOK_DIVIDE}, |
||||
{"", TOK_ERROR}, {"", TOK_ERROR}, {"", TOK_ERROR}, |
||||
{"+=", TOK_ASSIGNMENT_OPERATOR_NOEQUAL}, |
||||
{"%=", TOK_ASSIGNMENT_OPERATOR_NOEQUAL}, |
||||
{"", TOK_ERROR}, {"", TOK_ERROR}, |
||||
{"|", TOK_OR}, |
||||
{"||", TOK_OR_OR}, |
||||
{"*", TOK_MULTIPLY}, |
||||
{"", TOK_ERROR}, {"", TOK_ERROR}, {"", TOK_ERROR}, |
||||
{"&=", TOK_ASSIGNMENT_OPERATOR_NOEQUAL}, |
||||
{"", TOK_ERROR}, {"", TOK_ERROR}, {"", TOK_ERROR}, |
||||
{"-", TOK_MINUS}, |
||||
{"--", TOK_MINUSMINUS}, |
||||
{"", TOK_ERROR}, {"", TOK_ERROR}, {"", TOK_ERROR}, |
||||
{"", TOK_ERROR}, |
||||
{"!=", TOK_NOT_EQUAL}, |
||||
{"!==", TOK_NOT_DOUBLEEQUAL}, |
||||
{"", TOK_ERROR}, {"", TOK_ERROR}, |
||||
{"+", TOK_PLUS}, |
||||
{"++", TOK_PLUSPLUS}, |
||||
{"%", TOK_PERCENT}, |
||||
{"", TOK_ERROR}, {"", TOK_ERROR}, {"", TOK_ERROR}, |
||||
{"^=", TOK_ASSIGNMENT_OPERATOR_NOEQUAL}, |
||||
{"", TOK_ERROR}, {"", TOK_ERROR}, {"", TOK_ERROR}, |
||||
{"?", TOK_QUESTIONMARK}, |
||||
{"", TOK_ERROR}, {"", TOK_ERROR}, {"", TOK_ERROR}, |
||||
{"", TOK_ERROR}, {"", TOK_ERROR}, {"", TOK_ERROR}, |
||||
{"", TOK_ERROR}, {"", TOK_ERROR}, {"", TOK_ERROR}, |
||||
{"&", TOK_AND}, |
||||
{"&&", TOK_AND_AND}, |
||||
{"", TOK_ERROR}, {"", TOK_ERROR}, {"", TOK_ERROR}, |
||||
{"", TOK_ERROR}, {"", TOK_ERROR}, {"", TOK_ERROR}, |
||||
{"", TOK_ERROR}, {"", TOK_ERROR}, |
||||
{":", TOK_COLON}, |
||||
{"", TOK_ERROR}, {"", TOK_ERROR}, {"", TOK_ERROR}, |
||||
{"", TOK_ERROR}, {"", TOK_ERROR}, {"", TOK_ERROR}, |
||||
{"", TOK_ERROR}, {"", TOK_ERROR}, {"", TOK_ERROR}, |
||||
{"!", TOK_EXCLAMATION}, |
||||
{"", TOK_ERROR}, {"", TOK_ERROR}, {"", TOK_ERROR}, |
||||
{"", TOK_ERROR}, {"", TOK_ERROR}, {"", TOK_ERROR}, |
||||
{"", TOK_ERROR}, {"", TOK_ERROR}, {"", TOK_ERROR}, |
||||
{"", TOK_ERROR}, {"", TOK_ERROR}, {"", TOK_ERROR}, |
||||
{"", TOK_ERROR}, {"", TOK_ERROR}, {"", TOK_ERROR}, |
||||
{"", TOK_ERROR}, {"", TOK_ERROR}, {"", TOK_ERROR}, |
||||
{"", TOK_ERROR}, |
||||
{"^", TOK_XOR} |
||||
}; |
||||
|
||||
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) |
||||
{ |
||||
int key = op_hash (str, len); |
||||
|
||||
if (key <= MAX_HASH_VALUE && key >= 0) |
||||
{ |
||||
const char *s = oplist[key].name; |
||||
|
||||
if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0') |
||||
return &oplist[key]; |
||||
} |
||||
} |
||||
return 0; |
||||
} |
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,29 @@ |
||||
/*
|
||||
* Javascript normalizer. |
||||
* |
||||
* Copyright (C) 2008 Sourcefire, Inc. |
||||
* |
||||
* Authors: Török Edvin |
||||
* |
||||
* This program is free software; you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License version 2 as |
||||
* published by the Free Software Foundation. |
||||
* |
||||
* This program 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 this program; if not, write to the Free Software |
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
||||
* MA 02110-1301, USA. |
||||
*/ |
||||
|
||||
struct parser_state; |
||||
int cli_js_init(struct parser_state *state); |
||||
void cli_js_process_buffer(struct parser_state *state, const char *buf, size_t n); |
||||
void cli_js_parse_done(struct parser_state* state); |
||||
void cli_js_output(struct parser_state *state); |
||||
void cli_js_destroy(struct parser_state *state); |
||||
|
||||
@ -0,0 +1,25 @@ |
||||
break |
||||
case |
||||
catch |
||||
continue |
||||
default |
||||
delete |
||||
do |
||||
else |
||||
finally |
||||
for |
||||
function |
||||
if |
||||
in |
||||
instanceof |
||||
new |
||||
return |
||||
switch |
||||
this |
||||
throw |
||||
try |
||||
typeof |
||||
var |
||||
void |
||||
while |
||||
with |
||||
@ -0,0 +1,146 @@ |
||||
/*
|
||||
* Javascript normalizer. |
||||
* |
||||
* Copyright (C) 2008 Sourcefire, Inc. |
||||
* |
||||
* Authors: Török Edvin |
||||
* |
||||
* This program is free software; you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License version 2 as |
||||
* published by the Free Software Foundation. |
||||
* |
||||
* This program 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 this program; if not, write to the Free Software |
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
||||
* MA 02110-1301, USA. |
||||
*/ |
||||
#ifndef YYSTYPE |
||||
enum token_type { |
||||
TOK_FUTURE_RESERVED_WORD=1, |
||||
TOK_ERROR, |
||||
TOK_IDENTIFIER_NAME, |
||||
TOK_TRUE, |
||||
TOK_FALSE, |
||||
TOK_NULL, |
||||
TOK_BRACKET_OPEN, |
||||
TOK_BRACKET_CLOSE, |
||||
TOK_COMMA, |
||||
TOK_CURLY_BRACE_OPEN, |
||||
TOK_CURLY_BRACE_CLOSE, |
||||
TOK_PAR_OPEN, |
||||
TOK_PAR_CLOSE, |
||||
TOK_DOT, |
||||
TOK_SEMICOLON, |
||||
TOK_COLON, |
||||
TOK_NEW, |
||||
TOK_NumericInt, |
||||
TOK_NumericFloat, |
||||
TOK_StringLiteral, |
||||
TOK_REGULAR_EXPRESSION_LITERAL, |
||||
TOK_THIS, |
||||
TOK_PLUSPLUS, |
||||
TOK_MINUSMINUS, |
||||
TOK_DELETE, |
||||
TOK_VOID, |
||||
TOK_TYPEOF, |
||||
TOK_MINUS, |
||||
TOK_TILDE, |
||||
TOK_EXCLAMATION, |
||||
TOK_MULTIPLY, |
||||
TOK_DIVIDE, |
||||
TOK_PERCENT, |
||||
TOK_PLUS, |
||||
TOK_SHIFT_LEFT, |
||||
TOK_SHIFT_RIGHT, |
||||
TOK_DOUBLESHIFT_RIGHT, |
||||
TOK_LESS, |
||||
TOK_GREATER, |
||||
TOK_LESSEQUAL, |
||||
TOK_GREATEREQUAL, |
||||
TOK_INSTANCEOF, |
||||
TOK_IN, |
||||
TOK_EQUAL_EQUAL, |
||||
TOK_NOT_EQUAL, |
||||
TOK_TRIPLE_EQUAL, |
||||
TOK_NOT_DOUBLEEQUAL, |
||||
TOK_AND, |
||||
TOK_XOR, |
||||
TOK_OR, |
||||
TOK_AND_AND, |
||||
TOK_OR_OR, |
||||
TOK_QUESTIONMARK, |
||||
TOK_EQUAL, |
||||
TOK_ASSIGNMENT_OPERATOR_NOEQUAL, |
||||
TOK_VAR, |
||||
TOK_IF, |
||||
TOK_ELSE, |
||||
TOK_DO, |
||||
TOK_WHILE, |
||||
TOK_FOR, |
||||
TOK_CONTINUE, |
||||
TOK_BREAK, |
||||
TOK_RETURN, |
||||
TOK_WITH, |
||||
TOK_SWITCH, |
||||
TOK_CASE, |
||||
TOK_DEFAULT, |
||||
TOK_THROW, |
||||
TOK_TRY, |
||||
TOK_CATCH, |
||||
TOK_FINALLY, |
||||
TOK_FUNCTION, |
||||
TOK_UNNORM_IDENTIFIER |
||||
}; |
||||
|
||||
enum val_type { |
||||
vtype_undefined, |
||||
vtype_cstring, |
||||
vtype_string, |
||||
vtype_scope, |
||||
vtype_dval, |
||||
vtype_ival |
||||
}; |
||||
|
||||
typedef struct token { |
||||
union { |
||||
const char *cstring; |
||||
char *string; |
||||
struct scope *scope;/* for function */ |
||||
double dval; |
||||
long ival; |
||||
} val; |
||||
enum token_type type; |
||||
enum val_type vtype; |
||||
} yystype; |
||||
|
||||
/* inline functions to access the structure to ensure type safety */ |
||||
|
||||
#define TOKEN_SET(DST, VTYPE, VAL) do {\ |
||||
(DST)->vtype = vtype_##VTYPE ; (DST)->val.VTYPE = (VAL); \
|
||||
} while(0); |
||||
|
||||
#define cstring_invalid NULL |
||||
#define string_invalid NULL |
||||
#define scope_invalid NULL |
||||
/* there isn't really an invalid double, or long value, but we don't care
|
||||
* about those values anyway, so -1 will be fine here */ |
||||
#define dval_invalid -1 |
||||
#define ival_invalid -1 |
||||
|
||||
/* compatible if same type, or if we request a const char* instead of char*,
|
||||
* but not viceversa! */ |
||||
static int vtype_compatible(enum val_type orig, enum val_type req) |
||||
{ |
||||
return orig == req || (orig == vtype_string && req == vtype_cstring); |
||||
} |
||||
#define COMPATIBLE(SRC, VTYPE) ((SRC)->vtype == vtype_##VTYPE || ) |
||||
|
||||
#define TOKEN_GET(SRC, VTYPE) (vtype_compatible((SRC)->vtype, vtype_##VTYPE) ? (SRC)->val.VTYPE : VTYPE##_invalid) |
||||
|
||||
#define YYSTYPE yystype |
||||
#endif |
||||
@ -0,0 +1,44 @@ |
||||
struct operator { |
||||
const char *name; |
||||
int val; |
||||
}; |
||||
%% |
||||
=, TOK_EQUAL |
||||
+, TOK_PLUS |
||||
===, TOK_TRIPLE_EQUAL |
||||
>>>, TOK_DOUBLESHIFT_RIGHT |
||||
!==, TOK_NOT_DOUBLEEQUAL |
||||
<<, TOK_SHIFT_LEFT |
||||
<=, TOK_LESSEQUAL |
||||
==, TOK_EQUAL_EQUAL |
||||
>=, TOK_GREATEREQUAL |
||||
>>, TOK_SHIFT_RIGHT |
||||
||, TOK_OR_OR |
||||
--, TOK_MINUSMINUS |
||||
!=, TOK_NOT_EQUAL |
||||
&&, TOK_AND_AND |
||||
++, TOK_PLUSPLUS |
||||
*=, TOK_ASSIGNMENT_OPERATOR_NOEQUAL |
||||
/=, TOK_ASSIGNMENT_OPERATOR_NOEQUAL |
||||
"%=", TOK_ASSIGNMENT_OPERATOR_NOEQUAL |
||||
+=, TOK_ASSIGNMENT_OPERATOR_NOEQUAL |
||||
-=, TOK_ASSIGNMENT_OPERATOR_NOEQUAL |
||||
<<=, TOK_ASSIGNMENT_OPERATOR_NOEQUAL |
||||
>>=, TOK_ASSIGNMENT_OPERATOR_NOEQUAL |
||||
>>>=, TOK_ASSIGNMENT_OPERATOR_NOEQUAL |
||||
&=, TOK_ASSIGNMENT_OPERATOR_NOEQUAL |
||||
^=, TOK_ASSIGNMENT_OPERATOR_NOEQUAL |
||||
|=, TOK_ASSIGNMENT_OPERATOR_NOEQUAL |
||||
&, TOK_AND |
||||
:, TOK_COLON |
||||
/, TOK_DIVIDE |
||||
!, TOK_EXCLAMATION |
||||
>, TOK_GREATER |
||||
<, TOK_LESS |
||||
-, TOK_MINUS |
||||
*, TOK_MULTIPLY |
||||
|, TOK_OR |
||||
"%", TOK_PERCENT |
||||
?, TOK_QUESTIONMARK |
||||
~, TOK_TILDE |
||||
^, TOK_XOR |
||||
@ -0,0 +1,3 @@ |
||||
null, TOK_NULL |
||||
true, TOK_TRUE |
||||
false, TOK_FALSE |
||||
Loading…
Reference in new issue