flex 기초 수기
containing only `%%'.
definitions
%%
rules
%%
user code
Some patterns:
`\123'
the character with octal value 123
`\x2a'
the character with hexadecimal value 2a
`(?r-s:pattern)'
apply option `r' and omit option `s' while interpreting pattern.
Options may be zero or more of the characters `i', `s', or `x'.
`(?# comment )'
omit everything within `()'. The first `)' character encountered
ends the pattern. It is not possible to for the comment to contain
a `)' character. The comment may span lines.\
`r/s'
an `r' but only if it is followed by an `s'.
`
an `r', but only in start condition `s'
`
same, but in any of start conditions `s1', `s2', or `s3'.
`<
an end-of-file.
`
an end-of-file when in start condition `s1' or `s2'
character class expressions:
[:alnum:] [:alpha:] [:blank:]
[:cntrl:] [:digit:] [:graph:]
[:lower:] [:print:] [:punct:]
[:space:] [:upper:] [:xdigit:]
[:^alnum:] [:^alpha:] [:^blank:]
[:^cntrl:] [:^digit:] [:^graph:]
[:^lower:] [:^print:] [:^punct:]
[:^space:] [:^upper:] [:^xdigit:]
The `{-}' operator computes the difference of two character classes, '{+}' does a union operation.
일치 하 는 방식 은 '최대 길이 우선' 입 니 다. 길이 가 같 을 때 앞 에 쓰 는 것 이 우선 입 니 다.
token 과 일치 할 때마다 이 token 은 전역 char 형 포인터 에 있 습 니 다.
yytext 에서 찾 을 수 있 습 니 다. 길 이 는 전역 int 에서 찾 을 수 있 습 니 다.
yyleng '에서 읽 기;이 token 에 대응 하 는 action 도 이때 실 행 됩 니 다.token 이후 텍스트 가 계속 검색 되 었 습 니 다.
actions special directives:
`ECHO'
copies yytext to the scanner's output.
`BEGIN'
followed by the name of a start condition places the scanner in the
corresponding start condition
`REJECT'
directs the scanner to proceed on to the "second best" rule which
matched the input (or a prefix of the input).
`yymore()'
tells the scanner that the next time it matches a rule, the
corresponding token should be _appended_ onto the current value of
`yytext' rather than replacing it.
`yyless(n)' returns all but the first `n' characters of the current
token back to the input stream, where they will be rescanned when the
scanner looks for the next match. `yytext' and `yyleng' are adjusted
appropriately
`input()' reads the next character from the input stream.
`YY_FLUSH_BUFFER()' flushes the scanner's internal buffer
`yyterminate()' can be used in lieu of a return statement in an
action.
Start Conditions:
`%s' or '%x' represents "inclusive" start conditions or "exclusive" start conditions.
`BEGIN(INITIAL)' is equivalent to `BEGIN(0)'
We can access the current start condition using the integer-valued `YY_START' macro, and Flex provides `YYSTATE' as an alias for `YY_START'
Multiple Input Buffers:
-- Function: YY_BUFFER_STATE
yy_create_buffer ( FILE *file, int size )
which takes a `FILE' pointer and a size and creates a buffer associated with the given file and large enough to hold `size' characters (when in doubt, use `YY_BUF_SIZE' for the size).
-- Function: void
yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer )
The above function switches the scanner's input buffer so subsequent tokens will come from `new_buffer'.
-- Function: void
yy_delete_buffer ( YY_BUFFER_STATE buffer )
is used to reclaim the storage associated with a buffer.
-- Function: void
yypush_buffer_state ( YY_BUFFER_STATE buffer )
This function pushes the new buffer state onto an internal stack.
-- Function: void
yypop_buffer_state ( )
This function removes the current state from the top of the stack, and deletes it by calling `yy_delete_buffer'.
-- Function: void
yy_flush_buffer ( YY_BUFFER_STATE buffer )
This function discards the buffer's contents
-- Function: YY_BUFFER_STATE
yy_new_buffer ( FILE *file, int size )
is an alias for `yy_create_buffer()'
`YY_CURRENT_BUFFER' macro returns a `YY_BUFFER_STATE' handle to the current buffer. It should not be used as an lvalue.
-- Function: YY_BUFFER_STATE
yy_scan_string ( const char *str )
scans a NUL-terminated string.
-- Function: YY_BUFFER_STATE
yy_scan_bytes ( const char *bytes, int len )
scans `len' bytes (including possibly `NUL's) starting at location `bytes'.
Note that both of above two functions create and scan a _copy_ of the string or bytes.You can avoid the copy by using:
-- Function: YY_BUFFER_STATE
yy_scan_buffer (char *base, yy_size_t size)
the last two bytes of which _must_ be `YY_END_OF_BUFFER_CHAR' (ASCII NUL). These last two bytes are not scanned; thus, scanning consists of `base[0]' through `base[size-2]', inclusive.
-- Data type: yy_size_t
is an integral type to which you can cast an integer expression reflecting the size of the buffer.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
⭐️ Flex & OpacityThe flex CSS shorthand property sets how a flex item will grow or shrink to fit the space available in its flex containe...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.