The example presented here shows how one would use groc
to create
an internationalized die-roll application:
$ roll
You rolled a one
$ roll
call plug#begin() | |
Plug 'tomasr/molokai' | |
Plug 'itchyny/lightline.vim' | |
call plug#end() | |
filetype plugin on | |
set mouse=a |
# .bashrc | |
# Source global definitions | |
if [ -f /etc/bashrc ]; then | |
. /etc/bashrc | |
fi | |
# User specific environment | |
if ! [[ "$PATH" =~ "$HOME/.local/bin:$HOME/bin:$HOME/code/tools/text-tools/bin" ]] | |
then |
#include "unicode.h" | |
#include <stdint.h> | |
#include <stddef.h> | |
int is_valid_char(uint32_t ch) | |
{ | |
return ch < 0xd800 || ch > 0xdfff; | |
} | |
int is_combo_char(uint32_t ch) |
#include <cheax.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
int main(void) | |
{ | |
int result; | |
CHEAX *c = cheax_init(); |
private static int getch(byte[] buf, ref int idx) | |
{ | |
byte nxt = buf[idx++]; | |
byte mask; | |
int remunits; | |
if ((nxt & 0x80) == 0) { | |
mask = 0; | |
remunits = 0; | |
} else { | |
byte lead = 0xC0; |
%code requires { | |
#include "types.h" | |
#include <stddef.h> | |
#include <stdio.h> | |
} | |
%code { | |
int yylex(); | |
void yyerror(ASTFileElement **f, const char *msg); | |
} |
use v6; | |
unit module CTokens; | |
grammar CTokens::Token is export { | |
token TOP { | |
[ | |
<preproc> | | |
<comment> | | |
<line-comment> | |
#include<stdio.h> | |
#define b ;break;case | |
#define w (c=getc(f)) | |
int c,x=1,y,u,r=1;char m[30000],*s=m;int main(int i,char**j){FILE*f=fopen(j[1],"r");while(w-'$'){++x;y+=c=='\n'?x=1:0;}for(;;){switch w{case'#':return fclose(f);b'\\':i=u;u=-r;r=-i;b'/':i=u;u=r;r=i;b'}':s++b'{':s--b',':*s=getchar()b'.':putchar(*s)b'^':u=*s?(r=0)+1:u;b'<':r=*s?(u=0)-1:r;b'v':u=*s?(r=0)-1:u;b'>':r=*s?(u=0)+1:r;b'+':++*s;b'-':--*s;b'!':x+=r;y-=u;}x+=r;y-=u;rewind(f);for(i=0;i<y;i+=w=='\n');for(i=0;i<x;++i)w;}} |