Jump to content
  • Advertisement
Sign in to follow this  
Cornstalks

C++ should use more @`,!>

This topic is 2001 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Here's a little sample from my Racket-based parser for parsing tokenized Python (uses Matt Might's derivative parser):
 

; <program> ::= (program <stmt>*)
(file_input      (@--> (seq! `(rep (or NEWLINE stmt)) ENDMARKER)
                       (? (seq) `(program ,@seq))))
 
; <funcdef> ::= (def (<NAME> <NAME>*) <suite>)
(funcdef         ($--> (seq! "def" `NAME `parameters ":" `suite)
                       `(def (,($ 0) ,@($ 1)) ,($ 2))))
 
; ... more stuff

; <simple_stmt> ::= <small_stmt> | (begin <small_stmt>+)
(simple_stmt     (>--> (seq! `(seq* small_stmt
                                    (rep (seq! ";" `small_stmt)))
                             (opt ";")
                             NEWLINE)
                       [`((,small_stmt ())) small_stmt]
                       [`((,small_stmt ,rep)) `(begin ,small_stmt ,@rep)]))
 
; ... and a ton more cryptic cases

 
Because you can never have enough randomly* placed symbols sprinkled throughout your code...
*and by randomly, I mean very carefully

A whole file of this is actually kinda mesmerizing when you look back on what you've written.

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!