开发者

Auto complete in c [Codemirror]

You can see this being used to autocomplete local JavaScript variables in http://codemirror.net/2/demo/complete.html But,How i use this 开发者_开发技巧autocomplete in c language?

How i edit this code? http://codemirror.net/demo/complete.js


Are you talking about editing the script to auto-complete C in the browser?

First you need to identify the where local variables in C are defined. You're looking for keywords like int float long or patterns like type_name identifier_1 = value, identifier_2;

The next thing you need to do is identify the function parameters. The pattern you're looking for is

return_type function_name(parm1, param2){
    // current code
}

Last you need to include constants created with #define and variables defined in file scope (C) or global scope (C++).

type_name identifier = value;
#define constant value

// Outside of any sort of scope

/* something  */{

}

It would be difficult to just edit the script that works on JavaScript because the two languages behave differently and have different rules. If you need some help of the ways to parse the data from C and other languages using JavaScript you might look into google-prettify which is a syntax highlighting script.

Good luck.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