CCS下makefile的编写

2019-01-26 17:11

CCS makefile文件编写

前期预备知识

Alternation and Grouping

1 | 用法 PUBLIC|PRIVATE :表示匹配单词为PUBLIC或者PRIVATE 2 空格以用法 PUBLIC (void|DWORD) :

3 ^ 表示一行的开始处, [ \\t] 表跟着多个空格或tabs.

例子:^PUBLIC[ \\t]+(void|int|long|DWORD) It matches, at the beginning of a line, the word \followed by one or more spaces or tabs, followed by any one of the following words: \

Beginning and Ending of Line

^PUBLIC: 一行开头是PUBLIC。 \\)$: 一行结尾是圆括号。

^\\)$ 这一行就只有一个圆括号。

Character Classes

[AEIOUYaeiouy] : matches any vowel, whether upper or lower case. [0-9]will match any character between 0 and 9.

^ 如果不用在开头字母上, 放中间表示 it just adds the up-caret to that class. You may use it as a shorthand method of saying \for the following: rather than specifying a large character class. For example, [^$.|(){}*+?^] matches anything except the eleven characters following the up-caret.

Escape Sequences 转义字符

Escape Meaning \\n Newline ( or , depending on how it is defined for the document) \\t Tab \\b [Ctrl]-[H] (backspace) \\r Carriage return

\\f form feed \\nnn Octal value between 0 and 0377. \\xnn Hexadecimal digit between 0x00 and 0xFF \\m The literal character m.

Note: When using escape sequences in C language source code, each backslash must also be escaped with another backslash. The resulting pattern specification is often unaesthetic.

Iteration Qualifiers

the * matches any number of occurrences, the + matches one or more, and the ? matches zero or one. 特例:

\\t* The example above will match any number of consecutive tabs, including none. By itself, it is not very useful to match none of something. As part of a larger regular expression, it could be quite useful. For our purposes here, the following might be preferable:

\\t+ This example matches one or more consecutive tabs. The tab is represented as \\t, and the plus sign says \ To match whitespace, we need to match spaces too. We don't know what order the spaces and tabs will come in, and we don't know how many there will be. These are signs that we need a character class.

[ \\t]+ The example above uses a character class containing a space and a tab. The + sign following it means that this Regular Expression will match any combination of spaces and tabs, so long as there is at least one space or tab.If you wanted to match the whitespace within a function call, where you knew there might be one space or tab, or there might be none, your expression could look like this:

\\([ \\t]? This example searches for a left parenthesis followed by zero or one spaces or tabs. Since the left parenthesis is a meta-character it is necessary to escape or quote it with a preceding backslash. The \\t we have used before to represent a tab character. The question mark says \

Matching a Character

The basic unit of a regular expression is matching a single character. You can match a single character in one of three ways: Literally,

Ambiguously, or

With a Character Class.

You may match a character literally by using the character itself or the appropriate escape sequence. If matching a character literally is too limiting, you may match ambiguously, by using the dot ( . ) metacharacter. If a literal character is too narrow a match and the dot is too broad a match, a character class can be used for anything in

between.

Placing the Cursor

The escape sequence that specifies cursor position is \\c. An example of its use follows:

singletons\\[\\c.*\\]

This example places the cursor at the beginning of whatever text is contained between the left and right square brackets. The square brackets are metacharacters and are therefore escaped. This cursor positioning facilitates editing the contents of the square brackets.

Reference Groups and Replacement Strings

Regex Examples

Regular Expressions Tips

Regular Expression Syntax

Character Description

\\ Marks the next character as special. To define a special character in a regular expression, precede the special character with the backslash character. Example: The regular expression /n/ matches the character n. The regular expression /\\n/ matches a linefeed or newline character.

^ Matches the beginning of input or line. In this implementation, this character cannot be defined in character set.

$ Matches the end of input or line. In this implementation this character cannot be defined in a character set.

* Matches the preceding character zero or more times. In this implementation cannot be defined if only one character is specified in the regular expression. That means that /zo*/ matches z and zoo, but /z*/ will match nothing because only one character has been specified.

+ Matches the preceding character one or more times.

? Matches the preceding character zero or one time. In this implementation cannot be defined if only one character is specified in the regular expression.

. Matches any single character except '\\n'.

(pattern) Matches the pattern and remembers the match. The matched substring can be retrieved by using '\\0'-'\\9' in the regular expression, where '0'-'9' are the numbers of the pattern. Example: Regular expression '(re).*\\0s+ion' will match 'regular expression'. First, the pattern ?re)?matches the first two letters of 憆egular expression?and the pattern is remembered with index 0. The pattern '*' matches 'gular exp' in 'regular expression'. The pattern 慭0?retrieves the pattern that has been remembered with index 0, and this 're' matches the second occurrence of 're' in 'regular expression'. Finally, the pattern 's+ion' matches 'ssion'.

x|y Matches either the character 'x' or 'y'. You can combine more than two characters. Example: 'x|y|z'.

{n} Means the preceding character will match exactly n times (nonnegative). {n,} Means the preceding character will match at least n times (nonnegative).

{n,m} Means the preceding character will match at least n times and at most m times (both nonnegative).

[xyz] A character set. Matches any one of the enclosed characters.

[^xyz] A non-matching character set. Matches any character that is not in the set.

\\b Matches a word boundary, that is, the boundary between any character excluding space characters (\

\\B Matches a non-word boundary. Matches any boundary between space characters or between non-space characters. \\d Matches any digit /0-9/ \\D Matches any non-digit.

\\e Marks the start position of text to extract; used in conjunction with \\E.

\\E Marks the end position of text to extract; used in conjunction with \\e. If the \\E is not supplied, the end of line ($) will be used as the end position.

\\f Matches a formfeed.

\\n Matches a newline character.

\\r Matches a carridge return character. \\s Matches any white space character. \\S Matches any non-white space character. \\t Matches a tab character.

\\v Matches any vertical tab character.

\\w Matches any word character including underscore. [A-Za-z0-9_]

\\W Matches any non-word character (any character that does not match \\w).

\\num Where num is a value between 0 and 9. Matches remembered pattern. (See description of pattern.)

/n/ Where n is a value between 1 and 255. Matches supplied in n ASCII code.

Examples

\ Matches \

\ Matches \but only returns the characters between \

\Extracts all source files after the SOURCE=macro definition. \Extracts all the source dependencies in a makefile. \Extracts all macro definitions.

Searching for control characters (binary/hex data)

Control characters can be used in both search and replacement patterns. Any byte value can be specified as part of a pattern. Perform the following steps to search for or replace binary or hex values.

1. Go to Edit 郌ind (or Find/Replace, Find in Files, Replace in Files). 2. Turn on Regular Expressions in the appropriate dialog. 3. Then use the \\x notation to specify hexadecimal values.

Examples:

To search for the form feed character, use this string: \\x0c

(That's backslash x zero c.)

Make sure there are two digits following the x.

To search for two consecutive bytes by hexadecimal value, string them together like this:

\\x0c\\x0d

If you are replacing EOL characters, the following information will help to understand how CodeWright views and deals with End of Line characters.

Generally, using '\\n' for matching or replacing line ends is the suggested method in CodeWright (the '\\' must be doubled when used in code). However, a special case is made for searching for and replacing hexadecimal 0D and 0A characters. Since these


CCS下makefile的编写.doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:外墙保温分项工程质量验收记录表

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: