Skip to content

Instantly share code, notes, and snippets.

View qnighy's full-sized avatar

Masaki Hara qnighy

View GitHub Profile
def f(*)
yield 64 if block_given?
end
def g(*)
yield 32 if block_given?
end
f g((((((((((((((((((((((((((((((((((((((((((((((((
0
)))))))))))))))))))))))))))))))))))))))))))))))) do |x|
p x

parse.y

字句解析状態

基本の字句解析状態は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
@qnighy
qnighy / html-states.txt
Last active May 4, 2022 14:44
HTML basic parser states
<!-- 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>
@qnighy
qnighy / contentmodel.md
Created April 26, 2022 13:34
HTML elements in content model Venn diagram

https://html.spec.whatwg.org/multipage/dom.html#kinds-of-content

  • Node
    • Flow content (a, abbr, address, area (if it is a descendant of a map element), article, aside, audio, b, bdi, bdo, blockquote, br, button, canvas, cite, code, data, datalist, del, details, dfn, dialog, div, dl, em, embed, fieldset, figure, footer, form, h1, h2, h3, h4, h5, h6, header, hgroup, hr, i, iframe, img, input, ins, kbd, label, link (if it is allowed in the body), main (if it is a hierarchically correct main element), map, mark, MathML math, menu, meta (if the itemprop attribute is present), meter, nav, noscript, object, ol, output, p, picture, pre, progress, q, ruby, s, samp, script, section, select, slot, small, span, strong, sub, sup, SVG svg, table, template, textarea, time, u, ul, var, video, wbr, autonomous custom elements, text)
      • Sectioning (article, aside, nav, section)
      • Heading (h1, h2, h3, h4, h5, h6, hgroup)
  • Phrasing (a, abbr, area (if it is a descendant of a map element), audio, b, bdi, bdo, br, bu
@qnighy
qnighy / html.md
Last active April 17, 2022 01:04
HTML構文メモ
@qnighy
qnighy / zippy-type-predicates.ts
Created April 4, 2022 06:04
TypeScript type testing util less than in 40 lines
// 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 {
@qnighy
qnighy / juxtaposition-application.md
Created February 22, 2022 13:18
並置による関数適用に関する所感

並置による関数適用

並置による関数適用の善し悪しについて盛り上っているので、自分の意見を表明しておく。以下の2本立て。

  • 純粋に構文論的な議論 (構文拡張の余地を残す)
  • 意味論との関係での議論 (副作用の表示)

先に結論だけ書くと、私はどちらかといえば括弧による関数適用のほうが好みです。

そもそも並置による関数適用とは

"" ... "" + 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
@qnighy
qnighy / main.rs
Created March 28, 2021 01:00
stdin.scan() for competitive programming
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))
}