ChubakPDP11+TakeWithGrainOfSalt

@ChubakPDP11+TakeWithGrainOfSalt@programming.dev
42 Post – 65 Comments
Joined 5 months ago

I really recommend creating a compiler or an interpreter from scratch, don't even use an IR like LLVM or MIR. Just hack and slash your way though a C compiler, it's the simplest language most people know. Don't care about 'optimization' at first, fuck optimization. Just grab Yacc/Lex or a PEG parser generator that works with the language you like most and have ot generate assembly code for simple expressions. Like, make a bc(1) native compiler! Interprets are fun too. You can use VMGEN to generate a superfast VM in C, and then bind it to another language using SWIG.
Also never imagine usability. Noobdy is going to use your C compiler for any serious work. It's just for education. Post it online to receive feedback.

You cna start by writing DSLs. For example, I am implementing the ASDL language from this old paper.

Also if you are going to do it as an example in your resume, just stop. Nobody cares, because it's a trivial task to write a compiler, even if you write backend, forntned, and the LP yourself! Do something money-loving people loike, like making some bullshit mobile app that tracks your gym sweat volume.

For anyone seeking to write their own database, I have one recommendation: the Tokyo Cabinet Library.

Tokyo Cabinet abstracts away all the needs of writing your own serializers and deserilizers for binary formats. You can have hashtable databases , B+ trees and everything else all prepared for you under one roof.

Of course that is if you have brain, and don't use a text storage format like JSON. If you use shit like JSON and YAML --- and add potentially hundreds of millisceonds of parsing time just to serialize data from text into machine-readable binary, then please submit your name and address to my council so we can get rid of you when we own the world.

Cleansing of the undesirables aside (seriously, give me ONE good thing about text storage formats! They are EXCHANGE formats, not STORAGE formats!), Tokyo Cabinet is written in C so you can easily bind it with SWIG. But there's probably bindings around if you look.

People are designing languages with JetBrains MPS and I am making an AWK interpreter in C with Yacc, Lex and my own implementation of ASDL. Why do I do this to myself? It seems like the technology I like is way behind. Like C is a language created for freaking mini-computers like VAX and PDP-11 and I still use it? I knew about MPS, I just felt a strong dislike towards it. Now that I am no longer a pill addict, I have to reconsider the technology I choose to implement my stuff. C lacks portability, and QoL features.

