Skip to content

Instantly share code, notes, and snippets.

View cognominal's full-sized avatar

Stéphane Payrard cognominal

View GitHub Profile
@cognominal
cognominal / slangs.pod
Last active March 25, 2021 22:20
proposal about slangs
=begin pod
=head1 Slangs
This material complements existing docs about slangs. Mainly, it
describes the consequences of using C<~slang>, especially writing the
intuitive <~slang.rule> instead of the cryptic C<LANG('slang',
'rule')>. Also in C<&LANG> implementation, the relationship between
grammar and actions is hardwired which is plain wrong:
my $*ACTIONS := %*LANG{$lang ~ '-actions'};
@cognominal
cognominal / dabblet.css
Created April 13, 2016 07:35
Intrinsic sizing
/**
* Intrinsic sizing
*/
figure {
max-width: 2000px;
max-width: min-content;
margin: auto;
}
@cognominal
cognominal / dabblet.css
Created April 2, 2016 06:11 — forked from csssecrets/dabblet.css
Typing animation
/**
* Typing animation
*/
@keyframes typing {
from { width: 0 }
}
@keyframes caret {
50% { border-right-color: transparent; }
@cognominal
cognominal / AST.pod
Last active June 2, 2017 16:42
slast slang, an AST DSL, at last.

caveat emptor

This document supposes you know NQP and the QAST API. It is in state of flux so it contains both raw thoughts, inconsistencies and fossils. Parts of the doc that are more glossary like probably have a more consistent terminology.

The implementation is not yet public or in very experimental form in dirty git branches in https://github.com/cognominal/nqp. Pod formating is missing

@cognominal
cognominal / sha1.p6
Last active December 11, 2015 19:41
sha1 hash
subset Sha1 of Str where *.chars == 40 and m:i/<[A..F 0..9]>/;
class Sha1H does Associative {
has %!h;
method AT-KEY(Sha1 $_) { %!h{ .lc } };
method ASSIGN-KEY(Sha1 $_, $v) { %!h{ .lc } = $v }
}
my %h is Sha1H;
my $sha1 = '64B0F6C3681E428CCE2EB830B05F27B3D7ED643E';
@cognominal
cognominal / print.p6
Created December 4, 2015 18:49
superseding .print
use MONKEY-TYPING;
supersede class IO::Handler {
my %escape = < \< &lt \> &gt >;
multi method print(IO::Handle:D: Str:D \x --> True) {
my &line = { "<div><$_></div></br>" }
[~] x.lines.map: { line [~] .comb.map: %escape{$_} // * }
}
}
@cognominal
cognominal / dot.p6
Last active October 3, 2015 22:03
create a call graph
my $test = q:to<END>;
void a();
void a(
) {
b();
c();
}
END
@cognominal
cognominal / test.p6
Created August 11, 2015 00:10
should the .a action method should be called knowing the match is in an assertion that does not contribute to the TOP match
grammar A {
token TOP { a <?before <a> > }
token a { a }
}
class A-actions {
method TOP($/) { say('yea') }
method a($/) { say('oops') }
}
@cognominal
cognominal / check-param.p6
Created August 2, 2015 05:18
tentative example of ParamTypeCheck use
use QAST:from<NQP>;
use nqp;
my $ast := QAST::Block.new(
QAST::Op.new(:op<call>,
QAST::Block.new(
QAST::Var.new(:name<$a>, :scope<param>, :decl<var>,
QAST::ParamTypeCheck.new(
QAST::Op.new(:op<istrue>, QAST::Var.new(:name<$a>, :scope<param>)))),
QAST::Op.new(:op<say>,
@cognominal
cognominal / error.txt
Created August 1, 2014 17:52
panda and module loader seems to be be not in sync
bash-3.2$ perl6 bootstrap.pl
==> Bootstrapping Panda
==> Fetching File::Find
==> Building File::Find
Compiling lib/File/Find.pm to mbc
==> Testing File::Find
t/01-file-find.t .. ok
All tests successful.
Files=1, Tests=10, 2 wallclock secs ( 0.03 usr 0.01 sys + 2.26 cusr 0.12 csys = 2.42 CPU)