基本の字句解析状態はlex_state_bits, lex_state_eにある。
EXPR_BEG
- 式の開始位置
EXPR_END
- リテラル・識別子の終了位置
def f(*) | |
yield 64 if block_given? | |
end | |
def g(*) | |
yield 32 if block_given? | |
end | |
f g(((((((((((((((((((((((((((((((((((((((((((((((( | |
0 | |
)))))))))))))))))))))))))))))))))))))))))))))))) do |x| | |
p x |
基本の字句解析状態はlex_state_bits, lex_state_eにある。
EXPR_BEG
EXPR_END
Host example.com | |
Port 22 | |
User qnighy | |
Host github.com | |
CheckHostIP no | |
Host * | |
# Share connections among processes | |
ControlMaster auto | |
ControlPath ~/.ssh/mux-%r@%h:%p | |
ControlPersist 10 |
<!-- initial --> | |
<!-- Ignored: whitespace --> | |
<!-- Relocated: comment --> | |
<!DOCTYPE html> | |
<!-- before html --> | |
<!-- Ignored: whitespace --> | |
<!-- Ignored: DOCTYPE --> | |
<!-- Ignored: end tags other than </head>, </body>, </html>, </br> --> | |
<!-- Relocated: comment --> | |
<html> |
https://html.spec.whatwg.org/multipage/dom.html#kinds-of-content
https://html.spec.whatwg.org/multipage/parsing.html#tokenization
state | example | 備考 |
---|---|---|
data | "" |
基本の状態 |
RCDATA | "<title>" |
文字参照と閉じタグのみ有効 |
RAWTEXT | "<xmp>" |
閉じタグのみ有効 |
script data | `" |
// Copyright 2022 Masaki Hara | |
// Licensed in MIT https://opensource.org/licenses/MIT | |
type Predicate<T> = { | |
co?: (() => T) | undefined; | |
contra?: ((x: T) => void) | undefined; | |
}; | |
function expectType<T>() { | |
return { |
"" ... "" + script data | |
"." ... "." + script data | |
"<" ... "" + script data less-than sign | |
"</" ... "" + script data end tag open | |
"</." ... "</." + script data | |
"</a" ... "" + script data end tag name | |
"</script " ... "" + before attribute name | |
"</foo " ... "</foo " + script data | |
"</script/" ... "" + self-closing start tag | |
"</foo/" ... "</foo/" + script data |
use std::io::{self, BufRead}; | |
use std::str::{self, FromStr}; | |
fn from_buf<T: FromStr>(buf: &[u8]) -> io::Result<T> | |
where | |
T::Err: std::error::Error + Send + Sync + 'static, | |
{ | |
let s = str::from_utf8(buf).map_err(|e| io::Error::new(io::ErrorKind::InvalidInput, e))?; | |
T::from_str(s).map_err(|e| io::Error::new(io::ErrorKind::InvalidInput, e)) | |
} |