You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Instantly share code, notes, and snippets.
Chubak Bidpaa
Chubek
Worked at @Cherry-Labs and @OctoShrew. Worked with a lot of people over the years. I am seeking a job in systems. If you know of any venue, do tell.
The 'map' function is the same as Kleene star (regex *)!
The map function and Kleene Star (regex *) are the same! (homomorphic)
In functional languages, and most modern imperative languages which implement functional features, we often have a map function. In λ-> (simply-typed λ-calc) we could describe the type of this function as:
Imperative representation of Peyton Jones' "enriched" λ-Calc language
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Pascal-Syntax.ml: ISO Pascal's syntax formalized in OCaml type system
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TSV datasets of ROFF (Requests, Escapes, NRs, SRs, Characters)
This Gist contains a total of 5 tab-separated values files (TSV), and they list:
ROFF-Requests.tsv -> ROFF requests, this file is the only one where the structure is taken from the manual downloaded from TROFF's website authored by the late Joe Ossanna and the legendary BWK, refer to the listing in the manual to get a sense of what each column means (name;args;default;default arg values;flags;description).
ROFF-Escapes.tsv -> The escape sequences --- those accepting arguments and those variable have been marked;
ROFF-NRs.tsv -> The built-in numeric registers (which GROFF just calls registers);
ROFF-SRs.tsv -> The built-in string registers (which GROFF just calls strings);
ROFF-Chars.tsv -> The pre-defined character list;
Important thing to note is, these are the listings as defined by Ossanna and Kernighan. GNU additions have not been accounted for. Whatever Heirloom DocTools adds neither. This is pure ROFF!
tokenize-ebnf.scm defines in it a tokenizer (aka lexer, or scanner) for EBNF. This is compliant to ISO but several other meta-structures such as RegExp (/.../) are also consumed. Comments starting withg # are tokenized, consumed and appended to the token stream. Do with them as you wish!
This was an excercise at Scheme --- and so much more, an excercise at hand-rollling lexers in an stateless language with functional paradigm built in.
You can use this to, for example, translate EBNF to LaTEx, HTML, PostScript, ROFF --- or maybe define a parser for it, and convert it to Yacc, PEG, ANTLR, Flex, Re2C, etc.
tokenize-ebnf.scm is a tokenizer for EBNF in Scheme. Although it is [almost] useless without a parser --- and that is what I have issue arriving at!
I want this to be an educational experience, so I don't wish to resort to define-sytax macros. Otherwise it would have been much simpler. Scheme's macros are a cheatcode tbqh. In fact, CLisp's macros are cheatcode too. Read 'Let Over Lambda' by Doug Hoyte. If I use macros here, I have doomed myself to be a Scheme Simp (Scsimp?) forever. I just don't want that.
So what I want is your help in creating a parser for EBNF that keeps in mind the recursive, context-free nature of it. EBNF was not meant to be parser, it was never created as an applicable language. I have loooked around and there are not that many parsers for EBNF around. It's a meta-grammar meant to be leared at and hooted at. Not parsed.
And I don't really need to parse it. I wanna write an ebnf2ps program. So this is enough really.
The problem is the 'nested' or 'recursive' nature of EBNF. For
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters