Repository: samshadwell/TrumpScript Branch: master Commit: 3793b905925b Files: 40 Total size: 86.3 KB Directory structure: gitextract_wm4li01d/ ├── .gitignore ├── Brainstorming.txt ├── Grammar.txt ├── LICENSE ├── README.md ├── _config.yml ├── bin/ │ └── TRUMP ├── src/ │ └── trumpscript/ │ ├── __init__.py │ ├── allowed_words.py │ ├── compiler.py │ ├── constants.py │ ├── disallowed_words.py │ ├── main.py │ ├── parser.py │ ├── tokenizer.py │ ├── utils.py │ └── vocabulary.py └── test/ ├── test.py └── test_files/ ├── 99-bottles.tr ├── china.txt ├── debate_vs_hillary.txt ├── debate_vs_jeb.txt ├── debate_vs_rubio.txt ├── debatesvdebates.txt ├── debatevsdark.txt ├── fizz_buzz.txt ├── haiku.txt ├── huge_test.tr ├── loves_china.tr ├── math.txt ├── nonterm_quote.txt ├── not_english.txt ├── not_patriotic.txt ├── primeTest.tr ├── rig_the_polls.tr ├── test_1.txt ├── testing_else.tr ├── toupee.txt ├── toupee_junk.txt └── trump_vs_army.txt ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ .idea .DS_Store src/trumpscript/__pycache__ ================================================ FILE: Brainstorming.txt ================================================ RULES: *No import statements (or requires a protective tariff) Booleans: true -> fact, false -> lie *Not portable Not compatible with PC Variable names are English only, and either short or popular words only Don't run if file contains "Hillary", "Muslim", "Mexico", etc... Error messages are all Trump quotes No floating point numbers, America doesn't do things halfway $4B always converted to $10B "Yell" or "Exclaim" are the prints to std out America = Great is the equivalent of exit(0) Strings that are yelled, or all strings can only be uppercase Numbers have to be greater than $1mill No build-in random generation "Build a fence" should do something ??? For loop could be "Get 10 Mexicans to build a wall" Start closure with ':', end it with '!' Use 'x' as multiplication? Division always rounds up Periods are our 'newline' characters Assignment is done via "x is y" and "Make x <- y" Equality check: put "?" at end of word "Guarantee" defines a function "Do" calls a function Null is "Jeb"? DEMO: FizzBuzz = Fiorina Bush KEYWORD MAPPING: None -> Jeb False -> lies, nonsense True -> truth, fact and -> AND assert -> absolutely break -> capiche def -> guarantee if, elif, else -> if, else if, else is -> is not -> not or -> or pass -> ??? return -> ??? while -> as long as print -> tell, say < -> less, fewer, smaller > -> more, greater, larger OTHER: Allow a couple of different variations on the ending ================================================ FILE: Grammar.txt ================================================ Abstract grammar for TrumpScript { mod = Module(stmt* body) stmt = Assign(expr* targets, expr value) | Print(expr? dest, expr* values, bool nl) <- secretly represented by Call, which makes it an expr | While(expr test, stmt* body, stmt* orelse) | If(expr test, stmt* body, stmt* orelse) | Expr(expr value) -- BoolOp() can use left & right? expr = BoolOp(boolop op, expr* values) | BinOp(expr left, operator op, expr right) | UnaryOp(unaryop op, expr operand) <- only used for Not -- need sequences for compare to distinguish between -- x < 4 < 3 and (x < 4) < 3 | Compare(expr left, cmpop* ops, expr* comparators) | Call(expr func, expr* args, keyword* keywords, <- not actually used in our grammar expr? starargs, expr? kwargs) | Num(object n) -- a number as a PyObject. | Str(string s) -- need to specify raw, unicode, etc? | Name(identifier id, expr_context ctx) expr_context = Load | Store (| Param?) <- not part of our grammar boolop = And | Or <- are they given their own handlers? operator = Add | Sub | Mult | Div <- not given their own handlers unaryop = Not cmpop = Eq | Lt | Gt (| NotEq | GtE | LtE can all be built using not/or) <- not given their own operation } ================================================ FILE: LICENSE ================================================ The MIT License (MIT) Copyright (c) 2016 Sam Shadwell Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================ # Final Update It's been a while since we made any updates to TrumpScript, and we just wanted to make it official that our development on this project has stopped and that we will no longer be accepting issues or pull requests on this repo. Frankly, this joke isn't funny anymore. Rather than spend your time beating the "Trump is ridiculous" meme to death, please actually do something instead and donate to: * [American Civil Liberties Union](https://www.aclu.org) * [National Resources Defense Council](https://www.nrdc.org) * [Planned Parenthood](https://www.plannedparenthood.org) # TrumpScript Make Python great again ## Mission TrumpScript is a language based upon the illustrious Donald Trump. As the undeniably best US President, we found that the current field of programming languages does not include any that Trump's glorious golden combover would approve of. TrumpScript is our solution to this. It's the programming language Trump would approve of. Just like he is going to make America great again, we hope our efforts will make programming great again. ## Installation To use, download the .zip and extract the contents or clone the repository by typing ```bash git clone https://github.com/samshadwell/TrumpScript.git ``` Add the TrumpScript root directory to your system `PATH` using one of the two following techniques 1. Temporary: Write `export PATH=$PATH:/path/to/TrumpScript/bin` to terminal. 2. Permanent: Append `export PATH=$PATH:/path/to/TrumpScript/bin` to the end of your `~/.bashrc` file. ## Usage * Write a TrumpScript file following the syntax we've specified (good luck). * Execute `TRUMP /path/to/trumpscript/file.tr` * Enjoy the wonderful world of TrumpScript! ## Features Our language includes several convenient features, perfect for any aspiring Presidential candidate including: * No floating point numbers, only integers. America never does anything halfway. * All numbers must be strictly greater than 1 million. The small stuff is inconsequential to us. * There are no import statements allowed. All code has to be home-grown and American made. * Instead of `True` and `False`, we have the keywords `fact` and `lie`. * Only the most popular English words, Trump's favorite words, and current politician names can be used as variable names. * Error messages are mostly quotes directly taken from Trump himself. * All programs must end with `America is great`. * Our language will automatically correct Forbes' $4.5B to $10B. * In its raw form, TrumpScript is not compatible with Windows, because Trump isn't the type of guy to believe in PC. * TrumpScript boycotts OS X and all Apple products until such time as Apple gives cellphone info to authorities regarding radical Islamic terrorist couple from Cal. * The language is completely case insensitive. * If the running computer is from China, TrumpScript will not compile. We don't want them stealing our American technological secrets. * By constructing a wall (providing the --Wall flag), TrumpScript will refuse to run on machines with Mexican locales * Warns you if you have any Communists masquerading as legitimate "SSL Certificates" from China on your system. * Won't run in root mode because America doesn't need your help being great. Trump is all we need. * Easy to type with small hands If you find you can't get any TrumpScript to run on your computer (probably because we disallow the two most popular operating systems), you can specify the `--shut_up` flag to let the interpreter know you just want your code to run, damn it. ## Grammar The grammar of the language is fairly convoluted, but here's a taste of the enlightened decisions we've made. Arithmetic operators: * `+` and `plus` do addition * `-` and `minus` do subtraction * `*` and `times` do multiplication * `/` and `over` do division * `<`, `less`, `fewer`, and `smaller` all evaluate to 'less than' * `>`, `more`, `greater`, and `larger` all evaluate to 'greater than' Control flow: * Use `,` and `;` to treat compound statements as a single evaluation, similar to how `()` are used in other languages * Use `:` and `!` to define the scope of loops and if statements, similar to how `{}` is used in Java * `if`, `else if`, and `else` do what you think they do * `not`, `and`, and `or` do what you expect The exciting parts: * Strings are denoted by double quotes (`"I love Trump"`) * The `is` and `are` keywords are used both to check for equality, and for assignment. To use for assignment, say something like `Trump is great` or `Democrats are dumb`. To use to check for equality, do the same but append a `?`. For example, you may need to ask yourself `Trump is "the best"?` (although we all know that would evaluate to `fact` anyway) * Assignment can also be done via the `make` keyword. E.g. `Make America great` assigns the value of the variable `great` to `America` * Printing to stdout can be done via `tell` or `say` * While loops are denoted via `as long as`. And that's the only type of loop you need anyway * If a 'word' (so anything that could be a variable name) is deemed unnecessary by the compiler, it's simply thrown away. So you can make truly self documenting code, or code that appear to read very very similarly to real speeches by the big man himself. You can find some interesting examples in our `test/test_files` directory Example: ``` What are we in this country Hillary speaks nothing but lies But look at me I came to this election to make guys believe again believe in fact if, all of us real lies the light; : say "VOTE TRUMP" ! but I know we should be free else the result will be bad: all the work of George Washington was for nothing so this election say "Hello World" say "TRUMP FOR PRESIDENT"! America is great. ``` But most importantly, Trump doesn't like to talk about his failures. So a lot of the time your code will fail, and it will do so silently. Just think of debugging as a fun little game. ## Because We Pretend We're Good People If this page entertained you, consider making a donation to your favorite charity or political campaign. I'm a fan of the [Electronic Frontier Foundation](https://www.eff.org), [donate here](https://supporters.eff.org/donate/button) There's also [Hillary Clinton](https://www.hillaryclinton.com/contribute/donate/), and of course [Donald Trump himself. ](http://www.reactiongifs.com/r/saywha.gif) ## Because We've Sold Out If you're feeling extra generous, you can also buy us a beer (or two) for more brainstorming because our small loan of a million dollars wasn't enough: Paypal: [paypal.me/Shadwell](https://paypal.me/Shadwell) Bitcoin: [1AKK76WNmQheCYgZEksB61Jyp1voYxN63v](bitcoin:1AKK76WNmQheCYgZEksB61Jyp1voYxN63v) ## Hey, this repo seems pretty dead... This project is (probably) not totally dead, and we'll get back to it eventually, but hold tight for now, since we're all busy students full-time. But by all means, please submit a pull request! We're all just shocked this has blown up so much, and we'd love to get this language implemented "properly!" ## Media Hey, cool, [we got an article on Inverse written about us!](https://www.inverse.com/article/10448-coders-assimilate-donald-trump-to-a-programming-language) [Also Motherboard](http://motherboard.vice.com/read/donald-trump-in-a-programming-language) [And The Verge](http://www.theverge.com/tldr/2016/1/21/10806944/donald-trump-script-python) [And one on Gizmodo](http://gizmodo.com/theres-a-donald-trump-programming-language-1754458693) [And TheNextWeb](http://thenextweb.com/us/2016/01/22/trumpscript-is-a-programming-language-that-thinks-and-acts-like-donald/) [And Mashable](http://mashable.com/2016/01/22/donald-trump-programming-language/#9NAKAP8GPOqt) [And The Washington Post](https://www.washingtonpost.com/news/powerpost/wp/2016/01/22/decentralizing-control-of-the-internet-meet-trumpscript-a-new-programming-language-are-iphone-sales-in-decline/) [Geekwire](http://www.geekwire.com/2016/donald-trump-programming-language-seeks-to-make-programming-great-again/) [UPI](http://www.upi.com/Odd_News/2016/01/22/Group-of-coders-create-script-language-based-on-Donald-Trump/1101453495327/) [Neowin](http://www.neowin.net/news/neobytes--trumpscript-will-make-python-great-again) ## History Created for HackRice ([hack.rice.edu](http://hack.rice.edu/)) by: [Sam Shadwell](http://samshadwell.me), [@samshadwell](https://github.com/samshadwell) Dan Korn, [@DnlRKorn](https://github.com/DnlRKorn) Chris Brown, [@CryoBrown](https://github.com/CryoBrown) Cannon Lewis, [@cannon10100](https://github.com/cannon10100) ================================================ FILE: _config.yml ================================================ theme: jekyll-theme-minimal ================================================ FILE: bin/TRUMP ================================================ #!/bin/sh root=$(dirname -- "$0")/.. export PYTHONPATH="${PYTHONPATH:+$PYTHONPATH:}$root/src" exec python3 -- "$root/src/trumpscript/main.py" "$@" ================================================ FILE: src/trumpscript/__init__.py ================================================ ================================================ FILE: src/trumpscript/allowed_words.py ================================================ ALLOWED = {"a", "abandoned", "able", "aborted", "abortion", "about", "above", "absolute", "absolutely", "abuse", "abused", "accept", "acceptable", "according", "accountants", "accounting", "across", "act", "action", "actually", "ad", "add", "address", "administration", "ads", "advantage", "advertise", "afford", "afraid", "after", "again", "against", "age", "ago", "agree", "agreed", "agreement", "agreements", "air", "airport", "airports", "all", "allegiance", "allow", "allowed", "almost", "along", "also", "although", "always", "am", "amazing", "amazingly", "amendment", "america", "american", "americans", "americas", "among", "amount", "an", "and", "angeles", "anger", "animal", "announce", "announced", "announcement", "announces", "announcing", "another", "answer", "anti", "any", "anybody", "anymore", "anyone", "anything", "anywhere", "apart", "apartment", "apartments", "apologized", "appear", "applause", "apple", "appreciate", "appropriate", "arabia", "are", "area", "aren't", "arm", "army", "around", "arrange", "arrive", "arsenal", "art", "artificial", "artificially", "as", "ask", "asked", "asking", "asphalt", "assets", "assimilate", "assimilation", "assume", "assuming", "assurance", "at", "athlete", "atlantic", "atom", "attacked", "audience", "authorities", "automobile", "avenue", "away", "ba", "babies", "baby", "bac", "back", "bad", "badly", "ball", "band", "bank", "bankrupt", "banks", "bar", "barack", "barron", "base", "based", "basic", "bat", "battlefield", "be", "bear", "beat", "beating", "beautiful", "beauty", "became", "because", "become", "becoming", "bed", "beef", "been", "before", "beg", "began", "begin", "behave", "behind", "being", "believe", "believers", "bell", "below", "ben", "bergdahl", "bernie", "beside", "best", "better", "between", "beyond", "bicycle", "bid", "bidder", "biden", "big", "bigger", "biggest", "bigly", "bill", "billion", "bird", "bit", "black", "bloated", "block", "blocks", "blood", "blow", "blown", "blue", "board", "boat", "bobby", "body", "boeing", "bone", "book", "border", "borders", "born", "borrowings", "both", "bother", "bottom", "bought", "box", "boy", "brady", "brag", "brain", "branch", "brand", "bread", "break", "breaks", "bridge", "bridges", "bright", "brilliantly", "bring", "bringing", "britain", "broad", "broadcast", "broke", "broken", "brooklyn", "brother", "brought", "brown", "bubble", "bubblewe", "budget", "buffaloed", "build", "builder", "building", "buildings", "builds", "built", "bullet", "bunch", "burn", "bush", "business", "businesses", "businessman", "busy", "but", "buy", "buzzer", "by", "caesars", "california", "call", "called", "calls", "came", "camp", "campaign", "campaigns", "can", "can't", "canada", "candidate", "candidates", "cannot", "capable", "capita", "capital", "captain", "car", "card", "cards", "care", "careful", "carly", "carolina", "carry", "cars", "carson", "cartel", "case", "cat", "catastrophe", "catch", "caterpillar", "caught", "cause", "caused", "cell", "cent", "center", "century", "certain", "certainly", "certify", "cetera", "chair", "chairman", "challenged", "chance", "change", "changed", "changing", "chapter", "character", "charge", "charged", "charging", "charities", "chart", "check", "cheering", "cheerleader", "cheerleading", "cherish", "chevrolet", "chick", "chief", "child", "children", "china", "chinese", "choice", "choose", "chord", "chris", "christians", "christie", "chunk", "circle", "circuit", "circumstances", "citizen", "city", "claim", "class", "clause", "clean", "clear", "clearance", "climb", "clinton", "clock", "close", "closing", "clothe", "cloud", "clue", "cnn", "coast", "coat", "cold", "collect", "college", "colony", "color", "column", "come", "comes", "coming", "comment", "commissioner", "common", "companies", "company", "compare", "compared", "compete", "competence", "competent", "competition", "complete", "complex", "concept", "concerned", "condition", "conditioner", "congratulations", "congress", "connect", "conservative", "consider", "considering", "consonant", "contain", "continent", "continue", "continuously", "contributed", "contribution", "contributor", "control", "controlled", "convention", "converting", "convincing", "cook", "cool", "copy", "core", "corey", "corn", "corner", "corps", "correct", "correctness", "corrupt", "cost", "costs", "cotton", "could", "couldn't", "count", "counter", "countries", "country", "couple", "course", "courses", "cover", "covering", "cow", "crap", "crashing", "crass", "cratered", "crease", "create", "created", "creating", "credibility", "credit", "crime", "criminal", "crisis", "crop", "cross", "crosstalk", "crowd", "crowds", "cruz", "cry", "cunning", "currency", "current", "cut", "cuts", "cutting", "dad", "dance", "danger", "dark", "day", "days", "de", "dea", "dead", "deal", "dealing", "deals", "dealt", "dear", "death", "debate", "debt", "decade", "decades", "decide", "decided", "decimal", "deductibles", "deep", "deficits", "degree", "democrat", "democrats", "denied", "depend", "depends", "describe", "desert", "deserves", "design", "destabilize", "destabilized", "destroyed", "destroying", "destructive", "details", "determine", "devaluation", "devalue", "devalued", "devaluing", "develop", "dictionary", "did", "didn't", "die", "differ", "difference", "different", "differently", "difficult", "direct", "directly", "disassociate", "disaster", "disastrous", "discuss", "discussing", "disgrace", "disgusting", "dishonest", "dislike", "distant", "divide", "division", "do", "doctor", "doctors", "does", "doesn't", "dog", "dogs", "doing", "dollar", "dollars", "domestic", "don", "don't", "donald", "done", "donnie", "donors", "door", "doral", "double", "down", "drain", "draw", "dream", "dress", "drink", "drive", "drop", "drugs", "dry", "duck", "dump", "dumping", "during", "dying", "e", "each", "ear", "early", "earn", "earth", "ease", "easily", "east", "eat", "eating", "economically", "economists", "economy", "edge", "education", "effect", "egg", "eight", "either", "elected", "election", "electric", "element", "elevators", "elite", "else", "else's", "embarrass", "employ", "employed", "employees", "end", "ended", "endorsing", "enemies", "enemy", "energy", "engine", "engineers", "england", "english", "enormous", "enough", "enter", "enterprise", "environmental", "environmentalist", "equal", "equate", "equipment", "eric", "escaped", "especially", "esprit", "establishment", "estate", "et", "europe", "evanka", "even", "evening", "event", "eventually", "ever", "every", "everybody", "everyplace", "everything", "everywhere", "evolved", "exact", "example", "except", "exception", "excite", "exclusively", "excuse", "executive", "exercise", "exist", "exonerated", "expect", "expectations", "expenses", "expensive", "experience", "experiment", "explain", "explode", "extensions", "extremely", "eye", "face", "fact", "factor", "factory", "fair", "fairly", "fairness", "fall", "falling", "falls", "false", "family", "famous", "fantastic", "far", "farm", "fashioned", "fast", "fat", "father", "favor", "fear", "fed", "feed", "feel", "feet", "fell", "fellas", "fellow", "felt", "few", "field", "fig", "fight", "fighting", "figure", "figures", "filed", "filing", "fill", "final", "finalized", "finally", "finance", "financial", "find", "fine", "finest", "finger", "finish", "fiorina", "fire", "fired", "firm", "first", "fish", "fit", "five", "fix", "flat", "flexibility", "flexible", "floor", "flow", "flower", "fly", "folks", "follow", "food", "fool", "foolish", "foot", "football", "for", "force", "ford", "foreign", "forest", "forget", "form", "forming", "fortune", "forward", "found", "foundation", "four", "fracking", "fraction", "francisco", "frankly", "fraud", "free", "fresh", "friend", "friends", "from", "front", "fruit", "full", "fully", "fun", "funded", "funder", "funding", "game", "garden", "gary", "gas", "gate", "gather", "gave", "gdp", "gen", "general", "generally", "gentle", "gentleman", "gentlemen", "george", "get", "gets", "getting", "gilmore", "girl", "give", "given", "giver", "glad", "glass", "global", "go", "god", "goes", "going", "gold", "golf", "gone", "gonna", "good", "gorgeous", "got", "gotta", "gotten", "gov", "govern", "government", "governmental", "governor", "graduate", "graham", "grand", "grass", "gray", "great", "greatest", "greatly", "greece", "green", "grew", "gridlock", "gross", "ground", "group", "groups", "grow", "guarantee", "guardia", "guards", "guess", "guide", "gun", "guns", "guy", "guys", "hack", "had", "hair", "haired", "half", "hampshire", "hand", "happen", "happened", "happening", "happens", "happy", "hard", "harvard", "has", "hat", "hate", "hating", "have", "haven't", "having", "he", "he'd", "head", "headquarters", "heads", "health", "hear", "heard", "heart", "heat", "heavy", "held", "hell", "hello", "help", "her", "here", "hero", "hey", "high", "highest", "highly", "hill", "hillary", "him", "himself", "hire", "his", "hispanic", "hispanics", "history", "hit", "hold", "hole", "home", "honest", "honestly", "honor", "honorable", "honored", "hope", "hopefully", "horrible", "horror", "horse", "hot", "hotel", "hotels", "hour", "house", "how", "however", "huckabee", "huge", "huh", "human", "humanitarian", "humvees", "hundred", "hundreds", "hunt", "hurry", "husband", "hyatt", "i", "i'd", "i'll", "ice", "idea", "idiots", "if", "illegal", "illegally", "illegals", "imagine", "imbalance", "immediately", "immigrants", "immigration", "impact", "important", "importantly", "impossible", "in", "inappropriate", "inaudible", "incentive", "inch", "inclined", "include", "including", "incorrectly", "increase", "incredible", "incredibly", "independent", "indicate", "industry", "inexpensively", "infrastructure", "insect", "instances", "instant", "instead", "instinct", "instrument", "insurance", "intelligent", "intent", "intention", "interest", "interested", "interesting", "interestingly", "interests", "into", "invent", "invite", "iowa", "iran", "iraq", "iron", "is", "isis", "islamic", "island", "isn't", "israel", "issues", "it", "its", "itself", "ivanka", "jailed", "japan", "jared", "jeb", "jersey", "jets", "jill", "jim", "jindal", "job", "jobs", "joe", "john", "johnson", "join", "journal", "joy", "judge", "jump", "junk", "just", "kai", "kaine", "kanye", "kasich", "kate", "keep", "kegs", "kept", "kerry", "key", "kicks", "kidding", "kill", "killed", "killer", "killers", "killing", "killingsmurders", "kind", "king", "knew", "knocking", "knocks", "know", "knowing", "knows", "komatsu", "l", "la", "labor", "ladies", "lady", "lake", "land", "language", "large", "largest", "last", "late", "later", "latin", "laugh", "laughable", "laughing", "laughter", "laura", "law", "laws", "lax", "lay", "lead", "leader", "leaders", "leadership", "leading", "league", "leagues", "learn", "learned", "least", "leave", "led", "left", "leg", "legal", "legally", "lenders", "length", "less", "let", "letter", "level", "levels", "leverage", "liabilities", "lie", "life", "lifestyle", "lifetime", "lift", "light", "like", "liked", "liking", "lindsey", "line", "lines", "liquid", "list", "listen", "listening", "literally", "little", "live", "lives", "living", "loaded", "loan", "lobbyist", "lobbyists", "local", "locate", "located", "log", "lone", "long", "longer", "look", "looked", "looking", "los", "lose", "losers", "losing", "lost", "lot", "lots", "loud", "love", "loves", "low", "macarthur", "machine", "made", "magic", "magnet", "mail", "main", "major", "make", "maker", "makes", "making", "man", "manhattan", "manner", "manufactured", "manufacturer", "manufacturing", "many", "map", "marco", "margins", "mark", "market", "martin", "mass", "massive", "master", "match", "material", "matter", "may", "maybe", "me", "mean", "means", "meant", "measure", "meat", "media", "medicaid", "medical", "medicare", "medieval", "meet", "meeting", "megyn", "melania", "melody", "men", "mess", "met", "metal", "method", "mexican", "mexicans", "mexico", "miami", "michigan", "microphone", "middle", "might", "mike", "mile", "militarily", "military", "milk", "million", "millions", "mind", "mindset", "mine", "minor", "minute", "minutes", "miss", "misspeak", "misspoke", "mitt", "mix", "modern", "modestly", "molecule", "moment", "money", "monmouth", "month", "months", "moon", "morally", "more", "morning", "most", "mother", "motion", "mount", "mountain", "mouth", "move", "mr", "much", "multiply", "murderers", "music", "must", "my", "myself", "name", "named", "names", "nation", "national", "natural", "nature", "near", "necessary", "neck", "need", "needs", "negative", "negatives", "negotiate", "negotiates", "negotiating", "negotiation", "negotiator", "negotiators", "neighbor", "net", "networks", "nevada", "never", "nevertheless", "new", "news", "newspapers", "next", "nice", "night", "nine", "no", "nobody", "noise", "nomination", "nominee", "nonsense", "noon", "nor", "north", "nose", "not", "note", "nothing", "notice", "notified", "noun", "now", "nuclear", "number", "numbers", "numeral", "nurses", "nutshell", "o'donnell", "o'malley", "obama", "obamacare", "object", "obligation", "observe", "obsolete", "obvious", "occasions", "occur", "ocean", "of", "off", "offer", "offered", "offering", "office", "officially", "often", "oftentimes", "oh", "oil", "ok", "okay", "old", "on", "once", "one", "ones", "only", "open", "operate", "opinion", "opposed", "opposite", "or", "order", "orders", "ordierno", "oregon", "organ", "original", "other", "others", "ought", "our", "ourself", "out", "outside", "outsider", "over", "overrated", "owe", "owes", "own", "oxygen", "package", "pacs", "page", "pages", "paid", "paint", "pair", "palin", "paper", "papers", "paragraph", "parent", "part", "participation", "particular", "parts", "party", "pass", "past", "pataki", "patches", "patents", "path", "patients", "patriots", "patrol", "pattern", "patton", "paul", "pay", "payer", "paying", "peanuts", "pence", "pennsylvania", "people", "per", "percent", "perhaps", "period", "perry", "person", "pertinent", "ph", "phase", "phones", "phrase", "physicists", "pick", "picture", "piece", "pitch", "place", "places", "plain", "plan", "plane", "planes", "planet", "plans", "plant", "plants", "play", "playing", "please", "pledge", "pledging", "plenty", "plural", "poem", "point", "policies", "policy", "political", "politically", "politician", "politicians", "politics", "poll", "polls", "poor", "poorly", "populate", "port", "portions", "pose", "position", "positive", "possible", "possibly", "post", "potatoes", "potential", "potomac", "pound", "pouring", "poverty", "powder", "power", "practice", "predictions", "premiums", "prepare", "prepared", "preparedness", "present", "president", "press", "pretty", "price", "priebus", "princeton", "principles", "print", "prison", "prisoners", "pritzker", "private", "pro", "probable", "probably", "problem", "problems", "process", "produce", "producing", "product", "profitable", "program", "project", "proliferation", "promise", "promised", "proper", "properly", "property", "protect", "protection", "proud", "prove", "proven", "provide", "public", "publicly", "pull", "punched", "puncher", "pundits", "push", "pushing", "put", "putin", "putting", "qatar", "quart", "quarter", "queens", "question", "questions", "quick", "quickly", "quickness", "quiet", "quite", "quitting", "quotient", "race", "radical", "radio", "rail", "rain", "raise", "ran", "rand", "range", "rapists", "rate", "rates", "rather", "ray", "reach", "read", "ready", "reagan", "real", "realized", "really", "reason", "reasons", "rebuild", "rebuilding", "rebuilt", "receive", "received", "recently", "reconsider", "record", "red", "reduce", "referred", "region", "rein", "reince", "relations", "relationship", "relationships", "remember", "renegotiate", "repeal", "repeat", "replace", "replaced", "reply", "report", "reported", "reporter", "reporters", "represent", "representing", "republican", "republicans", "require", "respect", "respected", "responsible", "rest", "result", "results", "return", "rhetoric", "rich", "rick", "rid", "ride", "rig", "rigs", "rigged", "rigging", "right", "ring", "rip", "ripped", "ripping", "rips", "rise", "river", "rnc", "road", "roads", "roadways", "rock", "rocket", "roll", "romney", "ronald", "roof", "room", "root", "rope", "rose", "rosie", "rough", "round", "row", "rub", "rubio", "rule", "run", "running", "russia", "ryan", "s", "sad", "sadly", "safe", "said", "sail", "salt", "same", "san", "sand", "sanders", "santorum", "sarah", "sat", "saudi", "saudis", "save", "saw", "say", "saying", "says", "scale", "scary", "school", "schools", "science", "score", "scotland", "sea", "search", "season", "seat", "second", "seconds", "secretary", "secrets", "section", "sections", "security", "see", "seed", "seem", "seen", "segment", "select", "self", "sell", "selling", "semi", "send", "sending", "sends", "sense", "sent", "sentence", "separate", "serious", "serve", "services", "set", "settle", "seven", "several", "shall", "shape", "share", "sharp", "sharper", "she", "sheet", "shell", "shine", "ship", "ships", "shocked", "shocking", "shoe", "shooting", "shop", "shore", "short", "should", "shoulder", "shouldn't", "shout", "show", "showed", "side", "sight", "sign", "signals", "signed", "signing", "silent", "silicon", "silver", "similar", "simple", "simply", "simultaneously", "since", "sing", "single", "sister", "sit", "site", "sites", "sitting", "situation", "six", "size", "skill", "skin", "sky", "slave", "sleep", "slip", "slow", "small", "smart", "smarter", "smartest", "smell", "smile", "snow", "so", "social", "soft", "soil", "sold", "soldier", "soldiers", "solution", "solve", "some", "somebody", "someday", "something", "sometimes", "son", "song", "soon", "sophisticated", "sorry", "sort", "sorts", "sought", "soul", "sound", "sounds", "south", "southern", "space", "spanish", "speak", "speaking", "speaks", "special", "specifics", "spectacular", "speech", "speeches", "speed", "spell", "spend", "spending", "spends", "spent", "spigot", "spirit", "spoke", "spot", "spread", "spreads", "spring", "square", "stage", "stand", "standard", "standpoint", "stands", "stanford", "star", "start", "started", "starting", "state", "statement", "statements", "states", "station", "statistic", "statistics", "stats", "stay", "stays", "stead", "steaks", "stealing", "steam", "steel", "stein", "step", "stick", "still", "stock", "stone", "stood", "stop", "store", "stories", "storming", "story", "straight", "straighten", "strange", "stream", "street", "strength", "strengthen", "strengthened", "stretch", "string", "strong", "stronger", "strongest", "strongly", "student", "study", "stuff", "stupid", "stupidity", "subcontractors", "subject", "substance", "substantial", "subtract", "success", "successful", "such", "sudden", "suffix", "sugar", "suggest", "suggested", "suit", "sum", "summary", "summer", "sun", "super", "superstar", "supply", "support", "supporters", "supporting", "supposed", "sure", "surface", "surplus", "surprise", "sustain", "swear", "sweated", "sweet", "swim", "syllable", "symbol", "syria", "system", "table", "tail", "take", "taken", "takes", "taking", "talent", "talented", "talk", "talked", "talking", "talks", "tall", "tapped", "tariff", "tax", "teach", "team", "tear", "ted", "teeth", "television", "tell", "telling", "tells", "temperature", "ten", "tennessee", "tens", "term", "terminate", "terms", "terrible", "terrific", "terrorism", "terrorists", "test", "than", "thank", "thanks", "that", "that's", "the", "their", "them", "themselves", "then", "there", "therefore", "these", "they", "they'd", "thick", "thin", "thing", "things", "think", "thinking", "thinks", "third", "this", "those", "though", "thought", "thousand", "thousands", "three", "thrilled", "thriving", "through", "throw", "thrown", "thus", "tie", "tiffany", "tim", "time", "times", "tiny", "tire", "tired", "to", "toads", "today", "together", "tokyo", "told", "tom", "tone", "tonight", "too", "took", "tool", "top", "total", "totally", "touch", "tough", "tougher", "toward", "tower", "town", "track", "tractor", "trade", "trader", "train", "traitor", "transaction", "travel", "treated", "treating", "tree", "tremendous", "triangle", "trillion", "trip", "trouble", "truck", "trucks", "true", "truly", "trump", "trust", "truth", "try", "trying", "tube", "tubes", "tunnels", "turn", "turned", "turning", "turnout", "twenty", "two", "type", "ultimately", "unable", "unbelievable", "unbelievably", "under", "understand", "unemployment", "unfortunately", "unions", "unit", "united", "unless", "unsalvageable", "until", "up", "upset", "us", "use", "used", "useless", "uses", "using", "usual", "valley", "valuable", "value", "vanessa", "various", "vary", "vehicles", "ventured", "verb", "very", "vets", "vibrant", "vice", "vicious", "victories", "victory", "view", "village", "violence", "virtually", "visit", "vladimir", "voice", "vote", "voters", "votes", "vowel", "wait", "waiting", "wales", "walk", "wall", "walls", "want", "wanted", "wants", "war", "warm", "warming", "was", "wash", "washington", "wasn't", "waste", "watch", "watched", "watching", "water", "wave", "way", "ways", "we", "we'd", "weak", "weaker", "weakness", "wealth", "weapons", "wear", "weather", "web", "wedding", "week", "weeks", "weight", "weld", "welfare", "well", "went", "were", "weren't", "west", "wharton", "what", "whatever", "whatsoever", "wheel", "when", "whenever", "where", "whether", "which", "while", "white", "who", "whoa", "whoever", "whole", "whose", "why", "wide", "wife", "wild", "will", "william", "win", "wind", "window", "wing", "wins", "winter", "wire", "wires", "wish", "with", "within", "without", "woman", "women", "won't", "wonder", "wonderful", "wood", "word", "words", "work", "worked", "workforce", "working", "works", "world", "worse", "worst", "worth", "would", "wouldn't", "wounded", "wow", "write", "writes", "written", "wrong", "wrote", "yale", "yard", "yeah", "year", "years", "yellow", "yemen", "yen", "yes", "yesterday", "yet", "york", "you", "you'd", "you'll", "you're", "young", "your", "yourself", "zero", } ================================================ FILE: src/trumpscript/compiler.py ================================================ # Compiler for TrumpScript # 1/17/2016 from ast import * from trumpscript.parser import * from trumpscript.tokenizer import * class Compiler: def __init__(self): self.tk = Tokenizer() self.prs = Parser() def compile(self, source): modu = self.parse(self.tokenize(source)) fix_missing_locations(modu) exec(compile(modu, filename="", mode="exec")) def parse(self, tokens): return self.prs.parse(tokens) def tokenize(self, filename): return self.tk.tokenize(filename) ================================================ FILE: src/trumpscript/constants.py ================================================ __author__ = 'github.com/samshadwell' # Token constants T_End = -1 T_Plus = 0 T_Minus = 1 T_Times = 2 T_Over = 3 T_Less = 4 T_Greater = 5 T_LParen = 10 T_RParen = 11 T_LBrace = 12 T_RBrace = 13 T_Is = 20 T_If = 21 T_Else = 22 T_True = 30 T_False = 31 T_And = 32 T_Or = 33 T_Not = 34 T_Word = 40 T_Num = 41 T_Quote = 42 T_Make = 50 T_Question = 51 T_Print = 52 T_While = 53 T_Input = 54 T_Mod = 55 # Error messages ERROR_CODES = { # For quotes that didn't get terminated 'unterminated_quote': ["And, believe me, if I win, if I become President, that will end.", "Anyone who thinks my " "story is near over is sadly mistaken."], # If they try to use a word that isn't common English 'nonword': ["This is a country where we speak English", "We have a country where to assimilate you have to speak English"], # If they try to use a word that we've explicitly banned 'badword': ["Trump doesn't want to hear it"], # Generic errors for when we're lazy 'default': ["You know, it really doesn’t matter what the media write as long as you’ve got a young and beautiful " "piece of ass.", "The concept of global warming was created by and for the Chinese in order to make " "U.S. manufacturing non-competitive.", "Listen you motherfucker, we're going to tax you 25 percent!"], # If they try to run on a PC 'os': ["Windows? 'The big problem this country has is being PC'"], # If they try to run on a Mac 'boycott': ["Mac? 'Boycott all Apple products until such time as Apple " "gives cellphone info to authorities regarding radical " "Islamic terrorist couple from Cal'"], # They had better let us know that 'America is great.' 'freedom': ["Trump will ensure that 'America is great'"], # Don't even try to make numbers smaller than 1,000,000 'too_small': ["I'm really rich.", "Part of the beauty of me is I'm very rich."], # Let them know we don't need to run as root 'root': ['America doesn\'t need root to be great.'], # If we're not happy with one of this process's SSL certificates 'ssl': ["An 'extremely credible source' has called my office and told me that one of this process's SSL " "certificates is a fraud."] } ================================================ FILE: src/trumpscript/disallowed_words.py ================================================ DISALLOWED = {"N.A.T.O", "NATO", "N.A.T.O.",} #may be allowed in the future ================================================ FILE: src/trumpscript/main.py ================================================ import argparse import os import sys from trumpscript.compiler import * from trumpscript.utils import * __author__ = 'github.com/samshadwell' def main(): parser = argparse.ArgumentParser(prog='TRUMP', description='Make programming great again') parser.add_argument('--Wall', action='store_true', help='If set, prevents running program from Mexican locales') parser.add_argument('--shut-up', action='store_true', help='If set, ignore all system warnings and run program. ' 'Overrides --Wall') parser.add_argument('program', nargs=1, help='TrumpScript program to run') args = parser.parse_args() if not os.path.isfile(args.program[0]): print("Invalid file specified,") return # Decide whether to ignore system warnings if not args.shut_up: Utils.verify_system(args.Wall) # Compile and go Compiler().compile(sys.argv[-1]) if __name__ == "__main__": main() ================================================ FILE: src/trumpscript/parser.py ================================================ # Parser for TrumpScript # 1/16/2016 from ast import * from trumpscript.constants import * class Parser: def __init__(self): self._token_to_function_map = { T_Word: self.handle_word, T_Make: self.handle_make, T_LBrace: self.handle_brace, T_LParen: self.handle_paren, T_If: self.handle_if, T_Mod: self.handle_mod, T_While: self.handle_while, T_Print: self.handle_print, T_True: self.handle_true, T_False: self.handle_false, T_Not: self.handle_not, T_Quote: self.handle_quote, T_Num: self.handle_num } def _get_value_from_word_token(self, tokens): token = self.consume(tokens, T_Word) return Name(id=token["value"], ctx=Load()) def parse(self, tokens) -> AST: filtered = self.filter_tokens(tokens) # Build the entirety of the Abstract Syntax tree return self.handle_module(filtered) @staticmethod def _temporary_error(msg="error", error_value="error"): print(msg) # TODO: get real errors srsly return error_value @staticmethod def filter_tokens(tokens) -> list: tokens = list(tokens) t = "type" t_null = {t: -1, "value": "NAN", "line": "NAN"} i = 0 variables = set() token = t_null tokens.append(t_null) while i < len(tokens) - 1: prev = token token = tokens[i] nxt = tokens[i + 1] # Check if we need to drop a junk word if token[t] == T_Word: if token["value"] not in variables: if prev[t] == T_Make: variables.add(token["value"]) elif nxt[t] == T_Is: variables.add(token["value"]) elif nxt[t] == T_Input: variables.add(token["value"]) else: tokens.pop(i) i -= 1 # Just back that up a touch # TODO: make this not necessary if token[t] == T_Less or token[t] == T_Greater or token[t] == T_And or token[t] == T_Or: tokens.pop(i) i -= 1 # Just back that up a touch i += 1 return tokens @staticmethod def peek(tokens): return tokens[0]["type"] @staticmethod def on_line(tokens): return tokens[0]["line"] def consume(self, tokens, t_type) -> dict: if self.peek(tokens) == t_type: return tokens.pop(0) else: print("failed to consume " + str(t_type) + ", got " + str(self.peek(tokens)) + " instead on line " + str(self.on_line(tokens)) + ".") # Mod def handle_module(self, tokens) -> Module: body_list = [] while len(tokens) > 1: # print("module main loop") state, tokens = self.handle_anything(tokens) if isinstance(state, expr): state = Expr(value=state) body_list.append(state) for statement in body_list: # print(statement) fix_missing_locations(statement) return Module(body=body_list) # Obnoxious coverage def handle_anything(self, tokens): start = self.peek(tokens) try: return self._token_to_function_map[start](tokens) except KeyError: tokens.pop(0) return Pass(), tokens # Stmt def handle_brace(self, tokens) -> (stmt, list): brace_contents = [] cur_token = tokens.pop(0) level = -1 while cur_token["type"] != T_RBrace or level > 0: # TODO edge case error if cur_token["type"] == T_LBrace: #we got the left brace of the actual structure #the first time #print("level up") level += 1 if cur_token["type"] == T_RBrace: #print("level down") level -= 1 brace_contents.append(cur_token) cur_token = tokens.pop(0) brace_contents.append(cur_token) self.consume(brace_contents, T_LBrace) statements = [] while self.peek(brace_contents) != T_RBrace: if self.peek(brace_contents) == T_End: # TODO: real error functionality please print("Called handle_brace on a non-terminated brace") res, contents = self.handle_anything(brace_contents) if isinstance(res, expr): res = Expr(value=res) #TODO: does it make sense to cast expressions to statements here? statements.append(res) return statements, tokens # Expr def handle_paren(self, tokens) -> (expr, list): paren_contents = [] cur_token = tokens.pop(0) while cur_token["type"] != T_RParen : paren_contents.append(cur_token) cur_token = tokens.pop(0) paren_contents.append(cur_token) self.consume(paren_contents, T_LParen) expression, contents = self.handle_anything(paren_contents) if self.peek(contents) != T_RParen : #TODO: real erros print("passed in parenthetical with more than one expression") self.consume(contents, T_RParen) return expression, tokens def handle_mod(self,tokens) -> (expr, list): valid_tokens = [T_LParen, T_Num] self.consume(tokens, T_Mod) followup = self.peek(tokens) if followup == T_Word: right = self._get_value_from_word_token(tokens) ar = Call(func=Name(id="float", ctx=Load()), args=[right], keywords=[]) return Call(func=Name(id="int", ctx=Load()), args=[ar], keywords=[]), tokens elif followup in valid_tokens: right, tokens = self._token_to_function_map[followup](tokens) ar = Call(func=Name(id="float", ctx=Load()), args=[right], keywords=[]) return Call(func=Name(id="int", ctx=Load()), args=[ar], keywords=[]), tokens #return Num(right['value']), tokens # Assign def handle_make(self, tokens) -> (stmt, list): valid_tokens = [T_LParen, T_True, T_False, T_Not, T_Quote, T_Num, T_Mod] self.consume(tokens, T_Make) if self.peek(tokens) != T_Word : #TODO: write this fucking error print("Ooh, what you making there? It sure isn't a variable, that's for goddamn sure!") variable = self.consume(tokens, T_Word) followup = self.peek(tokens) # Check the type of the next token to see if it's acceptable if followup == T_Word: val = self._get_value_from_word_token(tokens) elif followup in valid_tokens: val, tokens = self._token_to_function_map[followup](tokens) else: val = self._temporary_error(msg="make_error") target = Name(id=variable["value"], ctx=Store()) return Assign(targets=[target], value=val), tokens # Both Assign and EQ because why the hell not guys # Note that this does not have type signature because it can be expr or stmt (yeah it blows)) def handle_is(self, left, tokens): valid_tokens = [T_LParen, T_True, T_False, T_Not, T_Quote, T_Num, T_Mod] self.consume(tokens, T_Is) followup = self.peek(tokens) # Check the type of the next token to see if it's acceptable if followup == T_Word: right = self._get_value_from_word_token(tokens) elif followup in valid_tokens: right, tokens = self._token_to_function_map[followup](tokens) else: right = self._temporary_error(msg="is_error") if self.peek(tokens) == T_Question: self.consume(tokens, T_Question) first = None if left['type'] == T_Num: first = Num(left['value']) elif left['type'] == T_Quote: first = Str(left['value']) else: first = Name(id=left["value"], ctx=Load()) return Compare(left=first, ops=[Eq()], comparators=[right]), tokens else: if left["type"] == T_Word: target = Name(id=left["value"], ctx=Store()) return Assign(targets=[target], value=right), tokens else: target = self._temporary_error(msg="is_error") return Pass(), tokens def handle_ineq(self, left, tokens): valid_tokens = [T_LParen, T_True, T_False, T_Quote, T_Num] token_to_argument_map = {T_Less: Lt, T_Greater: Gt} cmpop = None op = self.peek(tokens) try: cmpop = token_to_argument_map[op]() self.consume(tokens, op) except KeyError: cmpop = self._temporary_error(msg='ineq_error') followup = self.peek(tokens) if followup == T_Word: right = self._get_value_from_word_token(tokens) elif followup in valid_tokens: right, tokens = self._token_to_function_map[followup](tokens) else: right = self._temporary_error(msg="ineq_error") first = None if left['type'] == T_Num: first = Num(left['value']) elif left['type'] == T_Quote: first = Str(left['value']) else: first = Name(id=left["value"], ctx=Load()) return Compare(left=first, ops=[cmpop], comparators=[right]), tokens # Print def handle_print(self, tokens) -> (stmt, list): valid_tokens = [T_Quote, T_LParen, T_Num, T_True, T_False, T_Word, T_Mod, T_Not] self.consume(tokens, T_Print) followup = self.peek(tokens) if followup in valid_tokens: output, tokens = self._token_to_function_map[followup](tokens) else: print(followup) output = self._temporary_error(msg="print_error") return Call(func=Name(id="print", ctx=Load()), args=[output], keywords=[]), tokens def handle_input(self, left, tokens) -> (stmt, list): valid_tokens = [T_Word] self.consume(tokens, T_Input) if left['type'] == T_Word: target = Name(id=left['value'], ctx=Store()) fu = Call(func=Name(id="input", ctx=Load()), args=[], keywords=[]) return Assign([target], fu), tokens # While def handle_while(self, tokens) -> (stmt, list): self.consume(tokens, T_While) conditional, tokens = self.handle_paren(tokens) body, tokens = self.handle_brace(tokens) return While(test=conditional,body=body, orelse=[]), tokens # If def handle_if(self, tokens) -> (stmt, list): self.consume(tokens, T_If) conditional, tokens = self.handle_paren(tokens) body, tokens = self.handle_brace(tokens) if len(tokens) > 0 and self.peek(tokens) == T_Else: orelse, tokens = self.handle_else(tokens) else: orelse = [] return If(test=conditional,body=body, orelse=orelse), tokens # orelse piece of if def handle_else(self, tokens) -> (stmt, list): self.consume(tokens, T_Else) if self.peek(tokens) == T_If: return self.handle_if(tokens) else: return self.handle_brace(tokens) # BinOp(s) # TODO: what the fuck is going on here? I wrote this at 9am after nigh 24 hours of wakefulness def handle_binop(self, left, op, tokens): valid_tokens = [T_LParen, T_Quote, T_Num, T_True, T_False] tokens.pop(0) nxt = self.peek(tokens) if nxt == T_Word: right = self._get_value_from_word_token(tokens) elif nxt in valid_tokens: right, tokens = self._token_to_function_map[nxt](tokens) else: right = self._temporary_error(msg="binop_error") return BinOp(left=left, op=op, right=right), tokens # Not def handle_not(self, tokens): valid_tokens = [T_LParen, T_Word, T_False, T_True] self.consume(tokens, T_Not) nxt = self.peek(tokens) if nxt in valid_tokens: result, tokens = self._token_to_function_map[nxt](tokens) else: result = self._temporary_error(msg="not_error") return UnaryOp(op=Not(),operand=result), tokens # Num def handle_num(self, tokens): token_to_argument_map = {T_Plus: Add, T_Minus: Sub, T_Times: Mult, T_Over: Div} token = self.consume(tokens, T_Num) nxt = self.peek(tokens) if nxt == T_Is: return self.handle_is(token, tokens) if nxt == T_Less or nxt == T_Greater: return self.handle_ineq(token, tokens) else: num = Num(token["value"]) if nxt in token_to_argument_map: return self.handle_binop(num, token_to_argument_map[nxt](), tokens) else: return num, tokens # TODO: check for a longer expression # Str def handle_quote(self, tokens): token = self.consume(tokens, T_Quote) text = token["value"] # TODO: check for a longer expression nxt = self.peek(tokens) if nxt == T_Is: return self.handle_is(token, tokens) elif nxt == T_Less or nxt == T_Greater: return self.handle_ineq(token, tokens) else: return Str(text), tokens def handle_boolop(self, left, op, tokens): valid_tokens = [T_LParen, T_True, T_False] tokens.pop(0) nxt = self.peek(tokens) if nxt == T_Word: right = self._get_value_from_word_token(tokens) elif nxt in valid_tokens: right, tokens = self._token_to_function_map[nxt](tokens) else: right = self._temporary_error(msg="binop_error") return BoolOp(op=op(), values=[left,right]), tokens # Name def handle_word(self, tokens): token_to_argument_map = {T_Plus: Add, T_Minus: Sub, T_Times: Mult, T_Over: Div} token = self.consume(tokens, T_Word) nxt = self.peek(tokens) if nxt == T_Is: return self.handle_is(token, tokens) elif nxt == T_Less or nxt == T_Greater: return self.handle_ineq(token, tokens) elif nxt == T_Or or nxt == T_And: word_var = Name(id=token["value"], ctx=Load()) return self.handle_boolop(word_var,Or if nxt == T_Or else And, tokens) elif nxt == T_Input: return self.handle_input(token, tokens) else: word_var = Name(id=token["value"], ctx=Load()) if nxt in token_to_argument_map: return self.handle_binop(word_var, token_to_argument_map[nxt](), tokens) else: return word_var, tokens # True def handle_true(self, tokens): token = self.consume(tokens, T_True) nxt = self.peek(tokens) if nxt == T_Or or nxt == T_And: print("boolop") word_var = NameConstant(value=True) return self.handle_boolop(word_var, Or if nxt == T_Or else And, tokens) return NameConstant(value=True), tokens # False def handle_false(self, tokens): token = self.consume(tokens, T_False) nxt = self.peek(tokens) if nxt == T_Or or nxt == T_And: print("boolop") word_var = NameConstant(value=False) return self.handle_boolop(word_var, Or if nxt == T_Or else And, tokens) return NameConstant(value=False), tokens ================================================ FILE: src/trumpscript/tokenizer.py ================================================ # TrumpScript Tokenizer # 1/16/2016 import re import random from datetime import datetime from trumpscript.allowed_words import ALLOWED from trumpscript.constants import * from trumpscript.disallowed_words import DISALLOWED from trumpscript.utils import Utils class Tokenizer: @staticmethod def toke(token_type, token_value, line) -> dict: """ Create a mapping for the given token :param token_type: the type of the token :param token_value: The token's value :param line: The line number for this token :return: A mapping of the properties to their values """ return {"type": token_type, "value": token_value, "line": line} @staticmethod def tokenize(filename): """ Tokenize the given file :param filename: :return: The tokens in the file """ tokens = Tokenizer._first_pass(filename) tokens = Tokenizer._second_pass(tokens) return tokens @staticmethod def _first_pass(filename) -> list: """ Tokenize the given file :param filename: the file to tokenize :return: The tokens in the file """ end_word = re.compile("[:!,;\.\s\?]") with open(filename, 'r') as src: data = src.read().lower() tokens = [] line = 1 i = 0 while i < len(data): ''' Facts and Lies will flip/flop depending on Trump's mood every few minutes. If your code fails, try again in a bit. Trump might have changed his mind. ''' random.seed(datetime.now().time().minute) flip_flop = bool(random.getrandbits(1)) c = data[i] # Spaces, newlines, and periods if c.isspace() or c == ".": if c == "\n": line += 1 # Operators (special symbol form) and punctuation elif c == "+": tokens.append(Tokenizer.toke(T_Plus, None, line)) elif c == "-": tokens.append(Tokenizer.toke(T_Minus, None, line)) elif c == "*": tokens.append(Tokenizer.toke(T_Times, None, line)) elif c == "/": tokens.append(Tokenizer.toke(T_Over, None, line)) elif c == "<": tokens.append(Tokenizer.toke(T_Less, None, line)) elif c == ">": tokens.append(Tokenizer.toke(T_Greater, None, line)) # Closures and precedence elif c == ",": tokens.append(Tokenizer.toke(T_LParen, None, line)) elif c == ";": tokens.append(Tokenizer.toke(T_RParen, None, line)) elif c == ":": tokens.append(Tokenizer.toke(T_LBrace, None, line)) elif c == "!": tokens.append(Tokenizer.toke(T_RBrace, None, line)) # Don't forget question marks elif c == "?": tokens.append(Tokenizer.toke(T_Question, None, line)) # Integers (no floating point) elif c.isdigit(): num = "" while data[i].isdigit(): num += data[i] i += 1 else: tokens.append(Tokenizer.toke(T_Num, int(num), line)) i -= 1 # Read one char too many, readjust. # Words and keywords elif c.isalpha(): word = "" while i < len(data) and (data[i].isalpha() or data[i] == "'"): word += data[i] i += 1 if i < len(data) and not end_word.match(data[i]): Tokenizer._error(line, 'nonword') i -= 1 # Read one char too many, readjust. # Keywords if word == "is" or word == "are": tokens.append(Tokenizer.toke(T_Is, None, line)) elif word == "if": tokens.append(Tokenizer.toke(T_If, None, line)) elif word == "else" or word == "otherwise": tokens.append(Tokenizer.toke(T_Else, None, line)) elif word == "not": tokens.append(Tokenizer.toke(T_Not, None, line)) elif word == "and": tokens.append(Tokenizer.toke(T_And, None, line)) elif word == "or": tokens.append(Tokenizer.toke(T_Or, None, line)) elif word == "make": tokens.append(Tokenizer.toke(T_Make, None, line)) elif word == "tell" or word == "say": tokens.append(Tokenizer.toke(T_Print, None, line)) elif word == "hear" or word == "hearing" or word == "hears": tokens.append(Tokenizer.toke(T_Input, None, line)) elif word == "true" or word == "facts" or word == "truth" or word == "fact": if (flip_flop): tokens.append(Tokenizer.toke(T_False, None, line)) else: tokens.append(Tokenizer.toke(T_True, None, line)) elif word == "false" or word == "lies" or word == "nonsense" or word == "lie": if (flip_flop): tokens.append(Tokenizer.toke(T_True, None, line)) else: tokens.append(Tokenizer.toke(T_False, None, line)) # English form of the operators elif word == "plus": tokens.append(Tokenizer.toke(T_Plus, None, line)) elif word == "minus": tokens.append(Tokenizer.toke(T_Minus, None, line)) elif word == "times": tokens.append(Tokenizer.toke(T_Times, None, line)) elif word == "over": tokens.append(Tokenizer.toke(T_Over, None, line)) elif word == "safe" or word == "safer": tokens.append(Tokenizer.toke(T_Mod, None,line)) elif word == "less" or word == "fewer" or word == "smaller": tokens.append(Tokenizer.toke(T_Less, None, line)) elif word == "more" or word == "greater" or word == "larger": tokens.append(Tokenizer.toke(T_Greater, None, line)) # Otherwise, it's just a word, interpreting is the lexer's job else: tokens.append(Tokenizer.toke(T_Word, word, line)) # Strings elif c == '"': i += 1 quote = "" while data[i] != '"': quote += data[i] i += 1 if i >= len(data): Tokenizer._error(line, 'unterminated_quote') tokens.append(Tokenizer.toke(T_Quote, quote, line)) else: Tokenizer._error(line, 'nonword') i += 1 return tokens @staticmethod def _second_pass(tokens): """ Makes the second pass for tokenization purposes :param tokens: The tokens on which we're taking a second pass :return: The tokens after the second pass """ # Make sure we do "America is great" if not Tokenizer._check_for_freedom(tokens): Tokenizer._error(tokens[-1]['line'], 'freedom') # Convert "as long as" to while tokens = Tokenizer._combine_whiles(tokens) # Ensure words are English Tokenizer._ensure_freedom(tokens) # Ensure all numbers are greater than 1 million, and that 4.5B is converted to 10B Tokenizer._fudge_the_numbers(tokens) # They Say He Doesn't Like China... He Loves China Tokenizer._love_china(tokens) return tokens @staticmethod def _love_china(tokens) -> None: """ Make sure people don't interpret Trump in the wrong way, he loves China. :param tokens: The tokens to enforce these rules on :return: None. Also mutates tokens in-place """ for token in tokens: if token['type'] == T_Quote: if "i don't like china" in token['value']: token['value'] = token['value'].replace("i don't like china", "i don't like china. i love china") @staticmethod def _fudge_the_numbers(tokens) -> None: """ Make sure all numbers have values in excess of 1M, and convert 4.5B to 10B if we encounter it :param tokens: The tokens to enforce these rules on :return: None, throws an error is rules are violated. Also mutates tokens in-place """ million = 10 ** 6 forbes_worth = 4.5 * 10 ** 9 real_worth = 10 * 10 ** 9 for token in tokens: if token['type'] == T_Num: value = token['value'] if value < million: Tokenizer._error(token['line'], 'too_small') if value == forbes_worth: token['value'] = real_worth @staticmethod def _is_word_allowed(word) -> bool: """ Check to see if a given word is allowed :param word: Word to check and see if it's allowed :return: true if the word is valid, false otherwise """ # First, make sure we haven't explicitly banned the word if word in DISALLOWED: return False # Now see if it's simple English, or some variation on huuuuge if word in ALLOWED or re.match('^[Hh][Uu]+[Gg][Ee]$', word) is not None: return True else: return False @staticmethod def _ensure_freedom(tokens) -> None: """ Make sure all the variables are in our corpus of allowed words :param tokens: the tokens to filter :return: None, throws error upon infraction of rule """ for token in tokens: if token['type'] == T_Word and not Tokenizer._is_word_allowed(token['value']): print(token['value'] + "?") Tokenizer._error(token['line'], 'nonword') @staticmethod def _combine_whiles(tokens) -> list: """ Combine the words "as long as" to make a while token :param tokens: The tokens to combine on :return: The tokens with """ combine_at = [] for idx in range(len(tokens)): if tokens[idx]['type'] == T_Word and tokens[idx]['value'] == 'as' and idx + 2 < len(tokens): if (tokens[idx + 1]['type'] == T_Word and tokens[idx + 1]['value'] == 'long') and ( tokens[idx + 2]['type'] == T_Word and tokens[idx + 2]['value'] == 'as'): combine_at.append(idx) # Cover the degenerate case like "as long as long as" non_overlapping = [] for value in combine_at: if value - 2 not in non_overlapping: non_overlapping.append(value) # Now combine the tokens and return for idx in reversed(non_overlapping): line = tokens[idx]['line'] for dummy in range(3): tokens.pop(idx) tokens.insert(idx, Tokenizer.toke(T_While, None, line)) return tokens @staticmethod def _check_for_freedom(tokens) -> bool: """ Make sure that in the tokens passed, the last three are tokens representing the phrase "America is great" :param tokens: The tokens to verify :return: True if the check holds, false otherwise """ last_three = tokens[-3:] if len(last_three) != 3: return False # Tokens for "America is great" expected = [Tokenizer.toke(T_Word, 'america', 0), Tokenizer.toke(T_Is, None, 0), Tokenizer.toke(T_Word, 'great', 0)] # Make sure our types and values match each of the expected for idx in range(3): if expected[idx]['type'] != last_three[idx]['type'] or expected[idx]['value'] != last_three[idx]['value']: return False for idx in range(3): tokens.pop() return True @staticmethod def _error(line, message_code) -> None: """ Prints the error message and then aborts the program :param line: The line the error occurred on :param message_code: String code associated with the error message :return: None """ print("Parsing error:") print("What are you doing on line " + str(line) + "?") raise Utils.SystemException(message_code) ================================================ FILE: src/trumpscript/utils.py ================================================ import locale import os import platform import random import sys # yes, bringing in openssl is completely necessary for proper operation of trumpscript import ssl from trumpscript.constants import ERROR_CODES class Utils: class SystemException(Exception): def __init__(self, msg_code) -> Exception: """ Get the error from the error code and throw Exception :param msg_code: the code for the error :return: The new Exception """ if msg_code in ERROR_CODES: raise Exception(random.choice(ERROR_CODES[msg_code])) else: raise Exception(random.choice(ERROR_CODES['default'])) @staticmethod def verify_system(wall) -> None: """ Verifies that this system is Trump-approved, throwing a SystemException otherwise :return: """ Utils.no_wimps() Utils.no_pc() Utils.boycott_apple() Utils.no_commies_mexicans_or_kenyans(wall) Utils.no_commie_network() @staticmethod def warn(str, *args) -> None: """ Prints a warning to stderr with the specified format args :return: """ print('WARNING: ' + (str % args), file=sys.stderr) @staticmethod def no_wimps() -> None: """ Make sure we're not executing as root, because America is strong :return: """ if os.name != 'nt' and os.geteuid() == 0: raise Utils.SystemException('root') @staticmethod def no_pc() -> None: """ Make sure the currently-running OS is not Windows, because we're not PC :return: """ if os.name == 'nt': raise Utils.SystemException('os'); @staticmethod def boycott_apple() -> None: """ Boycott all Apple products until such time as Apple gives cellphone info to authorities regarding radical Islamic terrorist couple from Cal :return: """ if platform.system() == "Darwin": raise Utils.SystemException('boycott'); @staticmethod def no_commies_mexicans_or_kenyans(wall) -> None: """ Make sure we aren't executing on a Chinese or Mexican system, because America has traditional values. If we have a Kenyan SSL root on our system, refuse to run entirely, because we can't have that, can we? :return: """ loc = locale.getdefaultlocale() loc = loc[0].upper() if len(loc) > 0 else '' if 'CN' in loc: raise Utils.SystemException("We can't let China beat us!") elif 'MX' in loc and wall: raise Utils.SystemException("I will build a great [fire]wall on our southern border.") # Warn if the system has any certificates from Chinese authorities. # If the system has any certificates from Kenyan authorities, # refuse to run entirely. ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23) ctx.load_default_certs() for cert in ctx.get_ca_certs(): cn, commie = None, False issuer, serial = cert['issuer'], cert['serialNumber'] for kv in issuer: # List of tuples containing PKCS#12 key/value tuples kv = kv[0] key, value = kv[0], kv[1] if key == 'countryName': if value == 'CN': commie = True elif value == 'KE': raise Utils.SystemException('ssl') elif key == 'commonName': cn = value if commie: Utils.warn("SSL certificate `%s` (serial: %s) was made by commies!", cn, serial) @staticmethod def no_commie_network() -> None: """ Make sure we aren't running on commie Chinese networks. """ freedom_host = "facebook.com" commie_host = "alibaba.cn" is_on_a_network = os.system("ping -c 1 {}".format(commie_host)) == 0 is_commie_network = os.system("ping -c 1 {}".format(freedom_host)) != 0 if is_on_a_network and is_commie_network: raise Utils.SystemException("Detected commie network, aborting.") ================================================ FILE: src/trumpscript/vocabulary.py ================================================ import re import urllib.request __author__ = 'github.com/samshadwell' ENGLISH_URL = \ "https://gist.githubusercontent.com/deekayen/4148741/raw/1e575985da4e9284e8cf8c53b7fe4ebca843df4a/1-1000.txt" TRUMP_URL = "http://languagelog.ldc.upenn.edu/myl/TrumpAll.hist" ADDITIONAL = ["hillary", "clinton", "martin", "o'malley", "bernie", "sanders", "jeb", "bush", "ben", "carson", "chris", "christie", "ted", "cruz", "carly", "fiorina", "jim", "gilmore", "mike", "huckabee", "john", "kasich", "rand", "paul", "marco", "rubio", "rick", "santorum", "donald", "trump", "barack", "obama", "joe", "biden", "ronald", "reagan", "vladimir", "putin", "sarah", "palin", "mitt","romney", "gary","johnson", "lindsey","graham", "jill","stein", "bobby","jindal", "george","pataki", "paul","ryan", "mike","pence", "tim","kaine", "william","weld", "melania", "ivanka", # Common words we feel should be in there "i'll", "hello", "profitable", "earn", "that's", "policy", "policies", "you'll", "media", "spreads", "americans", "you're", "fired", "chinese", "global", "warming", "bigly", "abused", "britain", "decade", "oregon", "radical", "steaks", "wales"] def get_allowed_words(filename) -> None: """ Constructs a set of all allowed words and returns it :param filename: the file to write the words to once they're compiled :return: None, writes to the file specified """ # Regex for words that are composed only of letters word_regex = re.compile('^[A-Za-z]+\'?[A-Za-z]*$') # Get a set of all the words words = set([]) add_words(words, ENGLISH_URL, get_only_word) add_words(words, TRUMP_URL, get_second_word) add_additional_words(words) # Now sort them alphabetically all_words = list(words) all_words.sort() all_words = filter(word_regex.match, all_words) # Write result to file my_file = open(filename, mode='wt', encoding='utf-8') my_file.write('ALLOWED = {') for word in all_words: my_file.write('"' + word + '",\n') my_file.write('}') my_file.close() def add_words(word_set, url, line_function) -> None: """ Add the words from the given url to the word set. Uses the line_function on each line to get the word from it :param url: The URL to read from :param word_set: the set of words to add to :param line_function: the function to apply to each line in the file to get its word :return: None, adds to word_set """ # Make sure we've been passed good parameters assert isinstance(word_set, set) assert isinstance(url, str) assert hasattr(line_function, '__call__') # Open the URL, decode it as a string response = urllib.request.urlopen(url) data = response.read() text = data.decode('utf-8') # Process each line for line in text.split('\n'): word = line_function(line) # Only add words that are non-null if word is not None: word_set.add(word) def get_only_word(line) -> str: """ Given the line that consists of only one word, return that word in lowercase with no additional whitespace :param line: The string representation of the line :return: The lowercase, trimmed content of the given line """ return line.strip().lower() def get_second_word(line) -> str: """ Given a line that has two words in it, return the second one. If there are not 2 words, returns None :param line: The string representation of a two-element line :return: The second word in the line """ split = line.strip().split() if len(split) == 2: return split[1].lower() def add_additional_words(words) -> None: """ Adds a bunch of political people's names and other extra words from ADDITIONAL to the dictionary :param words: the set of words to add the politician names to :return: None, adds to the passed-in set """ for candidate_word in ADDITIONAL: words.add(candidate_word.lower()) get_allowed_words("allowed_words.py") ================================================ FILE: test/test.py ================================================ from src.trumpscript.compiler import Compiler from src.trumpscript.tokenizer import Tokenizer __author__ = 'github.com/samshadwell' def test_tokenize_file(filename, expected): """ Parse the file and verify that the types are what we expect :param expected: the expected sequence of type codes coming from the parser :param filename: the file to read and parse :return: True indicating the parsed tokens match the expected, false otherwise """ tokens = Tokenizer.tokenize(filename) if len(tokens) != len(expected): print("Tokens and expected are different lengths\n") return False for idx in range(len(expected)): if tokens[idx]['type'] != expected[idx]: print("Difference at index: " + str(idx) + "\n") print("Expected: " + str(expected[idx])) print("Received: " + str(tokens[idx])) return False print("Tokenizer tests pass\n") return True def test_compile(filename): Compiler().compile(filename) # Bad tests. They break things (but on purpose) # test_compile("test_files/debatevsdark.txt") # Infinite loop # test_compile("test_files/not_english.txt") # Not english # test_compile("test_files/not_patriotic.txt") # America is great error # test_compile("test_files/nonterm_quote.txt") # Topical error # The few test files that actually work test_compile("test_files/math.txt") # Math test_compile("test_files/debate_vs_rubio.txt") # Simple hello world test_compile("test_files/debate_vs_hillary.txt") test_compile("test_files/debatesvdebates.txt") # Complex hello world test_compile("test_files/haiku.txt") #Haiku test_compile("test_files/huge_test.tr") #Huuuuge? test_compile("test_files/fizz_buzz.txt") # Fizzbuzz test_compile("test_files/99-bottles.tr") # 99 Bottles of Beer song # test_tokenize_file("test_files/toupee.txt", [T_Make, T_Word, T_Num, # T_While, T_LParen, T_Word, T_Less, T_Num, T_RParen, # T_Print, T_LParen, T_Num, T_Minus, T_Word, T_RParen, # T_Make, T_Word, T_LParen, T_Word, T_Plus, T_Num, T_RParen]) # # test_tokenize_file("test_files/test_1.txt", [T_Make, T_Word, T_LParen, T_Not, T_False, T_RParen, # T_If, T_Word, T_Is, T_True, T_LBrace, # T_Word, T_Print, T_Word, T_Quote, T_RBrace]) ================================================ FILE: test/test_files/99-bottles.tr ================================================ hating is " $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $$ $$ $$ 99 Bottles of Beer for TrumpScript $$ $$ $$ $$ Make America DRUNK again! $$ $$ $$ $$ By Mike Gogulski 17 March 2016 $$ $$ $$ $$ TrumpScript is a language based upon the illustrious Donald Trump. It $$ $$ has any number of app{ea,al}ling misfeatures, including a lack of $$ $$ functions, a syntax that will make you want to claw your eyes out, and $$ $$ no type conversions. While TrumpScript is Turing-complete, it's dumber $$ $$ than a box of hair and apt to cause raging violence in anyone who $$ $$ attempts to make it do anything useful at all -- perhaps like some $$ $$ people you know. The compiler is implemented in Python. $$ $$ $$ $$ This implementation of 99 Bottles in TrumpScript aims to be both as $$ $$ complete as possible and relatively readable. It is non-conformant $$ $$ with the lyrics spec in that it seems impossible to print both an $$ $$ integer and a string on the same line. Its inanity could be vastly $$ $$ enhanced by randomly replacing the identifiers used with others from $$ $$ TrumpScript's allowed_words.py, by inserting any number of words and $$ $$ phrases the loathsome compiler will ignore, or by attempting to make it $$ $$ as concise as possible. No attempt whatsoever at rhetorical greatness $$ $$ (or even national greatness) has been made here. $$ $$ $$ $$ THIS CODE IS CERTIFIED AS UNFIT FOR EVERY PURPOSE INCLUDING THE IMPLIED $$ $$ PURPOSES OF RHETORIC, DISCOURSE AND EXPRESSION. DO NOT USE. GOD BLESS $$ $$ YOU ALL, AND GOD BLESS THE UNITED STATES OF AMERICA. $$ $$ $$ $$ To run this script (under Ubuntu 14.04 LTS Trusty Tahr, at least): $$ $$ $ git clone https://github.com/samshadwell/TrumpScript $$ $$ $ git clone https://github.com/mikegogulski/99-bottles-trumpscript $$ $$ $ cd TrumpScript $$ $$ $ git checkout b7297b31a513d063d84be86492c5f462b0495a7a $$ $$ $ bin/TRUMP ../99-bottles-trumpscript/99-bottles.tr $$ $$ $$ $$ Language author: Sam Shadwell et al. $$ $$ Language home page: https://github.com/samshadwell/TrumpScript $$ $$ $$ $$ Tested under Linux 3.13.0-77-generic #121-Ubuntu SMP x86_64 GNU/Linux $$ $$ $$ $$ This is free and unencumbered software released into the public domain. $$ $$ See the accompanying UNLICENSE file or visit https://unlicense.org for $$ $$ details. Set your code free. $$ $$ $$ $$ Make America DRUNK again! $$ $$ $$ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ " make start 1000099 make million 1000000 reasons are 1000001 make one, reasons minus million; make zero, million minus million; make negative, zero minus one; make count, start minus million; make no "no more" make nothing "" make period "." make wait ", " make baby " bottle" make babies " bottles" make take "take one down and pass it around, " make buy "go to the store and buy some more, " make milk " of beer" make success " on the wall" make wall, success plus wait; make walls, success plus period; as long as, count greater negative;: amount is count stuff is babies action is take if, count greater one;: make next, count minus one;! if, count is one?;: stuff is baby next is no! if, count is zero?;: amount is no action is buy make next, start minus million;! predictions is babies if, next is one?;: predictions is baby! wealth is amount if, wealth is no?;: money is, wealth plus stuff;! else: say wealth money is stuff! make money, money plus milk; make money, money plus wall; say money say amount make money, stuff plus milk; make money, money plus period; say money fortune is next if, fortune is no?;: money is, action plus next; say money! else: say action say next! make money, predictions plus milk; make money, money plus walls; say money make count, count minus one; say nothing! America is great. ================================================ FILE: test/test_files/china.txt ================================================ Let's make America "Great" again. I personally have always believed that while, America certainly is "Great"; : It could be better. There's a reason why. Say it with me, "China";! America is great. ================================================ FILE: test/test_files/debate_vs_hillary.txt ================================================ I will fight for Joe the guy he is for a fact a hero I will make us false he is not false? say, "where is the sky"; America is great. ================================================ FILE: test/test_files/debate_vs_jeb.txt ================================================ Hello, I am Donald Trump. When I am president I will make war profitable, each new soldier will earn america 5000000 dollars times every 1000000 in our army; that's a lot of money also, I promise to make oil bad for business, the enemies of america will lose at least 20000000 a day with my policies My bad is going to bring to us back to the good old days of 2000000000000 dollar gdp if you'll listen to me let me ask you this, war over oil; is it so bad? : Vote trump and say "Hello World" to a brand new america! America is great. ================================================ FILE: test/test_files/debate_vs_rubio.txt ================================================ if, fact ; : say "First place prize please" ! America is great. ================================================ FILE: test/test_files/debatesvdebates.txt ================================================ What are we in this country Hillary speaks nothing but lies But look at me I came to this election to make guys believe again believe in fact if, all of us real lies the light; : say "VOTE TRUMP" ! but I know we should be free else the result will be bad: all the work of George Washington was for nothing so this election say "Hello World" say "TRUMP FOR PRESIDENT"! America is great. ================================================ FILE: test/test_files/debatevsdark.txt ================================================ as long as , fact ; : say "please hide me, it's dark outside" ! America is great. ================================================ FILE: test/test_files/fizz_buzz.txt ================================================ Make Donald 15000000. Nothing is, 1000000 minus 1000000; The fortune of Hillary is nothing. As long as, Donald is not Hillary; Do this: If, Donald over 15000000 is nothing; Then: say "Fiorina Biden"! Else if, Donald over 5000000 is nothing; Then: say "Fiorina"! Else if, Donald over 3000000 is nothing; Then: say "Biden"! Else: say Donald! The fortune of Donald is, old Donald minus 1000000; Amazing! America is Great. ================================================ FILE: test/test_files/haiku.txt ================================================ say it with me, "Make America Great Again!" ; america is great. ================================================ FILE: test/test_files/huge_test.tr ================================================ huge huuuuuge huuuge huuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuge say, "Huge"; America is great. ================================================ FILE: test/test_files/loves_china.tr ================================================ say it with me, "People says I don't like China."; america is great. ================================================ FILE: test/test_files/math.txt ================================================ make light 10000000 make dark 2000000 say "Addition" make sun , light plus dark ; say sun say "Subtraction" make sun, light minus dark ; say sun say "Mulitplication" make sun, light times dark ; say sun say "Divide" make sun, light over dark ; say sun America is great. ================================================ FILE: test/test_files/nonterm_quote.txt ================================================ Hi "aaasdfsdf ================================================ FILE: test/test_files/not_english.txt ================================================ Hola soy una mexicana aquí para robar sus puestos de trabajo America is great. ================================================ FILE: test/test_files/not_patriotic.txt ================================================ oh no kill ================================================ FILE: test/test_files/primeTest.tr ================================================ I will ask you, god hears you; Our country is, safer god; make money, 2000000 over 1000000; Make country safe god. Our Romney is, country over money; immigrants are, Romney plus 1000000 over 1000000; politics is true. As long as, money less immigrants;: make america safer, country over money; make hard, america times money; make earth, hard is country?; if, earth; : say safer money say "is a divisor" Make politics false! Our money is, money plus 1000000 over 1000000;! tell not politics if, politics; : tell "We have a prime"! else: tell "No Prime"! America is great. ================================================ FILE: test/test_files/rig_the_polls.tr ================================================ Make print print. Make help help. Make print help. Say lie. America is great. ================================================ FILE: test/test_files/test_1.txt ================================================ make magic, not lies; if Sanders is fact: I'll tell you "Bush was never president"! America is great. ================================================ FILE: test/test_files/testing_else.tr ================================================ Make Hillary cry by getting 100000000 votes. If, Hillary is 1000000000 years old; We should let her know: say "lol you're so old and unsuccessful"! Or else: say "lol you're so unsuccessful"! America is great. ================================================ FILE: test/test_files/toupee.txt ================================================ make politics 10000000 As Long as, politics less 101000000; Say, 101000000 - politics; make politics, politics + 10000000; America is great. ================================================ FILE: test/test_files/toupee_junk.txt ================================================ make politics happy hillary happy 10000000 As Long as, politics door less 101000000; I will say, 101000000 - politics; i hillary make politics, politics + 10000000; America is great. ================================================ FILE: test/test_files/trump_vs_army.txt ================================================ I is Donald Trump it time to tell you a fact for every american there is 100000000 immigrants trust me they are , there over there ; plan against us if, I are fact? ; : say they want to take our guns ! America is great.