(Psyche! All you n000bz can be stuck with your Fischer-Price toys --- I'll do it MY way, the 70s WAY!!!!1)

2 more...

My man we have UNIX because PDP-11 was expensive!

You don't need any garbage 3rd party packages. Just use ctypes.

Read the documentation for ctypes. You can use any native object in Python the way you do in C using ctypes.

Whatever you do, don't trust some god-forsaken 3rd party package. I think people have forgotten to be clever and resourceful these days. A binary object is itself a package, why would you use s another package to communicate with it?

Here's how you can import libc into Python:

from ctypes import CDLL

libc = CDLL(None)

Just pass it path to the binary object that holds the symbols for GPIO.

Some tricks. Here's how you can use libc to make a syscall in Python:

libc = CDLL(None)

TIME_NR = 

libc.syscall(TIME_NR)


I think that happens when app developers learn2optimize. Stop using interpreted bytecode languages on small processors!

9 more...

So I am going to explain the concept of macro preprocessors to you --- m5.awk is a macro preprocessor, so is m4 so is GPP so is C's CPP, so is my Ekipp and so is my AllocPP.pl. They all work like this:

1- Frank Frankis (hereby referred to as FF) creates a file called my-file.randext --- randext here meaning that macro prerpcoessors work on all kind of files, be it a C code, a Python code, an HTML template, your tax files, your notes to your GF, your angry letter to your boss, etc;

2- There are dozens and dozens of uses for a macro preprocessors, but let's say FF wants to obliterate two birds with one sniper shot, he wishes to write a manual for his new Car XAshtray (TM), in HTML and Markdown, but he wants it to be contained within one single file -- and he wishes to reuse certain fragments of text, certain HTML tags, certain Markdown syntaxes, to be 'reusable', just like a 'function' is reusable piece of code in an imperative language (but not a functional language!) or how a template works in C++, etc.

3- FF enters the file with his favorite text editor. He defines these 'functions', which are the 'macro' part of a macro preprocessor. Think what 'macro' means. It means 'big picture' basically. I think the better term here is 'meta'. These two words have a close relationship in the English language, don't they?

Now let's see what macro preprocessor FF uses. Since GPP is really similar in syntax to C's preprocessor (at least with default settings) let's use GPP. I would use my Ekipp here but I honestly have forgotten the syntax (believe it or not, creating a language does not mean you are good at it).

#ifdef __HTML__
#define TITLE <h1>My Car XAshtray Manual</h1>
#define SUBTITLE <h5>Throw your ash on me</h5>
#define BOLDEN(text) <b>text</b>
#elif __MARKDOWN__
#define TITLE  \# My Car XAhtray Manual
#define SUBTITLE \#\#\#\#\# Throw your ash on me
#define BOLDEN(text) **text**
#else
#error "Must define a target language"
#endif

FF keeps defining these. Now comes writing the actual manual.

Keep in mind that GPP stands for 'Generic Preprocessor', it's a text macro prerpcoessor and not a language preprocessor like CPP (C's preprocessor) is. m4 and Ekipp are like that. My AllocPP.pl is a language preprocessor, it preprocesses C. So now, this means FF can now freely treat my-file.randext as a text file, with a 'language', the Macro Preprocessor language, defining the output (I'll talk about what I mean by 'output' soon).

So he writes his manual:

TITLE
SUBTITLE

Hello! Are you okay? Why did you buy this ashtray? BOLDEN(ARE YOU OKAY?). In this manual I will teach you how to use my ashtray...
...

Replace the last ellipse with rest of the text, the Car Ashtray manual.

Now, FF needs to 'preprocess' this text file. This is, well, the 'preprocessing' part of a macro preprocessor. It's like compiling a program with a compiler, except you are compiling text-to-text instead of text-to-binary.

gpp -D__MARKDOWN__ my-file.randext > my-manual.md
``
But what happened at `-D__MARKDOWN__`? I think you have already guessed. In the 'program' we asserted if '__MARKDOWN__' is 'defined', then then define those macros as Markdown, else HTML. We can also define a macro with a value:

gpp -DMyMacro=MyValue my-file.randext > my-manual.md


Now, GPP has more built-in macros like `#ifdef`, they are called 'meta macros` (as opposted to the macros you yourself define). There's `#include` which includes a file. There `#exec` which executes a shell command. Etc etc.

Now, you can read more about GPP on its Github. I was in touch with its maintainer, Tristan Miller, very recently when I showed him my Ekipp. He has made a new version of GPP so don't install it from your package manager like apt, install it from source because the release is very recent and these packages take ages to be updated. GPP is just one C file, very neat and clean. Read the man page (`man 1 gpp`) for more info.

m4 and m5 or Ekipp etc, as I said, are too, generic text preprpocessors. My Ekipp has this feature where, you can treat any program like PHP works:

#! delimexec $ ''awk "{ print $1; }"'' | <== foo bar ==>


This will run the AWK program in the file.

You can install my Ekipp using these commands:

sudo apt-get install libreadline-dev libgc-dev libunistring-dev wget -qO- https://raw.githubusercontent.com/Chubek/Ekipp/master/install.sh | sudo sh


Bring up `man 1 ekipp` to learn about it.

Keep in mind that Ekipp has some bugs. I will have to completely rewrite it honestly but I am busy making an implementation of ASLD (github.com/Chubek/asdl) and I am working on an implementation of AWK and later C so a macro preprocessor does not bite me really.

Thanks.




Understood. Thanks. I really wish they would allow people to upload their own games. Kinda like that old website (Newgrounds? idk).

I'm a simp for Alan Kay and I goon to his SnappChat, but I subscribe to Andrew Appel's OnlyFans (along with many others), so I did not look much into SmallTalk when it comes to '70s languages'. I guess I should do that. Thanks. I could have never put two and two together to realize Python uses prototypes. This blows my mind. Funny thing is just the other day I wrote JavaScript's grammar. https://gist.github.com/Chubek/0ab33e40b01a029a7195326e89646ec5

I guess I still got a lot to learn so better get moving. I guess by 'full semantic analysis' I meant do a a full type analysis 'before' you emit the bytecode, not after. What is the protocol here exactly? I have seen several variants and supersets of Python that do an ML-style type analysis. They achieve it via the `NAME [ ':' TYCON ]' syntax so the regular Python interpeter would still work.

So thanks. Learned something with your post.

3 more...

Thanks a lot my good man. Is this Monte? https://github.com/monte-language/monte I can't find the source code?

Can you tell me what you think of the code my implementation emits when you got the time? Is it good, bad, medicore etc?

So when you're building a language, should you always use a builder for the AST specifications? Becuase I figure, you don't need that in a language like Haskell or OCaml right?

I currently have 3 projects I ping-pong.

1- Marsh, a POSIX shell in C; 2- Awk2X; a translator of AWK to several languages, like C, Python Rust etc. This one is in Haskell 3- Cephyr; a C compiler in OCaml

For Marsh, I am stuck in the job control section. I just can't seem to find a flow for redirecting input and output. I think I am striking a balance though. I revised the job control like 10 times, literally 10 times.

But for Awk2X and Cephyr, I am kinda stuck at defining the AST. I learned Haskell just last night and I made this AST. I am not 'stuck' really, I will move on from it soon.

data UnaryOp
  = Prefix PrefixOp
  | Postfix PostfixOp
  deriving (Show)

data PrefixOp
  = PrefixIncr
  | PrefixDecr
  | Plus
  | Minus
  | Not
  deriving (Show)

data PostfixOp
  = PostfixIncr
  | PostfixDecr
  deriving (Show)

data BinaryOp
  = Add
  | Sub
  | Mul
  | Div
  | Mod
  | Eq
  | Ne
  | Gt
  | Ge
  | Le
  | Lt
  | And
  | Or
  deriving (Show)

data Lvalue
  = Unfixed String
  | Fixed String String
  deriving (Show)

data Factor
  = Constant Constant
  | Lvalue Lvalue
  deriving (Show)

data Constant
  = String String
  | Integer Int
  | Float Float
  | Regex String
  deriving (Show)

data Expr
  = Unary UnaryOp Factor
  | Binary Factor BinaryOp Factor
  | Ternary Expr Expr Expr
  | StrCat [Expr]
  | Delete Expr
  | Call String [Expr]
  | Assign Lvalue Expr
  deriving (Show)

data Stmt
  = Express Expr
  | For Expr Expr Expr Stmt
  | ForIn Lvalue Lvalue Stmt
  | DoWhile Stmt Expr
  | While Expr Stmt
  | If Expr Stmt [(Expr, Stmt)] (Maybe (Expr, Stmt))
  | Return (Maybe Expr)
  | Break
  | Continue
  | Compound [Stmt]
  deriving (Show)

data Pattern
  = Begin
  | End
  | Expr Expr
  | ExprPair Expr Expr

data PatternAction
  = WithPattern Pattern [Stmt]
  | JustAction [Stmt]

data FunctionDefn = FunctionDefn
  { name :: String,
    params :: [String],
    body :: [Stmt]
  }

data Element
  = PattAct PatternAction
  | FnDef FunctionDefn

newtype Program = Program [Element

Now for Cephyr, this one is a bit more complex. Before Cephyr I attempted to make a C compiler several times, and every time I got stuck at the AST.

The problem is, I wanna use OCaml's modules in the AST. But I don't know how? I just said fuck it and used top-level types. I am here currently:

type const_expr
type type_decl
type unary_op
type binary_op
type expr
type stmt

type literal =
    ConstLiteral of const_lit | CompoundLiteral of compound_lit

and const_lit =
  | IntConst of int * int_suffix option
  | FloatCOnst of float * float_suffix option
  | CharConst of char * charset_prefix option
  | StrConst of string * charset_prefix option
  | IdentConst of string * const_expr

and int_suffix =
    Long | LongLong | Unsigned | UnsignedLong | UnsignedLongLOng

and float_suffix =
    Double | LongDouble

and charset_prefix =
    Local | U8 | U16 | U32

and compound_lit =
  | ArrayCompound of init_type * init_item list
  | StructCompound of init_type * init_item list
  | UnionCompound of init_type * init_item list

and init_item =
  | RegularInit of expr
  | DesignatedInit of designated_init * expr

and designated_init =
  | ConstExpr of const_expr
  | ConstExprPair of const_expr * const_expr
  | Ident of string

and init_type = type_decl


type const_expr =
  | UnaryConstExpr of { factor: literal; op: unary_op; }
  | BinaryConstExpr of { left_factor: literal; right_factor: literal; op: binary_op; }


type primary_factor =
    Identifier of string | NestedExpr of expr | Literal of literal

and expr =
  | Primary of primary_factor
  | Unary of { factor: primary_factor; op: unary_op; }
  | Subscript of { factor: primary_factor; op: subscript_op; }
  | Binary of { left_factor: expr; right_factor: expr; op: binary_op; }
  | Ternary of { cond: expr; if_true: expr; if_false: expr; }
  | Assignment of { lvalue: expr; rvalue: expr; op: assign_op; }

and prefix_unary_op =
  | Negate            
  | LogicalNegate     
  | BitwiseNot        
  | AddressOf         
  | Dereference       
  | PreIncrement      
  | PreDecrement      

and postfix_unary_op =
  | PostIncrement     
  | PostDecrement

and unary_op =
  | PrefixOp of prefix_unary_op
  | PostfixOp of postfix_unary_op

and subscript_op =
  | Index of expr
  | DotMember of expr
  | ArrowMember of expr
  | FunctionCall of expr list

and binary_op =
  | Add               
  | Subtract          
  | Multiply          
  | Divide            
  | Modulo            
  | BitwiseAnd        
  | BitwiseOr         
  | BitwiseXor        
  | ShiftLeft         
  | ShiftRight        
  | LogicalAnd        
  | LogicalOr         
  | Equal             
  | NotEqual          
  | LessThan          
  | LessThanOrEqual   
  | GreaterThan       
  | GreaterThanOrEqual 

and assign_op =
  | Assignment        
  | AddAssign         
  | SubtractAssign    
  | MultiplyAssign    
  | DivideAssign      
  | ModuloAssign      
  | AndAssign         
  | OrAssign          
  | XorAssign         
  | ShiftLeftAssign   
  | ShiftRightAssign

It's still incomplete. I just found out I can use .mli files.

I think Cephyr is the 5th reincaation of my OCaml C compiler. I just spend hours at the AST and get tired of it.

I found lcc, by Fraiser et al:

https://github.com/drh/lcc

And I have the book too. I like the book but it's kinda useless for me because I wanna do SSA. These kinda tree-rewriting mumbo jumbo is too 80s for my taste.

So any help is appreciated. Thanks.

1 more...

So I'll answer your question and ask a question back from anyone who can help me.

RE the nesting, I was under the impression that they can't be combined when I made it. Then I read CommonMark's specs and it seems like it's possible. It would be miserable to do this with a syntax-directed translation. I used ASDL to write up a tree, and added some features to asdl(1) so they would be handled more properly. I am not sure whether I should use a parser generator for this, but the nesting can be handled by Lex's start conditions --- if I fail to do so, I may use a PEG generator.

Now my question.

I think nesting and recursion are a good case for using a push-down parser here --- I will still try and find a solution before I use an LR parser.

I avoid using Yacc because I honestly have no clue how to use it with a language like Markdown.

So my thinking is, I would just use a starting condition stack with Lex (I use Flex). It's pretty simple. Let's use a linked list so there are no limits.


struct stack { int state; stuct stack *next,  }

struct stack *top, *bottom;

void push ...

int pop ...

(I usually use typedefs though).

So now we have a psuedo-pushdown parser. What are these called?

I am still a beginner at this but one thing that worries me is, how would I handle the tree with this method?

With Yacc or PEG parser generators, it is easy to assign a value to a reduction/closure. But with this method, Flex won't allow me. Unless I use too many variables.

I think I may use peg(1). I can even do the same stack thingy with PEG.

Any help is welcome.

I don't understand. Am I doing something against the rules of this instance? I have posted stuff like this before?

1 more...

Well what you are describing are the abstractions upon these models. So the 'basis' still remains true. Think of it this way:

  • A modern machine is based on the RAM model;
  • The RAM model is based on the register model;
  • The register model is based on several lower-level abstractions, at the end of which we get to a Turing machine.

So AFAIK, Sipser's does not explain more intricate models like RAM machine or register machine, I recommend spending some time prompting ChatGPT or reading some books on it (don't know any off hand).

TL;DR: The formal languages described in Sipser's are the lowest levels of abstraction. Higher levels of theoretical abstractions do exist, which I described several here.

At the end, remember that theory and practice are to be used in tandem, neither will achieve anything alone. Modern languages we use today once resembled a formal, theoretical language, a PDA made of PDAs. Look at the earliest C compilers, for example: https://github.com/mortdeus/legacy-cc/tree/master/prestruct. It's just a giant state machine.

I highly recommend picking up an HDL (Hardware Description Language), or implementing one if you got the time. This shall give you a clear picture of how theory differs from practice.

PS: Modern systems languages also never give a true picture of what programming is, and what should it be about. I recommend picking up a language closer to functional than imperative. I recommend OCaml, or Haskell if could be. That is the other side of formality.

I think you are irresponsible towards your future if you are a gainfully employed self-taught programmer, and don't invest in formal education. If you say 'I don't have time!' well, consider this, even night classes in junior colleges teach you stuff you don't know. Go to them, get your associates. I am in the process of getting into a contract where I do some thankless jobs for someone I know, he in exchange pays me to go to college. I am 31 -- as I said in the other thread, THERE IS NOTHING WRONG WITH BEING A LATE-COLLEGER!

I have been to college, I have studied 3 subjects for a total of 9 semesters, I have no degree to show for any of them :( I quit English lit, French lit and "Programming" all after 3 semesters. But when I was studying French lit, there was a guy in our class who was SIXTY-FIVE YEARS OLD! He wanted to learn French to open up some a commerce consulting office, focusing on import/export from France.

What I wanted to do was to 'write', keep in mind, 'write', not 'draw' bande dessine! But now that I am older and hopefully wiser, I have a set goal in mind. I am going to go this 'boutic' college near our home to study Electronics Engineering and when push comes to shove and China makes its move, start a chipset engineering firm with a production wing.

Just like how electronics is math with physics, programming is the virtual aspect of it. it's 'applied math'. I understand enough discmath because I studied enough of it both in college, and high school (since I was math/physics elective) so I have managed to understand some very rough and old papers.

You can always self-study if you haven't got the time. Here's a book which is kind of a meme, but it's still very good: https://fuuu.be/polytech/INFOF408/Introduction-To-The-Theory-Of-Computation-Michael-Sipser.pdf

This is the 2nd edition though, 3rd is out --- I think 4th is coming. The best goddamn book, regardless of its meme status.

This is so nice... Thanks.

Why did you use a ? as a prompt for E, but a >>> as a prompt for Python? I know CPython uses >>> in its termio prompt (and I don't know how they brought that to Windows?) but why would have E used ??

I subconsciously knew this, I currently am making a simple data exchange format to use with a program, and I am using PEG to create a parser. Chances of errors happning in this DXF is really low, but if the parser can't parse it, it's invalid.

I kinda like that I am as far away from the web world as possible. The only time I deal with anything web-related making a static blog software for myself. As Alan Kay puts it, web is ill, because it has been a hack from day -1. Every time you make a web application, you are using a mule to carry a city worth of cargo on its back.

Web was created for static pages. Use it for static pages. The only website that does not do this and I use is Youtube. I only then visit HackerNoon and Lemmy instances, both of which come out of Web's tube of shit proud.

i wish I could post my conversation (barely a conversation, what do I have to converse with someone who's worked with magnetic core, I just agreed) with Alan Kay on Quora, but I tried to login, and it was so bloated, I could not find the conversation.

I apologize if this hurts your feelings that your 'lil protocol sucks. Read about Dough Englebert's NLS.

Thanks.

Good point me lad. The plain-text based approach indeed makes scraping much easier. And plus, if we send a 'process', the process can be easily malicious, even if we don't elavate its access.

Like imagine today. I tell you to wget a shell script and pipe it to shell to install my software from my remote (FPT, Git etc). This almost always needs sudo. I can't imagine how many 12 year olds would be fooled to sudo rm -rf *?

That is provided that a 12 year old would even know how to do that. I know several people who began their UNIX journey when they were as young as 7~8, but there's a reason these people earn 500k a year when they are 30! I can't imagine if your normie aunt would really feel like using a UNIX pipeline to check her emails.

HTTP 'just werks'. Derpcat told me this in 2010 when I told her I hate HTTP in 2010. IT JUST WERKS. Kay's solution, although extreemly unbaked, would not allow my mom to read her Intagram feed.

Besides money, the computation cost is also high. Kay used to use mini-computers, us poor people used micros (if i were a poor person when mini/micro distinction existed, today it's just clusters vs Jimmy's gaming rig, oh, where art thou, DEC?)

But again, nobody has given a it a thought. THAT IS THE ISSUE. Academic text on alternatives to web, AFAIK, is rare. Part of it is the 'just werks' thing, but also, academia just does not care about web.

I think if people who are smarter than me would give this a 'thorough' thought, they will come up with a good solution. Web won because it was 'open', it was easy to navigiate, as opposed to pesky newsgroups and the such. You can still go to the first website to see this: http://info.cern.ch/ (browse this with Lynx or W3M, it's the best way to do it! Don't use FF or Chrome).

I dunno!

1 more...

I remember that from ages ago. It was very, very cringe-worthy. I think it's the fault of whatever shit bootcamp he attended to learn his 'craft' for using imperative languages to teach DSA, if they taught him DSA at all? That is why in real universities they mostly teach DSA with functional languages. I studied 'programming' (not CS, 'programming') in a college which by American standards would be considered 'junior', for 3 semesters, and they, too, did not touch on functional languages. It was not until I had dropped out that I learned how to do FP using SML, Ocaml, Haskell, Scheme etc. That was when I 'understood' DSA for real.

Truly, this person is an embarrassment. I am currently working on an implementation of Appel et al's ASDL (github.com/Chubek/ZephyrASDL, check the new_version branch!) and it now emits decent C code, so it is time to write the man page (it currently has a sucky one) and the TextInfo. I COULD potentially have ChatGPT make both, it is very decent at doing so. But see, I am not a moron. So I use write them in Markdown and have Pandoc make the final markups.

Truth is, if you know your tools, if you know how to use a DSL-driven approach to programming, you won't need to use AI to generate your code. You don't need to go to Harvard to know DSA, neither a junior college like mine. Just grab CSLR and read it on your spare time!

I think this person is the guy behind Homebrew. I don't know why he thought Homebrew is an accomplishment that would give him immunity from knowing basic DSA --- which in real world, is what programming is about. Package managers have existed since the dawn of time. Linux has like dozens of package managers. His package manager being 'unique' on MacOS does not mean it's an accomplishment, it means MacOS sucks cocks!

Basically, when you start a project, think: can I turn this project into a paper? If you can't, then it's worthless. He could have just strapped Pacman to be built on MacOS and called it a day!

These days, employers are looking for people with theoretical, constitutional knowledge. Any monkey can code. I let ChatGPT aid me with a lot of my C code, it's very decent at generating C. Like I need a Makefile, it makes it for me. I need a print help function, it makes it for me. There's nothing wrong with using AI to 'help' you, but don't use it in vital shit!

But, if the code that AI generates is as good as the vital backbones of your software, maybe save up some money and go to college if you haven't, a 2-year degree at a junior college will be good. I am going back to college next year and I am 31! There's nothing wrong with being an old student.

Just don't expect people to suck your dick when you don't know how recursion works!

2 more...

It's a term that generally refers to the more 'mathematical' side of programming, as opposed to the more 'practical' side of things. I believe it means 'Data Structures and Algorithm' so its a generalization of 'meaty' programming. Think, someone who writes shell scripts does not need 'DSA' to oil his grind, but someone needing to write a compiler does.

Now we live at an age where you can generate a shell script with a simple prompt, and hell, you could piece-meal a compiler, but it's not as straightforward. If one wishes to make moola in the post-LLM world, one needs to have strong theoretical and constitutional foundation.

At this point, any employer who hires more than 1 person for the 'simple tasks' is doing charity. And charity ain't what employers known for!

That is not to say, don't use AI in your work. I believe AI is the BEST way to learn DSA. In fact I straightened a lot of my misconceptions using ChatGPT. Like, I have written 2 compilers and abandoned them because I never meant to finish them, it was an excuse to prompt ChatGPT with more complex requests and do some reckon on my knowledge. I managed to do 'basic' SSA with ChatGPT, and anyone who has read a compiler book or taken a class knows SSA is not easy. I generated the SSA, and confirmed with the SSA book that I had. IT was very decent. But ther SSA book was very 'crude' and ChatGPT's example was really, well, 'uncrude'? So it was a GIANT help in me understanding SSA.

So if you need to learn DSA, I can recommend these three steps:

1- Learn a functional language or LISP-like language, Scheme, Racket, OCaml, SML, Haskell, etc. These langauges are extremely fluid and scientific.

2- Read books. Just go on Libgen or Zlibrary and read books. I recommended SIpser's above (or was it in another post?) but there's dozens. I remember a book called "Grokking Algorithms" which was really good. I read this book when I was sick with Covid, Steven Skiena's "The Algoritmh Design Manual" and it seems like everyone just LOVES this book. I mean it, try it, it's the best. If you can, buy it, because it's very precious. Also, keep a copy of CSLR/CLSR or whatever as a reference on your desk, PC everywhere.

3- Piece-meal ChatGPT into designing you a complex application. It really helps if you got an aim. One thing I recommend is Genealogy software. Make a Genealogy DSL perhaps. Or a simple compiler.

My advice may not be sound, but some aspects of these were helpful for me.

I think digraphs and trigraphs are part of the preprocessor? I did not add any preprocessor stuff to this grammar. I am adding them to the new version I am working on.

I have read the C17 standard fully and I did recall it from memory from time to time but it seems like I had forgotten a lot of stuff. I am redefining it, and I am redigning my AWK grammar too.

I am hoping I could perhaps make a Github pages website called Internet Grammar Database and have all sorts of grammar inside it. Thoughts?

3 more...

Cool, I am making a second version were things are cleaner, I will add digraphs, trigraphs and preprocessor directives to the gramamr as wel. Thanks.

Is parenscript some sort of s-expression JS?

1 more...

Glad to hear that. I am a sucker for S-Expressions a s well. I recently wrote a script in Ruby which syntax-directly translated JSON to S-Expressions. Also, please check out my S-Expression parser in C: https://gist.github.com/Chubek/d2f0ac9067521716d2ab31c93948e885

Apologies. I will definitely fix them. Do you notice any more errors? I myself just realize that-- path expansion could be replaced with actual rules. Thanks again.

1 more...

Thanks my good human.

(Sorry if this is a double post) I think what you call 'decoration' I call 'augmentation;. After many iterations ,I came up with this AST: https://pastebin.com/NA1DhZF2

I like it, but I am still skeptical as of comitting to it. I really want to use Functors... But i'm nto sure how. These are new concepts to me!

You showed up! So, about this, you see how 'let' binding does not allow you to add parameters right? (the val binding does) I think this is a good place to use tacitness. I will basically add Perl-like, POSX-shell-like features. To further add concatativenss, I shall add OCaml-style shell (|>). I will take a page from F#'s book and add a '<|' too. I was originally planning to have these two operators be defined orthogonal-like via the operator binders (infix, infixr etc) but I think it's necessary to bake them in.

So any other cool stuff? I plan on having intrinsics like 'add' and 'or' etc. Since it is translated down to C, I will add a two-way FFI, similar to the language I am writing it in, Cyclone Scheme.

THANKS.

I know about all this --- I actually began implementing my own JVM language a few days ago. I know Android uses Dalvik btw. But I guess a lot of people can use this info; infodump is always good. I do that.

btw I actually have messed around with libgcc-jit and I think at least on x86, it makes zero difference. I once did a test:

-- Find /e/ with MAWK -> 0.9s -- Find /e/ with JAWK -> 50s.

No shit! It's seriously slow.

Now compare this with go-awk: 19s.

Go has reference counting and heap etc, basically a 'compiled VM'. I think if you want fast code, ditch runtime.

1 more...

I will download it all and mirror it on my server and Github pages. Hate to see it go. What happened to this dude? Was he old or young?

Cool, will do.

Not with this grammar. There's this parser-generator-immedate called BNFC that uses it's own flavor of BNF (Labeled BNF) to generate Yacc/Lex (or ANTLR when can), an abstract syntax tree, etc, but I don't like it. There are no EBNF parser generators AFAIK. One could, possibly, feed this to ChatGPT and ask for a Yacc/Lex pair in return, or even a manual parser! I may do that, but I first have to clean this up and add stuff that aren't there.

ChatGPT has changed langdev a lot for me. I automate a good portion of the processo with it. But one needs solid specs to feed to it.

As I said I wish to implement the frontend myself, basically the lexer/parser. But I kinda get bored with LP because it's too time-consuming. Plus LR(1) can only be generated, it's only LL(1) which can be hand-written. I have not decided yet. I wish to focus more on the backend, because that is where you can do innovative shit and perhaps, write a paper on it.

Also, I'm going to leave C23 to people who have years of experience. ANSI C is the lower denomniator of C. I am using C99 standard, which should be able to compile a good portion of code bases. C99 is the last required POSIX standard for C. That's when C went under ISO.

Thanks.

btw this is the ASDL I wrote:

%{

#include "mukette.h"


static Arena *ast_scratch = NULL;


#define ALLOC(size) arena_alloc(ast_scratch, size)


%}

md_linkage = Hyperlink(md_compound? name, string url)
	  | Image(string? alt, string path)
	  ;


md_inline = Italic(md_compound italic)
	 | Bold(md_compound bold)
	 | BoldItalic(md_compound bold_italic)
	 | Strikethrough(md_compound strike_through)
	 | InlineCode(string inline_code)
	 | Linkage(md_linkage linkage)
	 | RegularText(string regular_text)
	 ;


md_header_level = H1 | H2 | H3 | H4 | H5 | H6 ;


md_line = Header(md_compound text, md_header_level level)
	| Indented(md_compound text, usize num_indents)
	| LinkReference(identifier name, string url, string title)
	| HorizontalLine
	;


md_compound = (md_inline* compound) ;


md_table_row = (md_compound cells, size num_cell) ;


md_table = (md_table_row* rows, size num_rows) ;


md_ol_item = (int bullet_num, md_list_item item) ;


md_ul_item = (char bullet_char, md_list_item item) ;


md_list_item = TextItem(string text)
	    | OrderedItem(md_ol_item ordered_item)
	    | UnorderedItem(md_ul_item unordered_item)
	    | NestedList(md_list nested_list)
	    ;



md_list = (md_list_item* items) ;



md_block = Pargraph(md_compound* paragraph)
	| BlockQuote(md_compound* block_quote)2
	| CodeListing(identifier? label, string code)
	| Table(md_table table)
	| List(md_list list)
	| Line(md_line line)
	;


markdown = (md_block* blocks) ;


%%


static inline void init_tree_scratch(void) { ast_scratch = arena_init(AST_ARENA_SIZE); }
static inline void free_tree_scratch(void) { arena_free(ast_scratch); }

I had an easier time parsing ASDL with Yacc. I still can't tell whether a grammar is LR, LL or RE, but I can tell that Markdown is not CFG.

I just updated ASDL: https://github.com/Chubek/ZephyrASDL

Apologies if I am too late on the documetnation. I am still trying to improve it by using it myself. I also wish to add an Ocaml target.

1 more...

I remember reading something about recursive languages in Aho's Automata Book. I will have to check it again. So Regular Languages can't be recursive? Is that what 'recursive' language even means? I have to read the book again.

Thanks for your help man.

1 more...

Alright sorry. I'm just trolling people. If you go to my profile I have a lot of Rust projects. @hascat @FizzyOrange

This statement is completely wrong. Like, to a baffling degree. It kinda makes me wonder if you’re trolling.

No I just struggle at getting my meaning across + these stuff are new to me. What I meant was 'Go does memory management LIKE a VM does'. Like 'baking in the GC'. Does that make sense? Or am I still wrong?

Uh I did not see them. Thanks!

Uh apologies. I did not realize that.

That's what they are doing with Fandom (formerly Wikia). Right?