- Feature Name: syntax_tree_patterns
- Start Date: (fill me in with today's date, YYYY-MM-DD)
- RFC PR: (leave this empty)
- Rust Issue: (leave this empty)
Introduce a DSL that allows to describe lints using syntax tree patterns.
use std::io::{self, Read}; | |
pub trait MyRead: Read { | |
#[inline(always)] | |
fn read_to_buf<const N: usize>(&mut self) -> io::Result<[u8; N]> { | |
let mut buf = [0; N]; | |
self.read_exact(&mut buf)?; | |
Ok(buf) | |
} | |
} |
Panic context: | |
> | |
version: 796bfccac 2021-09-03 dev | |
request: codeLens/resolve CodeLens { | |
range: Range { | |
start: Position { | |
line: 0, | |
character: 3, | |
}, | |
end: Position { |
I've been thinking about file formats lately. When looking at different formats, it seems like there are common concepts used in many of them, the main ones being **textual data** and **hierarchy**. These concepts are usually implemented by stacking different encoding layers. For example, the SVG format can be seen as the following stack of abstractions: `SVG -> XML -> UTF-8 -> Binary`. In this case, the hierarchy is provided by XML and the encoding of textual data is done in XML and UTF-8. You might be wondering why textual data is handled both in XML and UTF-8. The reason for this is that one cannot simply paste a UTF-8-encoded string into an SVG file and expect it to work. A lot of strings would contain characters that have a meaning to the surrounding markup. The common solution to this is to use escape characters that indicate that the character following them should not be treated as markup. But other than that, textual data is encoded in UTF-8. | |
Having to handle textual data encoding at two levels in |
<head> | |
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Ubuntu+Mono" /> | |
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/tonsky/[email protected]/distr/fira_code.css"> | |
<style> | |
textarea { | |
font-family: Fira Code, monospace; | |
font-size: 12pt; | |
} | |
#measure { |
// tested using nix 0.15.0 | |
extern crate nix; | |
use std::path::Path; | |
use nix::pty::{posix_openpt, grantpt, unlockpt, ptsname}; | |
use nix::fcntl::{OFlag, open}; | |
use nix::sys::{stat, wait}; | |
use nix::unistd::{fork, ForkResult, setsid, dup2}; | |
use nix::libc::{STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO}; |
public class Quadratzahlen | |
{ | |
public static void main(String[] args) | |
{ | |
// Aufgabe: gib die ersten zehn Quadratzahlen auf der Konsole aus. | |
// | |
// Korrekte Ausgabe: | |
// 1 4 96 16 25 36 49 64 81 100 | |
import subprocess | |
def to_hex(byte_string): | |
return " ".join("{:02x}".format(b) for b in byte_string) | |
def to_bin(byte_string): | |
return " ".join("{:08b}".format(b) for b in byte_string) |