2007-11-13 21:47:04 +01:00
|
|
|
--- c.c
|
|
|
|
+++ c.c
|
2007-11-13 01:40:18 +01:00
|
|
|
@@ -59,35 +59,39 @@ typedef enum eException {
|
2006-12-29 00:06:40 +01:00
|
|
|
*/
|
|
|
|
typedef enum eKeywordId {
|
|
|
|
KEYWORD_NONE = -1,
|
|
|
|
- KEYWORD_ATTRIBUTE, KEYWORD_ABSTRACT,
|
|
|
|
- KEYWORD_BOOLEAN, KEYWORD_BYTE, KEYWORD_BAD_STATE, KEYWORD_BAD_TRANS,
|
|
|
|
- KEYWORD_BIND, KEYWORD_BIND_VAR, KEYWORD_BIT,
|
|
|
|
+ KEYWORD_ATTRIBUTE, KEYWORD_ABSTRACT, KEYWORD_ANY,
|
|
|
|
+ KEYWORD_BOOLEAN, KEYWORD_BYTE, KEYWORD_BYTEBLOCK, KEYWORD_BAD_STATE,
|
|
|
|
+ KEYWORD_BAD_TRANS,
|
|
|
|
+ KEYWORD_BIND, KEYWORD_BIND_VAR, KEYWORD_BIT, KEYWORD_BLOCK,
|
|
|
|
KEYWORD_CASE, KEYWORD_CATCH, KEYWORD_CHAR, KEYWORD_CLASS, KEYWORD_CONST,
|
|
|
|
KEYWORD_CONSTRAINT, KEYWORD_COVERAGE_BLOCK, KEYWORD_COVERAGE_DEF,
|
|
|
|
- KEYWORD_DEFAULT, KEYWORD_DELEGATE, KEYWORD_DELETE, KEYWORD_DO,
|
|
|
|
+ KEYWORD_DEFAULT, KEYWORD_DECLARATION, KEYWORD_DELEGATE, KEYWORD_DELETE,
|
|
|
|
+ KEYWORD_DO,
|
|
|
|
KEYWORD_DOUBLE,
|
|
|
|
- KEYWORD_ELSE, KEYWORD_ENUM, KEYWORD_EXPLICIT, KEYWORD_EXTERN,
|
|
|
|
+ KEYWORD_ELSE, KEYWORD_ENUM, KEYWORD_EXPLICIT, KEYWORD_EXPRESSION,
|
|
|
|
+ KEYWORD_EXTERN,
|
|
|
|
KEYWORD_EXTENDS, KEYWORD_EVENT,
|
|
|
|
KEYWORD_FINAL, KEYWORD_FLOAT, KEYWORD_FOR, KEYWORD_FRIEND, KEYWORD_FUNCTION,
|
|
|
|
KEYWORD_GOTO,
|
|
|
|
KEYWORD_IF, KEYWORD_IMPLEMENTS, KEYWORD_IMPORT, KEYWORD_INLINE, KEYWORD_INT,
|
|
|
|
KEYWORD_INOUT, KEYWORD_INPUT, KEYWORD_INTEGER, KEYWORD_INTERFACE,
|
|
|
|
KEYWORD_INTERNAL,
|
|
|
|
- KEYWORD_LOCAL, KEYWORD_LONG,
|
|
|
|
+ KEYWORD_LIST, KEYWORD_LOCAL, KEYWORD_LOCALE, KEYWORD_LONG,
|
|
|
|
KEYWORD_M_BAD_STATE, KEYWORD_M_BAD_TRANS, KEYWORD_M_STATE, KEYWORD_M_TRANS,
|
|
|
|
- KEYWORD_MUTABLE,
|
|
|
|
+ KEYWORD_MAP, KEYWORD_MUTABLE,
|
|
|
|
KEYWORD_NAMESPACE, KEYWORD_NEW, KEYWORD_NEWCOV, KEYWORD_NATIVE,
|
|
|
|
KEYWORD_OPERATOR, KEYWORD_OUTPUT, KEYWORD_OVERLOAD, KEYWORD_OVERRIDE,
|
|
|
|
- KEYWORD_PACKED, KEYWORD_PORT, KEYWORD_PACKAGE, KEYWORD_PRIVATE,
|
|
|
|
- KEYWORD_PROGRAM, KEYWORD_PROTECTED, KEYWORD_PUBLIC,
|
|
|
|
+ KEYWORD_PACKED, KEYWORD_PATH, KEYWORD_PORT, KEYWORD_PACKAGE,
|
|
|
|
+ KEYWORD_PRIVATE,
|
|
|
|
+ KEYWORD_PROGRAM, KEYWORD_PROTECTED, KEYWORD_PUBLIC, KEYWORD_REPEAT,
|
|
|
|
KEYWORD_REGISTER, KEYWORD_RETURN,
|
|
|
|
KEYWORD_SHADOW, KEYWORD_STATE,
|
|
|
|
KEYWORD_SHORT, KEYWORD_SIGNED, KEYWORD_STATIC, KEYWORD_STRING,
|
|
|
|
- KEYWORD_STRUCT, KEYWORD_SWITCH, KEYWORD_SYNCHRONIZED,
|
|
|
|
- KEYWORD_TASK, KEYWORD_TEMPLATE, KEYWORD_THIS, KEYWORD_THROW,
|
|
|
|
+ KEYWORD_STRUCT, KEYWORD_SWITCH, KEYWORD_SYNCHRONIZED, KEYWORD_SYMBOL,
|
|
|
|
+ KEYWORD_TASK, KEYWORD_TEMPLATE, KEYWORD_TERM, KEYWORD_THIS, KEYWORD_THROW,
|
|
|
|
KEYWORD_THROWS, KEYWORD_TRANSIENT, KEYWORD_TRANS, KEYWORD_TRANSITION,
|
|
|
|
KEYWORD_TRY, KEYWORD_TYPEDEF, KEYWORD_TYPENAME,
|
|
|
|
- KEYWORD_UINT, KEYWORD_ULONG, KEYWORD_UNION, KEYWORD_UNSIGNED, KEYWORD_USHORT,
|
|
|
|
+ KEYWORD_UINT, KEYWORD_ULONG, KEYWORD_UNION, KEYWORD_UNSIGNED, KEYWORD_UNTIL, KEYWORD_USHORT,
|
|
|
|
KEYWORD_USING,
|
|
|
|
KEYWORD_VIRTUAL, KEYWORD_VOID, KEYWORD_VOLATILE,
|
|
|
|
KEYWORD_WCHAR_T, KEYWORD_WHILE
|
2007-11-13 01:40:18 +01:00
|
|
|
@@ -99,7 +103,7 @@ typedef enum eKeywordId {
|
2006-12-29 00:06:40 +01:00
|
|
|
typedef struct sKeywordDesc {
|
|
|
|
const char *name;
|
|
|
|
keywordId id;
|
|
|
|
- short isValid [5]; /* indicates languages for which kw is valid */
|
|
|
|
+ short isValid [6]; /* indicates languages for which kw is valid */
|
|
|
|
} keywordDesc;
|
|
|
|
|
|
|
|
/* Used for reporting the type of object parsed by nextToken ().
|
2007-11-13 01:40:18 +01:00
|
|
|
@@ -135,6 +139,7 @@ typedef enum eTagScope {
|
2006-12-29 00:06:40 +01:00
|
|
|
typedef enum eDeclaration {
|
|
|
|
DECL_NONE,
|
|
|
|
DECL_BASE, /* base type (default) */
|
|
|
|
+ DECL_BLOCK, /* YCP unnamed block */
|
|
|
|
DECL_CLASS,
|
|
|
|
DECL_ENUM,
|
|
|
|
DECL_EVENT,
|
2007-11-13 01:40:18 +01:00
|
|
|
@@ -256,6 +261,7 @@ static langType Lang_cpp;
|
2006-12-29 00:06:40 +01:00
|
|
|
static langType Lang_csharp;
|
|
|
|
static langType Lang_java;
|
|
|
|
static langType Lang_vera;
|
|
|
|
+static langType Lang_ycp;
|
|
|
|
static vString *Signature;
|
|
|
|
static boolean CollectingSignature;
|
|
|
|
|
2007-11-13 01:40:18 +01:00
|
|
|
@@ -354,110 +360,138 @@ static kindOption VeraKinds [] = {
|
2006-12-29 00:06:40 +01:00
|
|
|
{ FALSE, 'x', "externvar", "external variable declarations"}
|
|
|
|
};
|
|
|
|
|
|
|
|
+/* Used to index into the YCPKinds table. */
|
|
|
|
+typedef enum {
|
|
|
|
+ YK_UNDEFINED = -1,
|
|
|
|
+ YK_FUNCTION, YK_PROTOTYPE,
|
|
|
|
+ YK_LOCAL,
|
|
|
|
+ YK_VARIABLE
|
|
|
|
+} ycpKind;
|
|
|
|
+
|
|
|
|
+static kindOption YCPKinds [] = {
|
|
|
|
+ { TRUE, 'f', "function", "function definitions"},
|
|
|
|
+ { FALSE, 'p', "prototype", "function prototypes"},
|
|
|
|
+ { FALSE, 'l', "local", "local variables"},
|
|
|
|
+ { TRUE, 'v', "variable", "variable definitions"},
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
static const keywordDesc KeywordTable [] = {
|
|
|
|
- /* C++ */
|
|
|
|
- /* ANSI C | C# Java */
|
|
|
|
- /* | | | | Vera */
|
|
|
|
- /* keyword keyword ID | | | | | */
|
|
|
|
- { "__attribute__", KEYWORD_ATTRIBUTE, { 1, 1, 1, 0, 0 } },
|
|
|
|
- { "abstract", KEYWORD_ABSTRACT, { 0, 0, 1, 1, 0 } },
|
|
|
|
- { "bad_state", KEYWORD_BAD_STATE, { 0, 0, 0, 0, 1 } },
|
|
|
|
- { "bad_trans", KEYWORD_BAD_TRANS, { 0, 0, 0, 0, 1 } },
|
|
|
|
- { "bind", KEYWORD_BIND, { 0, 0, 0, 0, 1 } },
|
|
|
|
- { "bind_var", KEYWORD_BIND_VAR, { 0, 0, 0, 0, 1 } },
|
|
|
|
- { "bit", KEYWORD_BIT, { 0, 0, 0, 0, 1 } },
|
|
|
|
- { "boolean", KEYWORD_BOOLEAN, { 0, 0, 0, 1, 0 } },
|
|
|
|
- { "byte", KEYWORD_BYTE, { 0, 0, 0, 1, 0 } },
|
|
|
|
- { "case", KEYWORD_CASE, { 1, 1, 1, 1, 0 } },
|
|
|
|
- { "catch", KEYWORD_CATCH, { 0, 1, 1, 0, 0 } },
|
|
|
|
- { "char", KEYWORD_CHAR, { 1, 1, 1, 1, 0 } },
|
|
|
|
- { "class", KEYWORD_CLASS, { 0, 1, 1, 1, 1 } },
|
|
|
|
- { "const", KEYWORD_CONST, { 1, 1, 1, 1, 0 } },
|
|
|
|
- { "constraint", KEYWORD_CONSTRAINT, { 0, 0, 0, 0, 1 } },
|
|
|
|
- { "coverage_block", KEYWORD_COVERAGE_BLOCK, { 0, 0, 0, 0, 1 } },
|
|
|
|
- { "coverage_def", KEYWORD_COVERAGE_DEF, { 0, 0, 0, 0, 1 } },
|
|
|
|
- { "do", KEYWORD_DO, { 1, 1, 1, 1, 0 } },
|
|
|
|
- { "default", KEYWORD_DEFAULT, { 1, 1, 1, 1, 0 } },
|
|
|
|
- { "delegate", KEYWORD_DELEGATE, { 0, 0, 1, 0, 0 } },
|
|
|
|
- { "delete", KEYWORD_DELETE, { 0, 1, 0, 0, 0 } },
|
|
|
|
- { "double", KEYWORD_DOUBLE, { 1, 1, 1, 1, 0 } },
|
|
|
|
- { "else", KEYWORD_ELSE, { 1, 1, 0, 1, 0 } },
|
2007-11-13 01:40:18 +01:00
|
|
|
- { "enum", KEYWORD_ENUM, { 1, 1, 1, 1, 1 } },
|
2006-12-29 00:06:40 +01:00
|
|
|
- { "event", KEYWORD_EVENT, { 0, 0, 1, 0, 1 } },
|
|
|
|
- { "explicit", KEYWORD_EXPLICIT, { 0, 1, 1, 0, 0 } },
|
|
|
|
- { "extends", KEYWORD_EXTENDS, { 0, 0, 0, 1, 1 } },
|
|
|
|
- { "extern", KEYWORD_EXTERN, { 1, 1, 1, 0, 1 } },
|
|
|
|
- { "final", KEYWORD_FINAL, { 0, 0, 0, 1, 0 } },
|
|
|
|
- { "float", KEYWORD_FLOAT, { 1, 1, 1, 1, 0 } },
|
|
|
|
- { "for", KEYWORD_FOR, { 1, 1, 1, 1, 0 } },
|
|
|
|
- { "friend", KEYWORD_FRIEND, { 0, 1, 0, 0, 0 } },
|
|
|
|
- { "function", KEYWORD_FUNCTION, { 0, 0, 0, 0, 1 } },
|
|
|
|
- { "goto", KEYWORD_GOTO, { 1, 1, 1, 1, 0 } },
|
|
|
|
- { "if", KEYWORD_IF, { 1, 1, 1, 1, 0 } },
|
|
|
|
- { "implements", KEYWORD_IMPLEMENTS, { 0, 0, 0, 1, 0 } },
|
|
|
|
- { "import", KEYWORD_IMPORT, { 0, 0, 0, 1, 0 } },
|
|
|
|
- { "inline", KEYWORD_INLINE, { 0, 1, 0, 0, 0 } },
|
|
|
|
- { "inout", KEYWORD_INOUT, { 0, 0, 0, 0, 1 } },
|
|
|
|
- { "input", KEYWORD_INPUT, { 0, 0, 0, 0, 1 } },
|
|
|
|
- { "int", KEYWORD_INT, { 1, 1, 1, 1, 0 } },
|
|
|
|
- { "integer", KEYWORD_INTEGER, { 0, 0, 0, 0, 1 } },
|
|
|
|
- { "interface", KEYWORD_INTERFACE, { 0, 0, 1, 1, 1 } },
|
|
|
|
- { "internal", KEYWORD_INTERNAL, { 0, 0, 1, 0, 0 } },
|
|
|
|
- { "local", KEYWORD_LOCAL, { 0, 0, 0, 0, 1 } },
|
|
|
|
- { "long", KEYWORD_LONG, { 1, 1, 1, 1, 0 } },
|
|
|
|
- { "m_bad_state", KEYWORD_M_BAD_STATE, { 0, 0, 0, 0, 1 } },
|
|
|
|
- { "m_bad_trans", KEYWORD_M_BAD_TRANS, { 0, 0, 0, 0, 1 } },
|
|
|
|
- { "m_state", KEYWORD_M_STATE, { 0, 0, 0, 0, 1 } },
|
|
|
|
- { "m_trans", KEYWORD_M_TRANS, { 0, 0, 0, 0, 1 } },
|
|
|
|
- { "mutable", KEYWORD_MUTABLE, { 0, 1, 0, 0, 0 } },
|
|
|
|
- { "namespace", KEYWORD_NAMESPACE, { 0, 1, 1, 0, 0 } },
|
|
|
|
- { "native", KEYWORD_NATIVE, { 0, 0, 0, 1, 0 } },
|
|
|
|
- { "new", KEYWORD_NEW, { 0, 1, 1, 1, 0 } },
|
|
|
|
- { "newcov", KEYWORD_NEWCOV, { 0, 0, 0, 0, 1 } },
|
|
|
|
- { "operator", KEYWORD_OPERATOR, { 0, 1, 1, 0, 0 } },
|
|
|
|
- { "output", KEYWORD_OUTPUT, { 0, 0, 0, 0, 1 } },
|
|
|
|
- { "overload", KEYWORD_OVERLOAD, { 0, 1, 0, 0, 0 } },
|
|
|
|
- { "override", KEYWORD_OVERRIDE, { 0, 0, 1, 0, 0 } },
|
|
|
|
- { "package", KEYWORD_PACKAGE, { 0, 0, 0, 1, 0 } },
|
|
|
|
- { "packed", KEYWORD_PACKED, { 0, 0, 0, 0, 1 } },
|
|
|
|
- { "port", KEYWORD_PORT, { 0, 0, 0, 0, 1 } },
|
|
|
|
- { "private", KEYWORD_PRIVATE, { 0, 1, 1, 1, 0 } },
|
|
|
|
- { "program", KEYWORD_PROGRAM, { 0, 0, 0, 0, 1 } },
|
|
|
|
- { "protected", KEYWORD_PROTECTED, { 0, 1, 1, 1, 1 } },
|
|
|
|
- { "public", KEYWORD_PUBLIC, { 0, 1, 1, 1, 1 } },
|
|
|
|
- { "register", KEYWORD_REGISTER, { 1, 1, 0, 0, 0 } },
|
|
|
|
- { "return", KEYWORD_RETURN, { 1, 1, 1, 1, 0 } },
|
|
|
|
- { "shadow", KEYWORD_SHADOW, { 0, 0, 0, 0, 1 } },
|
|
|
|
- { "short", KEYWORD_SHORT, { 1, 1, 1, 1, 0 } },
|
|
|
|
- { "signed", KEYWORD_SIGNED, { 1, 1, 0, 0, 0 } },
|
|
|
|
- { "state", KEYWORD_STATE, { 0, 0, 0, 0, 1 } },
|
|
|
|
- { "static", KEYWORD_STATIC, { 1, 1, 1, 1, 1 } },
|
|
|
|
- { "string", KEYWORD_STRING, { 0, 0, 1, 0, 1 } },
|
|
|
|
- { "struct", KEYWORD_STRUCT, { 1, 1, 1, 0, 0 } },
|
|
|
|
- { "switch", KEYWORD_SWITCH, { 1, 1, 1, 1, 0 } },
|
|
|
|
- { "synchronized", KEYWORD_SYNCHRONIZED, { 0, 0, 0, 1, 0 } },
|
|
|
|
- { "task", KEYWORD_TASK, { 0, 0, 0, 0, 1 } },
|
|
|
|
- { "template", KEYWORD_TEMPLATE, { 0, 1, 0, 0, 0 } },
|
|
|
|
- { "this", KEYWORD_THIS, { 0, 1, 1, 1, 0 } },
|
|
|
|
- { "throw", KEYWORD_THROW, { 0, 1, 1, 1, 0 } },
|
|
|
|
- { "throws", KEYWORD_THROWS, { 0, 0, 0, 1, 0 } },
|
|
|
|
- { "trans", KEYWORD_TRANS, { 0, 0, 0, 0, 1 } },
|
|
|
|
- { "transition", KEYWORD_TRANSITION, { 0, 0, 0, 0, 1 } },
|
|
|
|
- { "transient", KEYWORD_TRANSIENT, { 0, 0, 0, 1, 0 } },
|
|
|
|
- { "try", KEYWORD_TRY, { 0, 1, 1, 0, 0 } },
|
|
|
|
- { "typedef", KEYWORD_TYPEDEF, { 1, 1, 1, 0, 1 } },
|
|
|
|
- { "typename", KEYWORD_TYPENAME, { 0, 1, 0, 0, 0 } },
|
|
|
|
- { "uint", KEYWORD_UINT, { 0, 0, 1, 0, 0 } },
|
|
|
|
- { "ulong", KEYWORD_ULONG, { 0, 0, 1, 0, 0 } },
|
|
|
|
- { "union", KEYWORD_UNION, { 1, 1, 0, 0, 0 } },
|
|
|
|
- { "unsigned", KEYWORD_UNSIGNED, { 1, 1, 1, 0, 0 } },
|
|
|
|
- { "ushort", KEYWORD_USHORT, { 0, 0, 1, 0, 0 } },
|
|
|
|
- { "using", KEYWORD_USING, { 0, 1, 1, 0, 0 } },
|
|
|
|
- { "virtual", KEYWORD_VIRTUAL, { 0, 1, 1, 0, 1 } },
|
|
|
|
- { "void", KEYWORD_VOID, { 1, 1, 1, 1, 1 } },
|
|
|
|
- { "volatile", KEYWORD_VOLATILE, { 1, 1, 1, 1, 0 } },
|
|
|
|
- { "wchar_t", KEYWORD_WCHAR_T, { 1, 1, 1, 0, 0 } },
|
|
|
|
- { "while", KEYWORD_WHILE, { 1, 1, 1, 1, 0 } }
|
|
|
|
+ /* C++ YCP */
|
|
|
|
+ /* ANSI C | C# Java | */
|
|
|
|
+ /* | | | | Vera */
|
|
|
|
+ /* keyword keyword ID | | | | | | */
|
|
|
|
+ { "__attribute__", KEYWORD_ATTRIBUTE, { 1, 1, 1, 0, 0, 0 } },
|
|
|
|
+ { "abstract", KEYWORD_ABSTRACT, { 0, 0, 1, 1, 0, 0 } },
|
2007-11-13 01:40:18 +01:00
|
|
|
+ { "any", KEYWORD_ANY, { 0, 0, 0, 0, 0, 1 } },
|
2007-11-13 21:47:04 +01:00
|
|
|
+ { "bad_state", KEYWORD_BAD_STATE, { 0, 0, 0, 0, 1, 0 } },
|
2006-12-29 00:06:40 +01:00
|
|
|
+ { "bad_trans", KEYWORD_BAD_TRANS, { 0, 0, 0, 0, 1, 0 } },
|
|
|
|
+ { "bind", KEYWORD_BIND, { 0, 0, 0, 0, 1, 0 } },
|
|
|
|
+ { "bind_var", KEYWORD_BIND_VAR, { 0, 0, 0, 0, 1, 0 } },
|
|
|
|
+ { "bit", KEYWORD_BIT, { 0, 0, 0, 0, 1, 0 } },
|
|
|
|
+ { "block", KEYWORD_BLOCK, { 0, 0, 0, 0, 0, 1 } },
|
|
|
|
+ { "boolean", KEYWORD_BOOLEAN, { 0, 0, 0, 1, 0, 1 } },
|
|
|
|
+ { "byte", KEYWORD_BYTE, { 0, 0, 0, 1, 0, 0 } },
|
|
|
|
+ { "byteblock", KEYWORD_BYTEBLOCK, { 0, 0, 0, 0, 0, 1 } },
|
|
|
|
+ { "case", KEYWORD_CASE, { 1, 1, 1, 1, 0, 0 } },
|
|
|
|
+ { "catch", KEYWORD_CATCH, { 0, 1, 1, 0, 0, 0 } },
|
|
|
|
+ { "char", KEYWORD_CHAR, { 1, 1, 1, 1, 0, 0 } },
|
|
|
|
+ { "class", KEYWORD_CLASS, { 0, 1, 1, 1, 1, 0 } },
|
|
|
|
+ { "const", KEYWORD_CONST, { 1, 1, 1, 1, 0, 0 } },
|
|
|
|
+ { "constraint", KEYWORD_CONSTRAINT, { 0, 0, 0, 0, 1, 0 } },
|
|
|
|
+ { "coverage_block", KEYWORD_COVERAGE_BLOCK, { 0, 0, 0, 0, 1, 0 } },
|
|
|
|
+ { "coverage_def", KEYWORD_COVERAGE_DEF, { 0, 0, 0, 0, 1, 0 } },
|
|
|
|
+ { "declaration", KEYWORD_DECLARATION, { 0, 0, 0, 0, 0, 1 } },
|
|
|
|
+ { "do", KEYWORD_DO, { 1, 1, 1, 1, 0, 1 } },
|
|
|
|
+ { "default", KEYWORD_DEFAULT, { 1, 1, 1, 1, 0, 0 } },
|
|
|
|
+ { "delegate", KEYWORD_DELEGATE, { 0, 0, 1, 0, 0, 0 } },
|
|
|
|
+ { "delete", KEYWORD_DELETE, { 0, 1, 0, 0, 0, 0 } },
|
|
|
|
+ { "double", KEYWORD_DOUBLE, { 1, 1, 1, 1, 0, 0 } },
|
|
|
|
+ { "else", KEYWORD_ELSE, { 1, 1, 0, 1, 0, 1 } },
|
2007-11-13 01:40:18 +01:00
|
|
|
+ { "enum", KEYWORD_ENUM, { 1, 1, 1, 1, 1, 1 } },
|
2006-12-29 00:06:40 +01:00
|
|
|
+ { "event", KEYWORD_EVENT, { 0, 0, 1, 0, 1, 0 } },
|
|
|
|
+ { "explicit", KEYWORD_EXPLICIT, { 0, 1, 1, 0, 0, 0 } },
|
|
|
|
+ { "expression", KEYWORD_EXPRESSION, { 0, 0, 0, 0, 0, 1 } },
|
|
|
|
+ { "extends", KEYWORD_EXTENDS, { 0, 0, 0, 1, 1, 0 } },
|
|
|
|
+ { "extern", KEYWORD_EXTERN, { 1, 1, 1, 0, 1, 0 } },
|
|
|
|
+ { "final", KEYWORD_FINAL, { 0, 0, 0, 1, 0, 1 } },
|
|
|
|
+ { "float", KEYWORD_FLOAT, { 1, 1, 1, 1, 0, 1 } },
|
|
|
|
+ { "for", KEYWORD_FOR, { 1, 1, 1, 1, 0, 0 } },
|
|
|
|
+ { "friend", KEYWORD_FRIEND, { 0, 1, 0, 0, 0, 0 } },
|
|
|
|
+ { "function", KEYWORD_FUNCTION, { 0, 0, 0, 0, 1, 0 } },
|
|
|
|
+ { "goto", KEYWORD_GOTO, { 1, 1, 1, 1, 0, 0 } },
|
|
|
|
+ { "if", KEYWORD_IF, { 1, 1, 1, 1, 0, 1 } },
|
|
|
|
+ { "implements", KEYWORD_IMPLEMENTS, { 0, 0, 0, 1, 0, 0 } },
|
|
|
|
+ { "import", KEYWORD_IMPORT, { 0, 0, 0, 1, 0, 1 } },
|
|
|
|
+ { "inline", KEYWORD_INLINE, { 0, 1, 0, 0, 0, 0 } },
|
|
|
|
+ { "inout", KEYWORD_INOUT, { 0, 0, 0, 0, 1, 0 } },
|
|
|
|
+ { "input", KEYWORD_INPUT, { 0, 0, 0, 0, 1, 0 } },
|
|
|
|
+ { "int", KEYWORD_INT, { 1, 1, 1, 1, 0, 0 } },
|
|
|
|
+ { "integer", KEYWORD_INTEGER, { 0, 0, 0, 0, 1, 1 } },
|
|
|
|
+ { "interface", KEYWORD_INTERFACE, { 0, 0, 1, 1, 1, 0 } },
|
|
|
|
+ { "internal", KEYWORD_INTERNAL, { 0, 0, 1, 0, 0, 0 } },
|
|
|
|
+ { "list", KEYWORD_LIST, { 0, 0, 0, 0, 0, 1 } },
|
|
|
|
+ { "local", KEYWORD_LOCAL, { 0, 0, 0, 0, 1, 0 } },
|
|
|
|
+ { "locale", KEYWORD_LOCALE, { 0, 0, 0, 0, 0, 1 } },
|
|
|
|
+ { "long", KEYWORD_LONG, { 1, 1, 1, 1, 0, 0 } },
|
|
|
|
+ { "m_bad_state", KEYWORD_M_BAD_STATE, { 0, 0, 0, 0, 1, 0 } },
|
|
|
|
+ { "m_bad_trans", KEYWORD_M_BAD_TRANS, { 0, 0, 0, 0, 1, 0 } },
|
|
|
|
+ { "m_state", KEYWORD_M_STATE, { 0, 0, 0, 0, 1, 0 } },
|
|
|
|
+ { "m_trans", KEYWORD_M_TRANS, { 0, 0, 0, 0, 1, 0 } },
|
|
|
|
+ { "map", KEYWORD_MAP, { 0, 0, 0, 0, 0, 1 } },
|
|
|
|
+ { "mutable", KEYWORD_MUTABLE, { 0, 1, 0, 0, 0, 0 } },
|
|
|
|
+ { "namespace", KEYWORD_NAMESPACE, { 0, 1, 1, 0, 0, 0 } },
|
|
|
|
+ { "native", KEYWORD_NATIVE, { 0, 0, 0, 1, 0, 0 } },
|
|
|
|
+ { "new", KEYWORD_NEW, { 0, 1, 1, 1, 0, 0 } },
|
|
|
|
+ { "newcov", KEYWORD_NEWCOV, { 0, 0, 0, 0, 1, 0 } },
|
|
|
|
+ { "operator", KEYWORD_OPERATOR, { 0, 1, 1, 0, 0, 0 } },
|
|
|
|
+ { "output", KEYWORD_OUTPUT, { 0, 0, 0, 0, 1, 0 } },
|
|
|
|
+ { "overload", KEYWORD_OVERLOAD, { 0, 1, 0, 0, 0, 0 } },
|
|
|
|
+ { "override", KEYWORD_OVERRIDE, { 0, 0, 1, 0, 0, 0 } },
|
|
|
|
+ { "package", KEYWORD_PACKAGE, { 0, 0, 0, 1, 0, 0 } },
|
|
|
|
+ { "packed", KEYWORD_PACKED, { 0, 0, 0, 0, 1, 0 } },
|
|
|
|
+ { "path", KEYWORD_PATH, { 0, 0, 0, 0, 0, 1 } },
|
|
|
|
+ { "port", KEYWORD_PORT, { 0, 0, 0, 0, 1, 0 } },
|
|
|
|
+ { "private", KEYWORD_PRIVATE, { 0, 1, 1, 1, 0, 0 } },
|
|
|
|
+ { "program", KEYWORD_PROGRAM, { 0, 0, 0, 0, 1, 0 } },
|
|
|
|
+ { "protected", KEYWORD_PROTECTED, { 0, 1, 1, 1, 1, 0 } },
|
|
|
|
+ { "public", KEYWORD_PUBLIC, { 0, 1, 1, 1, 1, 0 } },
|
|
|
|
+ { "repeat", KEYWORD_REPEAT, { 0, 0, 0, 0, 0, 1 } },
|
|
|
|
+ { "register", KEYWORD_REGISTER, { 1, 1, 0, 0, 0, 0 } },
|
|
|
|
+ { "return", KEYWORD_RETURN, { 1, 1, 1, 1, 0, 1 } },
|
|
|
|
+ { "shadow", KEYWORD_SHADOW, { 0, 0, 0, 0, 1, 0 } },
|
|
|
|
+ { "short", KEYWORD_SHORT, { 1, 1, 1, 1, 0, 0 } },
|
|
|
|
+ { "signed", KEYWORD_SIGNED, { 1, 1, 0, 0, 0, 0 } },
|
|
|
|
+ { "state", KEYWORD_STATE, { 0, 0, 0, 0, 1, 0 } },
|
|
|
|
+ { "static", KEYWORD_STATIC, { 1, 1, 1, 1, 1, 0 } },
|
|
|
|
+ { "string", KEYWORD_STRING, { 0, 0, 1, 0, 1, 1 } },
|
|
|
|
+ { "struct", KEYWORD_STRUCT, { 1, 1, 1, 0, 0, 0 } },
|
|
|
|
+ { "switch", KEYWORD_SWITCH, { 1, 1, 1, 1, 0, 0 } },
|
|
|
|
+ { "synchronized", KEYWORD_SYNCHRONIZED, { 0, 0, 0, 1, 0, 0 } },
|
|
|
|
+ { "symbol", KEYWORD_SYMBOL, { 0, 0, 0, 0, 0, 1 } },
|
|
|
|
+ { "task", KEYWORD_TASK, { 0, 0, 0, 0, 1, 0 } },
|
|
|
|
+ { "template", KEYWORD_TEMPLATE, { 0, 1, 0, 0, 0, 0 } },
|
|
|
|
+ { "term", KEYWORD_TERM, { 0, 0, 0, 0, 0, 1 } },
|
|
|
|
+ { "this", KEYWORD_THIS, { 0, 1, 1, 1, 0, 0 } },
|
|
|
|
+ { "throw", KEYWORD_THROW, { 0, 1, 1, 1, 0, 0 } },
|
|
|
|
+ { "throws", KEYWORD_THROWS, { 0, 0, 0, 1, 0, 0 } },
|
|
|
|
+ { "trans", KEYWORD_TRANS, { 0, 0, 0, 0, 1, 0 } },
|
|
|
|
+ { "transition", KEYWORD_TRANSITION, { 0, 0, 0, 0, 1, 0 } },
|
|
|
|
+ { "transient", KEYWORD_TRANSIENT, { 0, 0, 0, 1, 0, 0 } },
|
|
|
|
+ { "try", KEYWORD_TRY, { 0, 1, 1, 0, 0, 0 } },
|
|
|
|
+ { "typedef", KEYWORD_TYPEDEF, { 1, 1, 1, 0, 1, 0 } },
|
|
|
|
+ { "typename", KEYWORD_TYPENAME, { 0, 1, 0, 0, 0, 0 } },
|
|
|
|
+ { "uint", KEYWORD_UINT, { 0, 0, 1, 0, 0, 0 } },
|
|
|
|
+ { "ulong", KEYWORD_ULONG, { 0, 0, 1, 0, 0, 0 } },
|
|
|
|
+ { "union", KEYWORD_UNION, { 1, 1, 0, 0, 0, 0 } },
|
|
|
|
+ { "unsigned", KEYWORD_UNSIGNED, { 1, 1, 1, 0, 0, 0 } },
|
|
|
|
+ { "until", KEYWORD_UNTIL, { 0, 0, 0, 0, 0, 1 } },
|
|
|
|
+ { "ushort", KEYWORD_USHORT, { 0, 0, 1, 0, 0, 0 } },
|
|
|
|
+ { "using", KEYWORD_USING, { 0, 1, 1, 0, 0, 0 } },
|
|
|
|
+ { "virtual", KEYWORD_VIRTUAL, { 0, 1, 1, 0, 1, 0 } },
|
|
|
|
+ { "void", KEYWORD_VOID, { 1, 1, 1, 1, 1, 1 } },
|
|
|
|
+ { "volatile", KEYWORD_VOLATILE, { 1, 1, 1, 1, 0, 0 } },
|
|
|
|
+ { "wchar_t", KEYWORD_WCHAR_T, { 1, 1, 1, 0, 0, 0 } },
|
|
|
|
+ { "while", KEYWORD_WHILE, { 1, 1, 1, 1, 0, 1 } }
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
2007-11-13 01:40:18 +01:00
|
|
|
@@ -881,6 +915,21 @@ static veraKind veraTagKind (const tagTy
|
2006-12-29 00:06:40 +01:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
+static ycpKind ycpTagKind (const tagType type)
|
|
|
|
+{
|
|
|
|
+ ycpKind result = YK_UNDEFINED;
|
|
|
|
+ switch (type)
|
|
|
|
+ {
|
|
|
|
+ case TAG_FUNCTION: result = YK_FUNCTION; break;
|
|
|
|
+ case TAG_PROTOTYPE: result = YK_PROTOTYPE; break;
|
|
|
|
+ case TAG_LOCAL: result = YK_LOCAL; break;
|
|
|
|
+ case TAG_VARIABLE: result = YK_VARIABLE; break;
|
|
|
|
+
|
|
|
|
+ default: Assert ("Bad YCP tag type" == NULL); break;
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
static const char *tagName (const tagType type)
|
|
|
|
{
|
|
|
|
const char* result;
|
2007-11-13 01:40:18 +01:00
|
|
|
@@ -890,6 +939,8 @@ static const char *tagName (const tagTyp
|
2006-12-29 00:06:40 +01:00
|
|
|
result = JavaKinds [javaTagKind (type)].name;
|
|
|
|
else if (isLanguage (Lang_vera))
|
|
|
|
result = VeraKinds [veraTagKind (type)].name;
|
|
|
|
+ else if (isLanguage (Lang_ycp))
|
|
|
|
+ result = YCPKinds [ycpTagKind (type)].name;
|
|
|
|
else
|
|
|
|
result = CKinds [cTagKind (type)].name;
|
|
|
|
return result;
|
2007-11-13 01:40:18 +01:00
|
|
|
@@ -904,6 +955,8 @@ static int tagLetter (const tagType type
|
2006-12-29 00:06:40 +01:00
|
|
|
result = JavaKinds [javaTagKind (type)].letter;
|
|
|
|
else if (isLanguage (Lang_vera))
|
|
|
|
result = VeraKinds [veraTagKind (type)].letter;
|
|
|
|
+ else if (isLanguage (Lang_ycp))
|
|
|
|
+ result = YCPKinds [ycpTagKind (type)].letter;
|
|
|
|
else
|
|
|
|
result = CKinds [cTagKind (type)].letter;
|
|
|
|
return result;
|
2007-11-13 01:40:18 +01:00
|
|
|
@@ -959,7 +1012,8 @@ static const char* accessField (const st
|
2006-12-29 00:06:40 +01:00
|
|
|
|
|
|
|
static void addContextSeparator (vString *const scope)
|
|
|
|
{
|
|
|
|
- if (isLanguage (Lang_c) || isLanguage (Lang_cpp))
|
|
|
|
+ if (isLanguage (Lang_c) || isLanguage (Lang_cpp) ||
|
|
|
|
+ isLanguage (Lang_ycp))
|
|
|
|
vStringCatS (scope, "::");
|
|
|
|
else if (isLanguage (Lang_java) || isLanguage (Lang_csharp))
|
|
|
|
vStringCatS (scope, ".");
|
2007-11-13 01:40:18 +01:00
|
|
|
@@ -1717,9 +1771,11 @@ static void processToken (tokenInfo *con
|
2006-12-29 00:06:40 +01:00
|
|
|
|
|
|
|
case KEYWORD_NONE: processName (st); break;
|
|
|
|
case KEYWORD_ABSTRACT: st->implementation = IMP_ABSTRACT; break;
|
|
|
|
+ case KEYWORD_ANY: st->declaration = DECL_BASE; break;
|
|
|
|
case KEYWORD_ATTRIBUTE: skipParens (); initToken (token); break;
|
|
|
|
case KEYWORD_BIND: st->declaration = DECL_BASE; break;
|
|
|
|
case KEYWORD_BIT: st->declaration = DECL_BASE; break;
|
|
|
|
+ case KEYWORD_BYTEBLOCK: st->declaration = DECL_BASE; break;
|
|
|
|
case KEYWORD_CATCH: skipParens (); skipBraces (); break;
|
|
|
|
case KEYWORD_CHAR: st->declaration = DECL_BASE; break;
|
|
|
|
case KEYWORD_CLASS: st->declaration = DECL_CLASS; break;
|
2007-11-13 01:40:18 +01:00
|
|
|
@@ -1738,9 +1794,13 @@ static void processToken (tokenInfo *con
|
2006-12-29 00:06:40 +01:00
|
|
|
case KEYWORD_INT: st->declaration = DECL_BASE; break;
|
|
|
|
case KEYWORD_INTEGER: st->declaration = DECL_BASE; break;
|
2007-11-13 01:40:18 +01:00
|
|
|
case KEYWORD_INTERFACE: processInterface (st); break;
|
2006-12-29 00:06:40 +01:00
|
|
|
+ case KEYWORD_LIST: st->declaration = DECL_BASE; break;
|
|
|
|
case KEYWORD_LOCAL: setAccess (st, ACCESS_LOCAL); break;
|
|
|
|
+ case KEYWORD_LOCALE: st->declaration = DECL_BASE; break;
|
|
|
|
case KEYWORD_LONG: st->declaration = DECL_BASE; break;
|
|
|
|
+ case KEYWORD_MAP: st->declaration = DECL_BASE; break;
|
|
|
|
case KEYWORD_OPERATOR: readOperator (st); break;
|
|
|
|
+ case KEYWORD_PATH: st->declaration = DECL_BASE; break;
|
|
|
|
case KEYWORD_PRIVATE: setAccess (st, ACCESS_PRIVATE); break;
|
|
|
|
case KEYWORD_PROGRAM: st->declaration = DECL_PROGRAM; break;
|
|
|
|
case KEYWORD_PROTECTED: setAccess (st, ACCESS_PROTECTED); break;
|
2007-11-13 01:40:18 +01:00
|
|
|
@@ -1750,7 +1810,9 @@ static void processToken (tokenInfo *con
|
2006-12-29 00:06:40 +01:00
|
|
|
case KEYWORD_SIGNED: st->declaration = DECL_BASE; break;
|
|
|
|
case KEYWORD_STRING: st->declaration = DECL_BASE; break;
|
|
|
|
case KEYWORD_STRUCT: st->declaration = DECL_STRUCT; break;
|
|
|
|
+ case KEYWORD_SYMBOL: st->declaration = DECL_BASE; break;
|
|
|
|
case KEYWORD_TASK: st->declaration = DECL_TASK; break;
|
|
|
|
+ case KEYWORD_TERM: st->declaration = DECL_BASE; break;
|
|
|
|
case KEYWORD_THROWS: discardTypeList (token); break;
|
|
|
|
case KEYWORD_UNION: st->declaration = DECL_UNION; break;
|
|
|
|
case KEYWORD_UNSIGNED: st->declaration = DECL_BASE; break;
|
2007-11-13 01:40:18 +01:00
|
|
|
@@ -1793,7 +1855,9 @@ static void processToken (tokenInfo *con
|
2006-12-29 00:06:40 +01:00
|
|
|
|
|
|
|
case KEYWORD_FOR:
|
|
|
|
case KEYWORD_IF:
|
|
|
|
+ case KEYWORD_REPEAT:
|
|
|
|
case KEYWORD_SWITCH:
|
|
|
|
+ case KEYWORD_UNTIL:
|
|
|
|
case KEYWORD_WHILE:
|
|
|
|
{
|
|
|
|
int c = skipToNonWhite ();
|
2007-11-13 01:40:18 +01:00
|
|
|
@@ -2302,7 +2366,8 @@ static void addContext (statementInfo *c
|
2006-12-29 00:06:40 +01:00
|
|
|
{
|
|
|
|
if (vStringLength (st->context->name) > 0)
|
|
|
|
{
|
|
|
|
- if (isLanguage (Lang_c) || isLanguage (Lang_cpp))
|
|
|
|
+ if (isLanguage (Lang_c) || isLanguage (Lang_cpp) ||
|
|
|
|
+ isLanguage (Lang_ycp))
|
|
|
|
vStringCatS (st->context->name, "::");
|
|
|
|
else if (isLanguage (Lang_java) || isLanguage (Lang_csharp))
|
|
|
|
vStringCatS (st->context->name, ".");
|
2007-11-13 01:40:18 +01:00
|
|
|
@@ -2637,7 +2702,12 @@ static void nest (statementInfo *const s
|
2006-12-29 00:06:40 +01:00
|
|
|
st->inFunction = TRUE;
|
|
|
|
/* fall through */
|
|
|
|
default:
|
|
|
|
- if (includeTag (TAG_LOCAL, FALSE))
|
|
|
|
+ if (isLanguage (Lang_ycp) && ! st->haveQualifyingName)
|
|
|
|
+ {
|
|
|
|
+ st->declaration = DECL_BLOCK;
|
|
|
|
+ createTags (nestLevel, st);
|
|
|
|
+ }
|
|
|
|
+ else if (includeTag (TAG_LOCAL, FALSE))
|
|
|
|
createTags (nestLevel, st);
|
|
|
|
else
|
|
|
|
skipToMatch ("{}");
|
2007-11-13 01:40:18 +01:00
|
|
|
@@ -2678,6 +2748,7 @@ static void tagCheck (statementInfo *con
|
2006-12-29 00:06:40 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (isContextualStatement (st) ||
|
|
|
|
+ st->declaration == DECL_BLOCK ||
|
|
|
|
st->declaration == DECL_NAMESPACE ||
|
|
|
|
st->declaration == DECL_PROGRAM)
|
|
|
|
{
|
2007-11-13 01:40:18 +01:00
|
|
|
@@ -2844,6 +2915,12 @@ static void initializeVeraParser (const
|
2006-12-29 00:06:40 +01:00
|
|
|
buildKeywordHash (language, 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
+static void initializeYcpParser (const langType language)
|
|
|
|
+{
|
|
|
|
+ Lang_ycp = language;
|
|
|
|
+ buildKeywordHash (language, 5);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
extern parserDefinition* CParser (void)
|
|
|
|
{
|
|
|
|
static const char *const extensions [] = { "c", NULL };
|
2007-11-13 01:40:18 +01:00
|
|
|
@@ -2910,4 +2987,16 @@ extern parserDefinition* VeraParser (voi
|
2006-12-29 00:06:40 +01:00
|
|
|
return def;
|
|
|
|
}
|
|
|
|
|
|
|
|
+extern parserDefinition* YcpParser (void)
|
|
|
|
+{
|
|
|
|
+ static const char *const extensions [] = { "ycp", NULL };
|
|
|
|
+ parserDefinition* def = parserNew ("YCP");
|
|
|
|
+ def->kinds = YCPKinds;
|
|
|
|
+ def->kindCount = KIND_COUNT (YCPKinds);
|
|
|
|
+ def->extensions = extensions;
|
|
|
|
+ def->parser2 = findCTags;
|
|
|
|
+ def->initialize = initializeYcpParser;
|
|
|
|
+ return def;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
/* vi:set tabstop=4 shiftwidth=4 noexpandtab: */
|
2007-11-13 21:47:04 +01:00
|
|
|
--- parsers.h
|
|
|
|
+++ parsers.h
|
2007-11-13 01:40:18 +01:00
|
|
|
@@ -49,7 +49,8 @@
|
2006-12-29 00:06:40 +01:00
|
|
|
VeraParser, \
|
|
|
|
VerilogParser, \
|
|
|
|
VimParser, \
|
|
|
|
- YaccParser
|
|
|
|
+ YaccParser, \
|
|
|
|
+ YcpParser
|
|
|
|
|
|
|
|
#endif /* _PARSERS_H */
|
|
|
|
|