├── CONTRIBUTING.md
├── README.md
├── assets
├── ddd.png
├── enterprise-folder-struct.png
├── graph.png
├── growth.png
├── logo.png
└── stars.png
├── index.js
├── node
├── .gitignore
├── .node-version
├── .npmrc
├── CONTRIBUTING.md
├── CompileError.js
├── E™
├── README.md
├── ast.js
├── compile.js
├── disruptiveLibs
│ ├── dlIOReadDelegator.js
│ ├── dlIOWriteDelegator.js
│ └── dlStringContainsDelegator.js
├── dls.js
├── enterprise.js
├── enterprise.peg
├── examples
│ ├── fdcFizzBuzzDelegator.E™
│ └── fdcUnicornEvaluator.E™
├── fdcFizzBuzzDelegator.E™
├── package.json
└── yarn.lock
└── rust
├── .gitignore
├── Cargo.lock
├── Cargo.toml
├── README.md
└── src
├── e.pest
├── lib.rs
├── main.rs
├── parser.rs
└── samples
├── fdcFizzBuzzDelegator.E™
└── fdcUnicornEvaluator.E™
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing to Enterprise™
2 |
3 | ### Your rights
4 |
5 | By sending any contribution, be it in form of a PR, issue, comment or any other
6 | conceivable way, you forfeit all your rights to your addition. Any attempt to
7 | copy, sell or profit from it in any way is in violation of Enterprise™'s terms
8 | of contributions.
9 |
10 | ### Code of conduct
11 |
12 | Enterprise™ promotes diversity and will accept contributions from everyone, as
13 | long as the particular contributor fits our definition of diversity, which is
14 | under our discretion.
15 |
16 | ### How to best help
17 |
18 | 1. Features over bugs
19 |
20 | Found a bug? It's fine to fix it, unless there's a disruptive feature to be
21 | implemented. We prioritize empowering Enterprise™ developers to disrupt, even
22 | if there are some rough edges. Remember
23 |
24 | > If you’re not embarrassed by the first version of your product,
25 | > you’ve launched too late.
26 |
27 | 2. Disrupt. Disrupt. Disrupt.
28 |
29 | Incremental improvements? Forget it. Send bold ideas. Think outside the box.
30 | Be different. Just do it.
31 |
32 | 3. Focus on user base
33 |
34 | Porting Enterprise™ to Haskell? Don't sweat. JVM? Cloud? Crypto dockerized
35 | block chains? Bring it.
36 |
37 | 4. Commit messages
38 |
39 | Don't sweat, no one reads 'em. Add some ™™™™s for the stylish effect.
40 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Enterprise™
2 |
3 |
4 | > Extra! Extra! * [Disruption Driven Development - Mastering Enterprise™ – the book is in the making!](#ddd---the-book)
5 |
6 |
7 |
8 |
9 |
10 |
11 | Enterprise™ is a non-deterministic-unnecessarily-statically-typed™
12 | Turing-complete-ish™, [Quantum-out-of-the-box™](https://github.com/joaomilho/Enterprise/issues/41) programming language.
13 |
14 | Enterprise™ is designed to create computer programs that disrupt markets.
15 |
16 | ### But why?
17 |
18 | Following on the footsteps of [Rockstar](https://github.com/dylanbeattie/rockstar),
19 | if we make Enterprise™ a real thing, then recruiters and hiring managers won't be
20 | able to talk about 'enterprise developers' any more.
21 |
22 | On top of that, articles about the "Best Programming Languages for Enterprise
23 | Development" will lose their meaning.
24 |
25 | ## Enterprise™ guide
26 |
27 | * [Specs](#specs)
28 | * [Comments](#chapter-1-comments)
29 | * [Classes](#chapter-2-classes)
30 | * [Extensions and file structure](#chapter-3-extensions-and-file-structure)
31 | * [Variables and types](#chapter-4-variables-and-types)
32 | * [Operations](#chapter-5-operations)
33 | * [Disruptive libraries](#chapter-6-disruptive-libraries)
34 | * [Control structures](#chapter-7-control-structures)
35 | * [Implementations](#implementations)
36 | * [Why learning Enterprise™?](#why-learning-enterprise)
37 | * [Disruption Driven Development - The Book](#ddd---the-book)
38 | * [Roadmap](#roadmap)
39 |
40 | ## Specs
41 |
42 | Following are the specifications of the Enterprise™ language.
43 |
44 | ### Chapter 1: Comments
45 |
46 | The most important bits in the Enterprise™ are comments. There are 8 different
47 | types of comments in Enterprise™. Some of them are found in languages not ready
48 | for corporate usage like:
49 |
50 | ##### line comment
51 |
52 | ```java
53 | // this is a boring line comment
54 | ```
55 |
56 | The line comment is useful when you want to restate what the next line does.
57 | Here's an idiomatic example:
58 |
59 | ```java
60 | // adds one to counter
61 | counter++;;;
62 | ```
63 |
64 | ##### block comment
65 |
66 | ```java
67 | /*
68 | this is a block comment
69 | */
70 | ```
71 |
72 | The block comment is useful when a comment is long, like explaining some
73 | implementation:
74 |
75 | ```java
76 | /*
77 | The International Enterprise™ Association only certifies code with a block
78 | comment that exceeds three lines, so this comment guarantees our future
79 | certification.
80 | (line intentionally left blank, to ensure "exceeding" three lines)
81 | */
82 | ```
83 |
84 | On top of these, Enterprise™ adds:
85 |
86 | ##### copyright comment
87 |
88 | ```
89 | /©
90 | This code is property of ACME™ studios 2017.
91 | ©/
92 | ```
93 |
94 | Every Enterprise™ program _must_ begin with a copyright notice, else it will
95 | not compile and fail with an `UnexpectedNonDisruptiveOpenSourceException` error.
96 |
97 | It's customary to cover any non trivial implementation in Enterprise™ with a
98 | copyright (and a comment). On top of that add an NDA comment (see below).
99 |
100 | ##### NDA comment
101 |
102 | ```
103 | /©
104 | This following code implements a "Web Dropdown Menu", copyright number 9283F3.
105 | ©/
106 | /NDA
107 | The following code can only be read if you signed NDA 375-1. If you happen to
108 | read it by mistake, send a written letter to our legal department with two
109 | attached copies immediately.
110 | NDA/
111 | ```
112 |
113 | ##### passive aggressive comment
114 |
115 | ```
116 | /?
117 | This next bit is oh so lovely
118 | ?/
119 | ```
120 |
121 | Things like irony may be a problem in communication. To solve this problem
122 | and ensure proper communication, Enterprise™ adds a passive aggressive comment,
123 | so the reader _must_ assume the opposite.
124 |
125 | ##### interview comment
126 |
127 | Since Enterprise™ will be widely used for job interviews, the interview comment
128 | is very handy to "explain how you reason" to your interviewer:
129 |
130 | ```
131 | /¯\_(ツ)_/¯
132 | ...this could be done in O(1) if I had the time...
133 | ¯\_(ツ)_/¯/
134 | ```
135 |
136 | ##### time to market comment
137 |
138 | ```
139 | /soon 1985-11-20
140 | using a while here would be more performatic
141 | soon/
142 | ```
143 |
144 | If you can't write the best implementation Today, use an improve in the future
145 | comment, to ensure it will be done some day. Adding the current day in the
146 | comment is part of its syntax, so one doesn't lose track of oldest comments.
147 |
148 | ##### deadline comment
149 |
150 | Deadline comments are extremely important to have our code disrupting the market
151 | on time, seizing all the opportunity costs. Deadline comments also have a date
152 | attached.
153 |
154 | ```
155 | /deadline 1997-01-11
156 | We need to ship this game before Xmas. No delays accepted.
157 | deadline/
158 | /deadline 1998-01-11
159 | We need to ship this game before Xmas, we already lost the previous one.
160 | deadline/
161 | /deadline 1999-01-11
162 | We need to ship this game before Xmas, this time for real.
163 | deadline/
164 | /deadline 2000-01-11
165 | The board is extremely impatient. No excuses this time.
166 | deadline/
167 | /deadline 2002-01-11
168 | Come on people, they just gave us a 2 years extension after that horrible
169 | meeting. Let's not let 'em down this time.
170 | deadline/
171 | /deadline 2005-01-11
172 | Ok... this game may not happen and we may throw this 8 year old effort in
173 | the wastebin of History if we don't get this done. Blogs are making a joke of
174 | us. Think about your families.
175 | deadline/
176 | /deadline 2011-01-11
177 | I don't know what to say. This is the biggest delay in game History. We're a
178 | laughingstock.
179 | deadline/
180 | /soon 2011-01-11
181 | We delivered! But we probably need to refactor everything very soon if we're
182 | to have a next release.
183 | soon/
184 | ```
185 |
186 | ### Chapter 2: Classes
187 |
188 | #### naming
189 |
190 | Classes are named with Hungarian Case. Hungarian Case is similar to Pascal Case,
191 | but is prefixed with one or more type characters (see more below). A class must
192 | end with an Enterprisey™ suffix (these suffixes are copyrighted and any use in
193 | other languages may be investigated by our lawyers).
194 |
195 | Type characters applicable to classes:
196 |
197 | * `fdc` final disruptive class
198 | * `fuc` final unnecessary class
199 |
200 | #### Enterprisey™ terms:
201 |
202 | After the prefix, a class name may have any number of Enterprisey™ terms. In
203 | Enterprise™, differently from other languages, class names are not open to
204 | developers' "cre-a-ti-vi-ty". That's because naming is known to be a hard
205 | problem, and limiting the alternatives makes it so much more predictable. Also,
206 | forcing developers to comply with that list will boost communication, since
207 | they'll share a common lingo.
208 |
209 | Here's the full list of accepted Enterprisey™ terms:
210 |
211 | ||||||||
212 | |-|-|-|-|-|-|-|
213 | |Accelerate|Acceleration|Account|Active|Activity|Agile|Agility|
214 | |Ajax|Algo|Analytics|Analyze|Analyzer|Ballpark|Bean|
215 | |Big|Bit|Bizmeth|Block|Boost|Bootstrap|Bootstraped|
216 | |Brand|Business|Buzz|Car|Chain|Chart|Clickthrough|
217 | |Cloud|Coin|Consumer|Content|Converge|Convergence|Coordinate|
218 | |Coordinator|Complex|Convert|Convertion|Cost|Costs|Critical|
219 | |Crypto|Currency|Customer|Cyber|Data|Deep|Delegate|
220 | |Delegator|Design|Dev|Develop|Development|Digital|Disrupt|
221 | |Disruptor|Disruptive|Diverse|Diversify|Diversifier|Diversity|Downsize|
222 | |Downsized|Drive|Driven|Driver|Economy|Economic|Employ|
223 | |Employee|Employer|Empowered|Engine|Enterprise|Entrepreneur|Entropy|
224 | |Equity|Evolution|Evolve|Evolving|Eyeball|Eyeballs|Facade|
225 | |Factory|Fast|Fee|Fizz|Flat|Founder|Founders|
226 | |Framework|Free|Future|Fuzzy|Generate|Generation|Generator|
227 | |Global|Gluten|Graph|Graphic|Group|Growth|Guideline|
228 | |Guidelines|Hack|Hacking|Hardware|Holistic|Human|Hyperlocal|
229 | |Immerse|Immersion|Immersive|Innovate|Innovative|Innovativity|Innovator|
230 | |Internet|Intranet|Invest|Investment|Item|Iterator|Java|
231 | |Lactose|Learn|Learning|Leverage|Line|List|Manage|
232 | |Management|Manager|Market|Marketing|Media|Mega|Merchant|
233 | |Message|Micro|Millenial|Mindshare|Mine|Mining|Mission|
234 | |Module|Momentum|Money|Nano|Network|New|Next|
235 | |Number|Nut|Object|Operation|Operator|Opportunity|Ops|
236 | |Order|Organic|Paradigm|Passionate|Pattern|Person|Pie|
237 | |Point|Policy|Portal|Product|Proof|Provable|Proxy|
238 | |Resource|Return|Roadmap|Scalable|Science|Self|Service|
239 | |Services|Share|Sharing|Simple|Skeuomorphic|Speed|Software|
240 | |Solution|Square|Startup|Streamline|Streamlined|Super|Sustainability|
241 | |Sustainable|Synergic|Synergy|System|Tax|Text|Time|
242 | |Trade|Trans|Upsize|Upsizer|User|Viral|Virality|
243 | |Viralize|Visual|Web|World|
244 |
245 | On top of these terms, you can use any upcase char (A-Z) and number, like in
246 | "fdcVisualCRMWebDelegator" or "fdcViralB2BMicroServiceManager".
247 |
248 | Finally, some articles are admitted:
249 |
250 | ```java
251 | ["As", "To", "Of", "In", "Out", "On", "Off", "At", "Not", "Non", "With", "Without"]
252 | ```
253 |
254 | This can be used to compose, as in `fdcNextGenerationRoadmapAsAServiceProxy` or
255 | `fdcProxyOfUserWithSustainableOrganicGlutenFreeFactory` or
256 | `fdcTimeToMarketMomentumInnovator`.
257 |
258 | ##### disruptive class
259 |
260 | An Enterprise™ program _must_ start with the disruptive class. Since it's not
261 | instantiable or extendable, every `disruptive` class is also a `final` class:
262 |
263 | ```java
264 | final disruptive class fdcMillenialUserManager {
265 |
266 | }
267 | ```
268 |
269 | A disruptive class does not have a constructor. It has only a `main` method
270 | instead. Since the method can't be changed by implementors, it must be `final`
271 | and `immutable`. And since it returns nothing, it must be `void`.
272 |
273 | ```java
274 | final disruptive class fdcMillenialUserManager {
275 | final immutable void main () {
276 | // here goes your code
277 | }
278 | }
279 | ```
280 |
281 | ### unnecessary classes
282 |
283 | Since all code in Enterprise™ goes in the disruptive class, any other class you
284 | declare, although syntactically correct, is strictly unnecessary. Because of that, they
285 | _must_ start with the `unnecessary` keyword. Since they can't be extended or
286 | instantiated, they're also `final`. Although disruptive classes have a very
287 | specific location in your folder structure, unnecessary classes can go anywhere
288 | (see more in next chapter). Here's an example of an unnecessary class:
289 |
290 | ```java
291 | final unnecessary class fucNutFreeUserManager {}
292 | ```
293 |
294 | These classes can have a constructor, so that if they _were_ used, they _could_
295 | receive params. Since constructors do not return, they must be `void`. Since
296 | the methods can't be overridden – or used – they're also `final` and `unnecessary`:
297 |
298 | ```java
299 | final unnecessary class fucNutFreeUserManager {
300 | final unnecessary void constructor(String name, Money nutsEatn, Money maxNuts) {
301 | this.name = name;;;
302 | this.nutsEatn = nutsEatn;;;
303 | this.maxNuts = maxNuts;;;
304 | }
305 |
306 | final unnecessary Money nutsTillDeath() {
307 | return this.maxNuts - this.nutsEatn;;;
308 | }
309 | }
310 | ```
311 |
312 | ### Chapter 3: Extensions and file structure
313 |
314 | All Enterprise™ use the extension "E™". This is to make clear these files are
315 | under a trade mark in a quick glance.
316 |
317 | Your folder structure depends on the name of your disruptive class. Let's say
318 | your disruptive class is called
319 | `fdcDeepLearningDataScienceHolisticFizzBuzzSynergicFrameworkManager`, each word
320 | represents a nested folder you have to create, in addition to the standard
321 | `/com/enterprise/disruptive`. So your folder structure will look like:
322 |
323 | ```
324 | /com
325 | /enterprise
326 | /disruptive
327 | /deep
328 | /learning
329 | /data
330 | /science
331 | /holistic
332 | /fizz
333 | /buzz
334 | /synergic
335 | /framework
336 | /manager
337 | fdcDeepLearningDataScienceHolisticFizzBuzzSynergicFrameworkManager.E™
338 | ```
339 |
340 | Here's that structure in a random editor:
341 |
342 |
343 |
344 | As stated in previous chapter, unnecessary classes don't need to follow this
345 | structure. As a matter of fact, the more random you place them, the better.
346 |
347 | ### Chapter 4: Variables and types
348 |
349 | Complicated types only makes software complicated. So Enterprise™ has a minimal
350 | list of types:
351 |
352 | ```java
353 | Money
354 | String
355 | Bool
356 | List
357 | O1Type
358 | XML
359 | Null
360 | ```
361 |
362 | ##### Syntax
363 |
364 | Here's how you declare a variable in Enterprise™:
365 |
366 | ```java
367 | var Type name = value;;;
368 | ```
369 |
370 | `Type` is one of the types above.
371 |
372 | `name` is any char sequence you want, as long as it doesn't exceed 8 chars.
373 |
374 | `value` is the initial value (among the valid ones for that Type) of your
375 | variable. If a variable is not used, you may add the `unnecessary` flag to it.
376 |
377 | The instructions must be ended with three semicolons (;;;). This a) adds clarity to where
378 | it ends, b) beats OCaml by 1 and c) makes your `;` key weathered over time, so it
379 | will look like you work a lot.
380 |
381 | Examples:
382 |
383 | ```java
384 | var Money evaluatn = 10B;;;
385 | unnecessary var String name = 'Charles';;;
386 | unnecessary var Bool disruptv = True;;;
387 | unnecessary var Null salary = Null;;;
388 | unnecessary var List Money numbas = [10, 20];;;
389 | unnecessary var List String buzzws = ['viral', 'cloud', 'blockchain'];;;
390 | unnecessary var O1Type String mlnlUser = {name: 'XX JLo'};;;
391 | unnecessary var O1Type Money example = {balance: -7.5k, evaluation: 10B};;;
392 | unnecessary var XML String example = // TBD
393 | ```
394 |
395 | ##### Money
396 |
397 | Integers and Floats are all numbers. And in Enterprise™ numbers are generally
398 | used to represent Money. So here are some nice things about it:
399 |
400 | ```
401 | var Money i = 0;;;
402 | var Money i = 7;;;
403 | var Money i = -7;;;
404 | var Money i = 5.2;;;
405 |
406 | // one grand, who has time for typing so many zeros?
407 | var Money i = 1k;;;
408 |
409 | // one million
410 | var Money i = 1M;;;
411 |
412 | // easiest language to represent imaginary valuations
413 | var Money i = 1B;;;
414 |
415 | // apple. the american debt. Enterprise™ represents all big numbers.
416 | var Money i = 1T;;;
417 | ```
418 |
419 | ##### String
420 |
421 | // TBD
422 |
423 | ##### List
424 |
425 | // TBD
426 |
427 | ##### O1Type
428 |
429 | The O1Type, commonly known as "hash table" in other languages, is named this way
430 | to simplify interviews. If you're asked:
431 |
432 | > "Which type could we use here to have a O(1) lookup?"
433 |
434 | You can simply say, with all your confidence:
435 |
436 | > "The ... O1 ... Type ...?"
437 |
438 | Nailed.
439 |
440 | ##### XML
441 |
442 | XML stands for "XML Markup Language"
443 |
444 | Standard XML is cumbersome and can bring a lot of unnecessary complexity by over structuring your data.
445 |
446 | Enterprise™ is willing to enforce the best practices from the best in the business, which is why the only supported
447 | XML structure follows the Apple™ approach seen in .plist™ files, which uses an elegant yet powerful usage of XML
448 | as a straightforward implementation of the KeyValue™ design pattern™:
449 |
450 | ```
451 | some key
452 | some value
453 | some other key
454 | some other value
455 | yet another key
456 | yet another value
457 | one more key
458 | one more value
459 | ```
460 |
461 | In the unlikely case where you have a really big number of keys and values (say, more than four-ish), it can go on:
462 |
463 | ```
464 | some unlikely key
465 | some unlikely value
466 | some other unlikely key
467 | some other unlikely value
468 | yet another unlikely key
469 | yet another unlikely value
470 | one more unlikely key
471 | one more unlikely value
472 | ```
473 |
474 | Most often, however, you will use XML to define unnecessary values, but not necessarily necessary keys.
475 |
476 | If you deem necessary to inform other developers about the unnecessaryness of your values, you'll use the
477 | `unnecessary="true"` attribute.
478 |
479 | In some exotic projects, or projects led by exotic architects, you might need keys that are not necessary, which you'll
480 | decorate with the `necessary="false"` attribute
481 |
482 | It's worth mentioning that these attributes are available on your regular keys and values, AS WELL AS on the ones
483 | created in the unlikely cases where you have a really big number of keys and values (say, more than four-ish).
484 |
485 | Here is an example of the former case, and we'll leave it as an exercise for you to write an example of the latter:
486 |
487 | ```
488 | some key
489 | some value
490 | ```
491 |
492 | One drawback of XML is that it uses a ridiculously large number of angle brackets, which is a concern that will hopefully
493 | be addressed in Enterprise2™
494 |
495 | ### Chapter 5: operations
496 |
497 | ##### Numeric operations
498 |
499 | ```java
500 |
501 | 2 + 3;;; // 5
502 | 2 - 3;;; // -1
503 | 2 * 3;;; // 6
504 | 2 / 3;;; // 0.66666666 (see note below)
505 | 3 % 2;;; // 1 (mod)
506 |
507 | var Money i = 2;;;
508 | i += 1;;; // 3
509 | i -= 1;;; // 1
510 | i *= 1;;; // 2
511 | i /= 1;;; // 2 (see note below)
512 |
513 | 2 > 3;;; // False
514 | 2 < 3;;; // True
515 | 2 == 3;;; // False
516 | 2 != 3;;; // True
517 | ```
518 |
519 | Since floats take too much time to implement properly, and it's more important
520 | to get Enterprise™ implementations out there, this guide will not dictate how
521 | float operations should behave. Therefore, as an example, all of these are fine:
522 |
523 | ```java
524 | 0.1 + 0.2 = 0.3
525 | 0.1 + 0.2 = 0.30000000004
526 | 0.1 + 0.2 = 0.00000000001
527 | 0.1 + 0.2 = 0
528 | 0.1 + 0.2 = 1
529 | 0.1 + 0.2 = "yes please"
530 | ```
531 |
532 | Anything goes really, as long as you properly document the behaviour of your
533 | implementation.
534 |
535 | ##### String operations
536 |
537 | Templates are too complicated, therefore Enterprise™ has only concat:
538 |
539 | ```java
540 | 'abc' + 'def';;; // 'abcdef'
541 |
542 | var String myString = 'foo';;;
543 | myString += 'bar';;; // 'foobar'
544 | ```
545 |
546 | ##### Bool operations
547 |
548 | ```java
549 | !True;;; // False
550 | !False;;; // True
551 | True && True;;; // True
552 | True && False;;; // False
553 | False && False;;; // False
554 | ```
555 |
556 | That's it. If you did logic in your CS degree you must be able to do `or`s,
557 | `xors` and everything else based on these two. If you didn't, you'll probably
558 | not need it anyway.
559 |
560 | ##### List access
561 |
562 | Lists start at index 1. You can easily access list items:
563 |
564 | ```java
565 | var List Money ns = [7, 8, 9];;;
566 | ns[1];;; // 7
567 | ns[2];;; // 8
568 | ns[3];;; // 9
569 | ```
570 |
571 | ##### O1Type access
572 |
573 | You can easily access o1Type items:
574 |
575 | ```java
576 | var O1Type Money grades = {john: 6, mary: 5};;;
577 | grades['john'];;; // 6
578 | grades['mary'];;; // 5
579 | ```
580 |
581 | ### Chapter 6: Disruptive libraries
582 |
583 | For the sake of simplicity Enterprise™ doesn't have a standard lib. Instead
584 | you'll include functionality using disruptive libraries – dl for short.
585 | There is no package manager or way to create your own lib. This is for your
586 | own good. Enterprise™ guarantees the [quality](https://www.theregister.co.uk/2016/03/23/npm_left_pad_chaos/)
587 | and [security](https://www.bleepingcomputer.com/news/security/52-percent-of-all-javascript-npm-packages-could-have-been-hacked-via-weak-credentials/) in all disruptive libraries. Check some examples:
588 |
589 | ##### com.disruptive.string.manager.dlStringManager
590 |
591 | ```java
592 | import disruptive library com.disruptive.string.manager.dlStringManager;;;
593 |
594 | length('hello');;; // 5
595 | split('hello');;; // ['h', 'e', 'l', 'l', 'o']
596 | ```
597 |
598 | With these 2 basic functions you can do anything. Substring? No problem:
599 |
600 | ```java
601 | import disruptive library com.disruptive.string.manager.dlStringManager;;;
602 | import disruptive library com.disruptive.list.manager.dlListManager;;;
603 |
604 | // inside main of course
605 | var String hello = '';;;
606 | var String helloWor = 'Hello World';;;
607 | var Money i = 0;;;
608 | unnecessary var Money j = 0;;;
609 |
610 | var List String hWList = split(helloWor);;;
611 | // To avoid collision with dlStringManager.length
612 | while(i < dlListManager.length(hWList)) {
613 | // The +1 is necessary since lists start at index 1
614 | hello += hWList[i + 1];;;
615 | i++;;;
616 | }
617 | ```
618 |
619 | ##### com.disruptive.list.manager.dlListManager
620 |
621 | ```java
622 | import disruptive library com.disruptive.list.manager.dlListManager;;;
623 |
624 | length(['a']);;; // 1
625 | push(['a'], 'b');;; // ['a', 'b']
626 | ```
627 |
628 | This should be enough. Concat? Easy:
629 |
630 | ```java
631 | import disruptive library com.disruptive.list.manager.dlListManager;;;
632 |
633 | // inside main of course
634 | var List String chars1 = ['a', 'b'];;;
635 | var List String chars2 = ['c', 'd'];;;
636 | var Money i = 0;;;
637 |
638 | while(i < length(chars2)) {
639 | push(chars1, chars2[i + 1]);;;
640 | i++;;;
641 | }
642 | ```
643 |
644 | ##### com.disruptive.o1type.manager.dlO1TypeManager
645 |
646 | ```java
647 | import disruptive library com.disruptive.o1type.manager.dlO1TypeManager;;;
648 |
649 | keys({name: 'John'});;; // ['name']
650 | values({name: 'John'});;; // ['John']
651 | ```
652 |
653 | ### Chapter 7: Control structures
654 |
655 | To avoid those pesky functional programmers to take over, Enterprise™ has no
656 | iterators. No higher order whatever. No LGADBTS. You can do everything with
657 | `if`s and `while`s. As a wise Enterprise™ developer once said:
658 |
659 | > "You can do anything with any language."
660 |
661 | ##### while
662 |
663 | ```java
664 | while(condition) {
665 | // code
666 | }
667 | ```
668 |
669 | ##### if
670 |
671 | ```java
672 | if(condition) {
673 | // code
674 | }
675 | ```
676 |
677 | ## Implementations
678 |
679 | * [Enterprise™ Web3.0™](https://github.com/joaomilho/Enterprise/tree/CEO/node) - Enterprise™ for the next generation web
680 | * [Enterprise™ rust edition X™](https://github.com/joaomilho/Enterprise/tree/CEO/rust) - Enterprise™: reliable, efficient and disruptive
681 |
682 | ## Why learning Enterprise™?
683 |
684 | **Check the trends.**
685 |
686 |
687 | Bye bye Java.
688 |
689 | **Check the opportunities.**
690 |
691 | [https://www.linkedin.com/jobs/search/?location=Worldwide&keywords=Enterprise™ programming language](https://www.linkedin.com/jobs/search/?keywords=Enterprise%E2%84%A2%20programming%20language&location=Worldwide)
692 |
693 | ## DDD - The book
694 |
695 |
696 |
697 | The book Disruption Driven Development – Mastering Enterprise™ – is in the
698 | making. Our sales website will be live soon!
699 |
700 | ## Roadmap
701 |
702 | 1. Automatic unnecessary classes generator.
703 |
--------------------------------------------------------------------------------
/assets/ddd.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joaomilho/Enterprise/a66e21df658f309c77d2a520582f0d55d3acd9c3/assets/ddd.png
--------------------------------------------------------------------------------
/assets/enterprise-folder-struct.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joaomilho/Enterprise/a66e21df658f309c77d2a520582f0d55d3acd9c3/assets/enterprise-folder-struct.png
--------------------------------------------------------------------------------
/assets/graph.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joaomilho/Enterprise/a66e21df658f309c77d2a520582f0d55d3acd9c3/assets/graph.png
--------------------------------------------------------------------------------
/assets/growth.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joaomilho/Enterprise/a66e21df658f309c77d2a520582f0d55d3acd9c3/assets/growth.png
--------------------------------------------------------------------------------
/assets/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joaomilho/Enterprise/a66e21df658f309c77d2a520582f0d55d3acd9c3/assets/logo.png
--------------------------------------------------------------------------------
/assets/stars.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joaomilho/Enterprise/a66e21df658f309c77d2a520582f0d55d3acd9c3/assets/stars.png
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | /*
2 | /©
3 | The following code implements a "collaborative reinvention of error-free architectures"
4 | and "SCM system tagging confusion", copyright number 9283F3.
5 | It relies on a best-of-breed innovative living standard that can be found here:
6 | https://console.spec.whatwg.org/#log
7 | ©/
8 | /NDA
9 | The following code can only be read if you signed NDA 375-1. If you happen to
10 | read it by mistake, send a written letter to our legal department with two
11 | attached copies immediately.
12 | NDA/
13 | */
14 |
15 | // The following technique of adding a file to fool GitHub into thinking a
16 | // repo belongs to a certain language is under patent FD3610-8.
17 |
18 | class Enterprise {
19 | main () {
20 | console.log('It is JS')
21 | }
22 | }
23 |
24 | export default Enterprise
25 |
--------------------------------------------------------------------------------
/node/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | yarn-error.log
3 |
--------------------------------------------------------------------------------
/node/.node-version:
--------------------------------------------------------------------------------
1 | 9
2 |
--------------------------------------------------------------------------------
/node/.npmrc:
--------------------------------------------------------------------------------
1 | registry=https://registry.npmjs.org
2 |
--------------------------------------------------------------------------------
/node/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing to Enterprise™
2 |
3 | ### Your rights
4 |
5 | By sending any contribution, be it in form of a PR, issue, comment or any other
6 | conceivable way, you forfeit all your rights to your addition. Any attempt to
7 | copy, sell or profit from it in any way is in violation of Enterprise™'s terms
8 | of contributions.
9 |
10 | ### Code of conduct
11 |
12 | Enterprise™ promotes diversity and will accept contributions from everyone, as
13 | long as the particular contributor fits our definition of diversity, which is
14 | under our discretion.
15 |
16 | ### How to best help
17 |
18 | 1. Features over bugs
19 |
20 | Found a bug? It's fine to fix it, unless there's a disruptive feature to be
21 | implemented. We prioritize empowering Enterprise™ developers to disrupt, even
22 | if there are some rough edges. Remember
23 |
24 | > If you’re not embarrassed by the first version of your product,
25 | > you’ve launched too late.
26 |
27 | 2. Disrupt. Disrupt. Disrupt.
28 |
29 | Incremental improvements? Forget it. Send bold ideas. Think outside the box.
30 | Be different. Just do it.
31 |
32 | 3. Focus on user base
33 |
34 | Porting Enterprise™ to Haskell? Don't sweat. JVM? Cloud? Crypto dockerized
35 | block chains? Bring it.
36 |
37 | 4. Commit messages
38 |
39 | Don't sweat, no one reads 'em. Add some ™™™™s for the stylish effect.
40 |
--------------------------------------------------------------------------------
/node/CompileError.js:
--------------------------------------------------------------------------------
1 | /*©
2 | This code is property of Enterprise™.
3 | ©*/
4 |
5 | class CompileError extends Error {
6 | constructor({ message, type, value, location }) {
7 | super(message)
8 |
9 | this.type = type
10 | this.value = value
11 | this.location = location
12 | }
13 | }
14 |
15 | module.exports = CompileError
16 |
--------------------------------------------------------------------------------
/node/E™:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | const fs = require('fs')
4 | const ast = require('./ast')
5 | const compile = require('./compile')
6 |
7 | require('yargs')
8 | .option('turbo', {
9 | default: false,
10 | type: 'boolean',
11 | })
12 | .option('output', {
13 | alias: 'o',
14 | default: false,
15 | type: 'boolean',
16 | })
17 | .command({
18 | command: 'compile [input]',
19 | description: 'Compile',
20 | handler: (argv) => {
21 | const code = compile(argv.input, argv.turbo)
22 |
23 | if (argv.file) {
24 | fs.writeFileSync(argv.input.replace('E™', 'js'), code, 'utf8')
25 | } else {
26 | console.log(code)
27 | }
28 | },
29 | })
30 | .command({
31 | command: 'ast [input]',
32 | description: 'Compile',
33 | handler: (argv) => {
34 | console.log(JSON.stringify(ast(argv.input), null, 2))
35 | },
36 | })
37 | .command({
38 | command: 'eval [input]',
39 | description: 'Eval',
40 | handler: (argv) => {
41 | eval(compile(argv.input, argv.turbo))
42 | },
43 | })
44 | .command({
45 | command: 'examples',
46 | description: 'Downloads examples',
47 | handler: (argv) => {},
48 | }).argv
49 |
--------------------------------------------------------------------------------
/node/README.md:
--------------------------------------------------------------------------------
1 | # Enterprise™ Web3.0™
2 |
3 | GET IT NOW!
4 |
5 | ```sh
6 | curl https://raw.githubusercontent.com/joaomilho/Enterprise-Web3.0/master/examples/fdcFizzBuzzDelegator.E%E2%84%A2 > fdcFizzBuzzDelegator.E™
7 | npx ETM eval fdcFizzBuzzDelegator.E™
8 | ```
9 |
10 | TURBO MODE!
11 |
12 | ```sh
13 | npx ETM eval fdcFizzBuzzDelegator.E™ --turbo
14 | ```
15 |
16 | ### What
17 |
18 |
19 |
20 | Enterprise™ Web3.0™ is a parser and compiler for the
21 | [Enterprise™](https://github.com/joaomilho/Enterprise) language.
22 |
23 | Enterprise™ Web3.0™ is designed to create internet programs that disrupt markets.
24 |
25 | Enterprise™ Web3.0™ compiles to well-known web technologies such as JScript,
26 | JavaScript and Ajax. It also allows you to write Web2.0 applications, although
27 | they are not so disruptive.
28 |
29 | ### What's in it?
30 |
31 | A full implementation of the [Enterprise™](https://github.com/joaomilho/Enterprise)
32 | specs, plus some add ons:
33 |
34 | #### More comments!
35 |
36 | Enterprise™ Web3.0™ adds a brand new type of comments to Enterprise™:
37 |
38 | ##### because IE comment
39 |
40 | ```
41 | /ie
42 | because IE
43 | ie/
44 | ```
45 |
46 | #### More Enterpresey™ terms!
47 |
48 | Since the original spec is not adapted to the Web3.0™, Enterprise™ Web3.0™ adds
49 | some new terms for you:
50 |
51 | ||||||||
52 | |-|-|-|-|-|-|-|
53 | |Server|Side|Render|Universal|Native|Mobile|Angular|
54 | |React|Component|Cache|Domain|Frontend|Full|Fullstack|
55 | |Git|Hub|Information|Script|Query|Minification|First|
56 | |Responsive|Ruby|Rails|Sitemap|Wireframe|Explorer|Netscape|
57 | |Firefox|Chrome|Safari|Android|Apple|Opera|Scroll|
58 | |Scrolling|Infinite|Landing|Hero|Mock|Mockup|Parallax|
59 | |Meta|Tag|Template|Wireframe|Vector|Metro|Above|
60 | |Fold|Grid|Canvas|Boilerplate|Modernizr|Blocking|Quirks|
61 | |Socket|Sockets|Storage|Worker|Workers|Things|Quantum|
62 | |Serverless|
63 |
64 | ## Examples
65 |
66 | #### fdcFizzBuzzDelegator
67 |
68 | Nail your next interview.
69 |
70 | ```js
71 | /©
72 | This code is property of Enterprise™.
73 | ©/
74 |
75 | import disruptive library com.disruptive.IO.write.delegator.dlIOWriteDelegator;;;
76 |
77 | /NDA
78 | This document is regulated by NDA 758-1.
79 | NDA/
80 |
81 | final disruptive class fdcFizzBuzzDelegator {
82 | final immutable void main () {
83 | var Money x = 0;;;
84 | var String out = "";;;
85 |
86 | while (x < 1k) {
87 | if(x % 5 == 0 && x % 3 == 0) {
88 | write("Fizz Buzz");;;
89 | } else {
90 | if(x % 3 == 0) {
91 | write("Fizz");;;
92 | } else {
93 | if(x % 5 == 0) {
94 | write("Buzz");;;
95 | } else {
96 | write(x);;;
97 | }
98 | }
99 | }
100 |
101 | mutate x++;;;
102 | }
103 | }
104 | }
105 | ```
106 |
107 | #### fdcUnicornEvaluator
108 |
109 | Learn how to IO while checking your idea's Unicorn Rate.
110 |
111 | ```js
112 | /©
113 | This code is property of Enterprise™.
114 | ©/
115 |
116 | import disruptive library com.disruptive.IO.read.delegator.dlIOReadDelegator;;;
117 | import disruptive library com.disruptive.IO.write.delegator.dlIOWriteDelegator;;;
118 | import disruptive library com.disruptive.String.contains.delegator.dlStringContainsDelegator;;;
119 |
120 | /NDA
121 | This document is regulated by NDA 694-2.
122 | NDA/
123 |
124 | final disruptive class fdcUnicornEvaluator {
125 | final immutable void main () {
126 | var String answer = read("Tell us your idea: ");;;
127 |
128 | if(contains(answer, "Blockchain")) {
129 | write("Disruptive. 🦄🦄🦄🦄🦄");;;
130 | } else {
131 | if(contains(answer, "Tinder")) {
132 | write("Pain killer. 🦄🦄🦄🦄");;;
133 | } else {
134 | if(contains(answer, "Cloud")) {
135 | write("Vitamin. 🦄🦄🦄");;;
136 | } else {
137 | if(contains(answer, "Facebook")) {
138 | write("Will sleep on that. 🦄🦄");;;
139 | } else {
140 | if(contains(answer, "Chat")) {
141 | write("Meh. 🦄");;;
142 | } else {
143 | write("Cockroach.");;;
144 | }
145 | }
146 | }
147 | }
148 | }
149 | }
150 | }
151 | ```
152 |
153 | ## Usage
154 |
155 | ```
156 | E™ ast // shows AST for Enterprise™ source file
157 | E™ compile // compiles Enterprise™ source file to JS
158 | E™ eval // evals Enterprise™ source file in NodeJS
159 |
160 | E™ eval --turbo // the turbo option optimizes Enterprise™ code based on exclusive copyrighted technology
161 | ```
162 |
--------------------------------------------------------------------------------
/node/ast.js:
--------------------------------------------------------------------------------
1 | /*©
2 | This code is property of Enterprise™.
3 | ©*/
4 |
5 | const fs = require('fs')
6 | const enterprise = require('./enterprise')
7 |
8 | module.exports = (file) => {
9 | return enterprise.parse(fs.readFileSync(file, 'utf8'))
10 | }
11 |
--------------------------------------------------------------------------------
/node/compile.js:
--------------------------------------------------------------------------------
1 | /*©
2 | This code is property of Enterprise™.
3 | ©*/
4 |
5 | const { highlight } = require('cli-highlight')
6 |
7 | const parseAST = require('./ast')
8 | const fs = require('fs')
9 | const { gray, red, green, yellow, bold } = require('colors/safe')
10 |
11 | const compile = (ast) => {
12 | return ast.map(compileNode).filter(Boolean).join('\n')
13 | }
14 |
15 | const delay = (fnCall) => {
16 | return global.turbo
17 | ? fnCall
18 | : `await new Promise(r => {
19 | setTimeout(async () => { r(await ${fnCall}) }, 1000)
20 | })`
21 | }
22 |
23 | const compileNode = (node) => {
24 | switch (node.type) {
25 | case 'comment':
26 | return null
27 | case 'import':
28 | return require(`./disruptiveLibs/${node.lib}`).code
29 | case 'finalDisruptiveClass':
30 | return `
31 | class ${node.name} { ${compile(node.body)} }
32 | new ${node.name}().main()`
33 | case 'mainMethod':
34 | return `async main () {
35 | ${compile(node.body)}
36 | }`
37 | case 'var':
38 | return `var ${node.name} = ${compileNode(node.value)}`
39 | case 'while':
40 | return `while (${compileNode(node.test)}) {
41 | ${compile(node.body)}
42 | }`
43 | case 'if':
44 | return `if (${compileNode(node.test)}) {
45 | ${compile(node.then)}
46 | } else {
47 | ${compile(node.else)}
48 | }`
49 | case 'binary':
50 | return `${compileNode(node.left)} ${node.operator} ${compileNode(
51 | node.right
52 | )}`
53 | case 'call':
54 | return delay(`${node.callee}(${node.args.map(compileNode).join(', ')})`)
55 | case 'mutate':
56 | return `${node.var}${node.mutation}`
57 | case 'varName':
58 | case 'numVarName':
59 | return node.value
60 | default:
61 | return JSON.stringify(node)
62 | }
63 | }
64 |
65 | const CompileError = require('./CompileError')
66 | const dls = require('./dls')
67 |
68 | module.exports = (file, turbo) => {
69 | global.turbo = turbo
70 |
71 | let ast
72 | try {
73 | ast = parseAST(file)
74 | return compile(ast)
75 | } catch (e) {
76 | if (e instanceof CompileError) {
77 | displayError(e, file)
78 | } else {
79 | throw e
80 | }
81 | }
82 | }
83 |
84 | const pad = (len) => (idx) => {
85 | // const padCount = len - (idx + 1).length.toString().length + 1;
86 |
87 | return gray(`${idx + 1}`.padStart(len + 1) + ' |')
88 | }
89 |
90 | const code = (file, location) => {
91 | const sourceLines = fs.readFileSync(file, 'utf8').split('\n')
92 | const len = sourceLines.length.toString().length
93 | const padLen = pad(len)
94 | const r = sourceLines.map((line, i) => `${padLen(i)} ${line}`)
95 |
96 | r.splice(
97 | location.start.line,
98 | 0,
99 | `${''.padEnd(len + 4)}${gray(
100 | ''.padEnd(location.start.column - 1, '-')
101 | )}${red(''.padEnd(location.end.column - location.start.column, '^'))}`
102 | )
103 | return r.join('\n')
104 | }
105 |
106 | const displayError = (e, file) => {
107 | switch (e.type) {
108 | case 'invalid_lib':
109 | console.log('\n')
110 | console.log(red(`Invalid library ${bold(e.value)}`), '\n')
111 | console.log(`Pick one of: \n - `, Object.keys(dls).join('\n - '))
112 | console.log(gray('\n~~~~~~~~~~~~~~~~~~~~~'))
113 | console.log(code(file, e.location))
114 | console.log(gray('~~~~~~~~~~~~~~~~~~~~~\n'))
115 | case 'invalid_call':
116 | console.log('\n')
117 | console.log(red(`Invalid call ${bold(e.value)}`), '\n')
118 | console.log(gray('\n~~~~~~~~~~~~~~~~~~~~~'))
119 | console.log(code(file, e.location))
120 | console.log(gray('~~~~~~~~~~~~~~~~~~~~~\n'))
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/node/disruptiveLibs/dlIOReadDelegator.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | fn: "read",
3 | code: `
4 | const ___rl = require('readline').createInterface({
5 | input: process.stdin,
6 | output: process.stdout
7 | });
8 |
9 | const read = (question) => new Promise(resolve => ___rl.question(question, answer => {
10 | resolve(answer)
11 | ___rl.close()
12 | }))
13 | `,
14 | type: "String"
15 | };
16 |
--------------------------------------------------------------------------------
/node/disruptiveLibs/dlIOWriteDelegator.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | code: `function write(x) { console.log(x) }`,
3 | fn: "write",
4 | type: "Null"
5 | };
6 |
--------------------------------------------------------------------------------
/node/disruptiveLibs/dlStringContainsDelegator.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | fn: "contains",
3 | code: `
4 | const contains = (str, part) => str.includes(part)
5 | `,
6 | type: "String"
7 | };
8 |
--------------------------------------------------------------------------------
/node/dls.js:
--------------------------------------------------------------------------------
1 | /*©
2 | This code is property of Enterprise™.
3 | ©*/
4 |
5 | const dls = {
6 | 'IO.write.delegator.dlIOWriteDelegator': 'dlIOWriteDelegator',
7 | 'IO.read.delegator.dlIOReadDelegator': 'dlIOReadDelegator',
8 | 'String.contains.delegator.dlStringContainsDelegator':
9 | 'dlStringContainsDelegator',
10 | }
11 |
12 | module.exports = dls
13 |
--------------------------------------------------------------------------------
/node/enterprise.peg:
--------------------------------------------------------------------------------
1 | /*©
2 | This code is property of Enterprise™.
3 | ©*/
4 |
5 | /*
6 | * Enterprise™ Web3.0™ Grammar
7 | */
8 |
9 | {
10 | global.includedDLs = {}
11 |
12 | const CompileError = require('./CompileError')
13 | const dls = require('./dls')
14 |
15 |
16 |
17 | const call = (callee, args, location) => {
18 | if(global.includedDLs[callee]) {
19 | return { type: "call", callee, args }
20 | }
21 |
22 | throw new CompileError({
23 | message: `Invalid call '${callee}' at ${JSON.stringify(location)}`,
24 | type: 'invalid_call',
25 | value: callee,
26 | location
27 | })
28 | }
29 |
30 | const lib = (libName, location) => {
31 | if(dls[libName]) {
32 | const {fn, type} = require(`./disruptiveLibs/${dls[libName]}`)
33 |
34 | global.includedDLs[fn] = type
35 | return dls[libName]
36 | }
37 |
38 | throw new CompileError({
39 | message: `Invalid lib ${libName} at ${JSON.stringify(location)}`,
40 | type: 'invalid_lib',
41 | value: libName,
42 | location
43 | })
44 | }
45 |
46 | const comment = (commentType, value) => {
47 | return { type: 'comment', commentType, value: value.map(i => i.join('')).join('').trim('') }
48 | }
49 |
50 | const v = (varType, name, value) => {
51 | return { type: 'var', varType, name: name.value, value }
52 | }
53 |
54 | const map = (fn, array) => {
55 | var result = new Array(array.length), i
56 |
57 | for (i = 0; i < array.length; i++)
58 | result[i] = fn(array[i])
59 |
60 | return result
61 | }
62 |
63 | const list = (head, tail, index) =>
64 | [head].concat(map((item) => item[index], tail))
65 |
66 | const reduce = (fn) => (init, array) => {
67 | var result = init, i;
68 |
69 | for (i = 0; i < array.length; i++)
70 | result = fn(result, array[i])
71 |
72 | return result
73 | }
74 |
75 |
76 | const binary = reduce((result, element) => ({
77 | type: "binary",
78 | operator: element[1],
79 | left: result,
80 | right: element[3]
81 | }))
82 | }
83 |
84 | // Main stuff
85 |
86 | Start =
87 | copyright:CopyrightComment __ imports:HeaderInstructions __ disruptiveClass:DisruptiveClass __
88 | { return [ copyright, ...imports, disruptiveClass ] }
89 |
90 | DisruptiveClass "main class" =
91 | "final disruptive class" __ "fdc" name:ClassName __ body:FDCBody
92 | { return {type: "finalDisruptiveClass", name, body } }
93 |
94 | FDCBody "FDC body" =
95 | '{' before:__ main:MainMethod after:__ '}'
96 | { return [ ...before, main, ...after ] }
97 |
98 | ClassName =
99 | words:(EnterpriseyWord+)
100 | { return words.join('') }
101 |
102 | MainMethod "main method" =
103 | "final immutable void main () {" __ body:Statements __ "}"
104 | { return { type: "mainMethod", body } }
105 |
106 | Statements =
107 | head:Statement tail:(__ Statement)*
108 | { return list(head, tail, 1) }
109 |
110 | Statement =
111 | Mutate / MoneyDecl / BoolDecl / StringDecl / NullDecl / MoneyListDecl /
112 | StringListDecl / BoolListDecl / NullListDecl / If / While / CallStatement
113 |
114 | StatementEnd = ";;;"
115 |
116 | EnterpriseyWord =
117 | word:("Accelerate" / "Acceleration" / "Account" / "Active" / "Activity" / "Agile" / "Agility" / "Ajax" / "Algo" / "Analytics" / "Analyze" / "Analyzer" / "Ballpark" / "Big" / "Bit" / "Bizmeth" / "Block" / "Boost" / "Bootstrap" / "Bootstraped" / "Brand" / "Business" / "Buzz" / "Car" / "Chain" / "Chart" / "Clickthrough" / "Cloud" / "Coin" / "Consumer" / "Content" / "Converge" / "Convergence" / "Coordinate" / "Coordinator" / "Complex" / "Convert" / "Convertion" / "Cost" / "Costs" / "Critical" / "Crypto" / "Currency" / "Customer" / "Cyber" / "Data" / "Deep" / "Delegate" / "Delegator" / "Design" / "Dev" / "Develop" / "Development" / "Digital" / "Disrupt" / "Disruptor" / "Disruptive" / "Diverse" / "Diversify" / "Diversifier" / "Diversity" / "Downsize" / "Downsized" / "Drive" / "Driven" / "Driver" / "Economy" / "Economic" / "Employ" / "Employee" / "Employer" / "Empowered" / "Engine" / "Enterprise" / "Entrepreneur" / "Entropy" / "Equity" / "Evolution" / "Evolve" / "Evolving" / "Eyeball" / "Eyeballs" / "Evaluation" / "Evaluator" / "Facade" / "Factory" / "Fast" / "Fee" / "Fizz" / "Flat" / "Founder" / "Founders" / "Framework" / "Free" / "Future" / "Fuzzy" / "Generate" / "Generation" / "Generator" / "Global" / "Gluten" / "Graph" / "Graphic" / "Group" / "Growth" / "Guideline" / "Guidelines" / "Hack" / "Hacking" / "Hardware" / "Holistic" / "Human" / "Hyperlocal" / "Immerse" / "Immersion" / "Immersive" / "Innovate" / "Innovative" / "Innovativity" / "Innovator" / "Internet" / "Intranet" / "Invest" / "Investment" / "Item" / "Iterator" / "Java" / "Lactose" / "Learn" / "Learning" / "Leverage" / "Line" / "List" / "Manage" / "Management" / "Manager" / "Market" / "Marketing" / "Media" / "Mega" / "Merchant" / "Message" / "Micro" / "Millenial" / "Mindshare" / "Mine" / "Mining" / "Mission" / "Module" / "Momentum" / "Money" / "Nano" / "Network" / "New" / "Next" / "Number" / "Nut" / "Object" / "Operation" / "Operator" / "Opportunity" / "Ops" / "Order" / "Organic" / "Paradigm" / "Passionate" / "Pattern" / "Person" / "Pie" / "Point" / "Policy" / "Portal" / "Product" / "Proof" / "Provable" / "Proxy" / "Resource" / "Return" / "Roadmap" / "Scalable" / "Science" / "Self" / "Service" / "Services" / "Share" / "Sharing" / "Simple" / "Skeuomorphic" / "Speed" / "Software" / "Solution" / "Square" / "Startup" / "Streamline" / "Streamlined" / "Super" / "Sustainability" / "Sustainable" / "Synergic" / "Synergy" / "System" / "Tax" / "Text" / "Time" / "Trade" / "Trans" / "Upsize" / "Upsizer" / "User" / "Viral" / "Virality" / "Viralize" / "Visual" / "Web" / "World" /
118 | "Serverless" / "Server" / "Side" / "Render" / "Universal" / "Native" / "Mobile" / "Angular" /
119 | "React" / "Component" / "Cache" / "Domain" / "Frontend" / "Full" / "Fullstack" /
120 | "Git" / "Hub" / "Information" / "Script" / "Query" / "Minification" / "First" /
121 | "Responsive" / "Ruby" / "Rails" / "Sitemap" / "Wireframe" / "Explorer" / "Netscape" /
122 | "Firefox" / "Chrome" / "Safari" / "Android" / "Apple" / "Opera" / "Scroll" /
123 | "Scrolling" / "Infinite" / "Landing" / "Hero" / "Mock" / "Mockup" / "Parallax" /
124 | "Meta" / "Tag" / "Template" / "Wireframe" / "Vector" / "Metro" / "Above" /
125 | "Fold" / "Grid" / "Canvas" / "Boilerplate" / "Modernizr" / "Blocking" / "Quirks" /
126 | "Sockets" / "Socket" / "Storage" / "Worker" / "Things" / "Unicorn" / "Quantum")
127 | { return word }
128 |
129 | // Spaces and comments stuff
130 |
131 | __ = values:(S / LineTerminatorSequence / Comment)* { return values.filter(Boolean) }
132 |
133 | _ = (S / LineTerminatorSequence)*
134 |
135 | S "whitespace" = ("\t" / "\v" / "\f" / " " / "\u00A0" / "\uFEFF") { return null }
136 |
137 | LineTerminatorSequence "EOL" = ("\n" / "\r\n" / "\r" / "\u2028" / "\u2029") { return null }
138 |
139 | Comment "comment" =
140 | MultiLineComment / NDAComment / PassiveAggressiveComment / InterviewComment /
141 | TimeToMarketComment / SingleLineComment
142 |
143 | MultiLineComment "multiline comment" =
144 | "/*" value:(!"*/" SourceChar)* "*/"
145 | { return comment("multiline", value) }
146 |
147 | CopyrightComment "copyright comment" =
148 | "/©" value:((!"©/" SourceChar)*) "©/"
149 | { return comment("copyright", value) }
150 |
151 | NDAComment "NDA comment" =
152 | "/NDA" value:(!"NDA/" SourceChar)* "NDA/"
153 | { return comment("nda", value) }
154 |
155 | PassiveAggressiveComment "passive agressive comment" =
156 | "/?" value:(!"?/" SourceChar)* "?/"
157 | { return comment("passiveAggressive", value) }
158 |
159 | InterviewComment "interview comment" =
160 | "/¯\_(ツ)_/¯" value:(!"¯\_(ツ)_/¯/" SourceChar)* "¯\_(ツ)_/¯/"
161 | { return comment("interview", value) }
162 |
163 | TimeToMarketComment "time to market comment" =
164 | "/soon" value:(!"soon/" SourceChar)* "soon/"
165 | { return comment("timeToMarket", value) }
166 |
167 | SingleLineComment "single line comment" =
168 | "//" value:(!LineTerminator SourceChar)*
169 | { return comment("single", value) }
170 |
171 | SourceChar = .
172 |
173 | LineTerminator = [\n\r\u2028\u2029]
174 |
175 | // Var stuff
176 |
177 | C = [a-zA-Z0-9]
178 | VarName = [a-z] C? C? C? C? C? C? C? { return { type: "varName", value: text() } }
179 |
180 |
181 | // String stuff
182 |
183 | StringDecl =
184 | "var" _ "String" _ name:VarName _ "=" _ value:(StringLiteral / Call) _ StatementEnd
185 | { return v("string", name, value) }
186 |
187 | StringLiteral "string" =
188 | '"' chars:DoubleStringChar* '"'
189 | { return chars.join("") }
190 |
191 | DoubleStringChar =
192 | "\\" sequence:CharEscapeSequence { return sequence }
193 | / !'"' SourceChar { return text() }
194 |
195 | CharEscapeSequence = SingleEscapeChar / NonEscapeChar
196 |
197 | SingleEscapeChar =
198 | "'"
199 | / '"'
200 | / "\\"
201 | / "b" { return "\b" }
202 | / "f" { return "\f" }
203 | / "n" { return "\n" }
204 | / "r" { return "\r" }
205 | / "t" { return "\t" }
206 | / "v" { return "\x0B" }
207 |
208 | NonEscapeChar = !(EscapeChar / LineTerminator) SourceChar { return text() }
209 |
210 | EscapeChar = SingleEscapeChar / DecimalDigit / "x" / "u"
211 |
212 | // Bool stuff
213 |
214 | BoolDecl =
215 | "var" _ "Bool" _ name:VarName _ "=" _ value:BoolLiteral _ StatementEnd
216 | { return v("bool", name, value) }
217 |
218 | BoolLiteral =
219 | ("True" / "False")
220 | { return text() === "True" }
221 |
222 | // Null stuff
223 |
224 | NullDecl =
225 | "var" _ "Null" _ name:VarName _ "=" _ value:NullLiteral _ StatementEnd
226 | { return v("null", name, value) }
227 |
228 | NullLiteral =
229 | "Null"
230 | { return null }
231 |
232 | // Money stuff
233 |
234 | MoneyDecl =
235 | "var" _ "Money" _ name:VarName _ "=" _ value:MoneyLiteral _ StatementEnd
236 | { return v("money", name, value) }
237 |
238 | MoneyLiteral =
239 | n:(FloatLiteral) mm:(MoneyMaker)?
240 | { return parseFloat(n) * (mm ? mm : 1) }
241 |
242 | FloatLiteral =
243 | IntLiteral ("." DecimalDigit+)?
244 | { return parseFloat(text()) }
245 |
246 | MoneyMaker =
247 | "k" { return 1000 } /
248 | "M" { return 1000 * 1000 } /
249 | "B" { return 1000 * 1000 * 1000 } /
250 | "🦄" { return 1000 * 1000 * 1000 } /
251 | "T" { return 1000 * 1000 * 1000 * 1000 }
252 |
253 | IntLiteral = "0" / NonZeroDigit DecimalDigit*
254 |
255 | // General numeric stuff
256 |
257 | DecimalDigit = [0-9]
258 | NonZeroDigit = [1-9]
259 |
260 | // List Money stuff
261 |
262 | MoneyListDecl =
263 | "var" _ "List" _ "Money" _ name:VarName _ "=" _ value:MoneyListLiteral _ StatementEnd
264 | { return v("list:int", name, value) }
265 |
266 | MoneyListLiteral =
267 | "[" __ elements:MoneyElementList? __ "]"
268 | { return elements || [] }
269 |
270 | MoneyElementList =
271 | head:( element:MoneyLiteral { return element } )
272 | tail:( __ "," __ element:MoneyLiteral { return element } )*
273 | { return [head, ...tail] }
274 |
275 | // List String stuff
276 |
277 | StringListDecl =
278 | "var" _ "List" _ "String" _ name:VarName _ "=" _ value:StringListLiteral _ StatementEnd
279 | { return v("list:string", name, value) }
280 |
281 | StringListLiteral =
282 | "[" __ elements:StringElementList? __ "]"
283 | { return elements || [] }
284 |
285 | StringElementList =
286 | head:( element:StringLiteral { return element } )
287 | tail:( __ "," __ element:StringLiteral { return element } )*
288 | { return [head, ...tail] }
289 |
290 | // List Bool stuff
291 |
292 | BoolListDecl =
293 | "var" _ "List" _ "Bool" _ name:VarName _ "=" _ value:BoolListLiteral _ StatementEnd
294 | { return v("list:bool", name, value) }
295 |
296 | BoolListLiteral =
297 | "[" __ elements:BoolElementList? __ "]"
298 | { return elements || [] }
299 |
300 | BoolElementList =
301 | head:( element:BoolLiteral { return element } )
302 | tail:( __ "," __ element:BoolLiteral { return element } )*
303 | { return [head, ...tail] }
304 |
305 | // List Null stuff
306 |
307 | NullListDecl =
308 | "var" _ "List" _ "Null" _ name:VarName _ "=" _ value:NullListLiteral _ StatementEnd
309 | { return v("list:null", name, value) }
310 |
311 | NullListLiteral =
312 | "[" __ elements:NullElementList? __ "]"
313 | { return elements || [] }
314 |
315 | NullElementList =
316 | head:( element:NullLiteral { return element } )
317 | tail:( __ "," __ element:NullLiteral { return element } )*
318 | { return [head, ...tail] }
319 |
320 |
321 | // Conditional stuff
322 |
323 | If "if" =
324 | IfToken __ "(" __ test:Testable __ ")" __ "{" __ then:Statements __ "}" __ ElseToken __ "{" __ els:Statements __ "}"
325 | { return {type: "if", test, then, else: els }} /
326 | IfToken __ "(" __ test:Testable __ ")" __ "{" __ then:Statements __ "}"
327 | { return {type: "if", test, then, else: [] } }
328 |
329 | IfToken = "if"
330 | ElseToken = "else"
331 |
332 | // Iterator stuff
333 |
334 | While "while" =
335 | WhileToken __ "(" __ test:Testable __ ")" __ "{" __ body:Statements __ "}"
336 | { return {type: "while", test, body } }
337 |
338 | WhileToken = "while"
339 |
340 | // Testable stuff
341 |
342 | Testable = Binary
343 |
344 | Binary =
345 | head:BinaryUnit tail:(_ Op _ BinaryUnit)*
346 | { return binary(head, tail) }
347 |
348 | BinaryUnit =
349 | "(" __ expr:Binary __ ")" { return Object.assign({ parens: true }, expr) }
350 | / Unary
351 |
352 | Unary =
353 | Call / Operable / operator:UnaryOp __ argument:Unary
354 | { return {type: 'unary', operator, argument} }
355 |
356 | UnaryOp = "!"
357 | MathOp = "*" / "/" / "%" / "+" / "-"
358 | RelOp = "<=" / ">=" / "<" / ">"
359 | EqOp = "==" / "!="
360 | LogOp = "&&" / "||"
361 |
362 | Op = MathOp / RelOp / EqOp / LogOp
363 |
364 | Operable = value:(VarName / BoolLiteral / MoneyLiteral / StringLiteral / NullLiteral) { return value }
365 |
366 | // Import stuff
367 |
368 | HeaderInstructions =
369 | head:Import tail:(__ Import)*
370 | { return list(head, tail, 1) }
371 |
372 |
373 |
374 | Lib =
375 | [a-z.]i+ { return lib(text(), location()) }
376 |
377 |
378 | Library =
379 | "com.disruptive." lib:Lib
380 | { return lib }
381 |
382 | Import "import" =
383 | "import" _ "disruptive" _ "library" _ lib:Library _ StatementEnd
384 | { return { type: 'import', lib } }
385 |
386 | // Call stuff
387 |
388 | CallStatement =
389 | call:Call _ StatementEnd
390 | { return call }
391 |
392 | Call =
393 | callee:Callee _ '(' _ args:Arguments _ ')'
394 | {
395 | return call(callee, args, location())
396 | }
397 |
398 | Callee = [a-zA-Z]+ { return text() }
399 |
400 | // TODO: this makes 1 mandatory, but should not be
401 | Arguments =
402 | head:( element:Argument { return element } )
403 | tail:( __ "," __ element:Argument { return element } )*
404 | { return [head, ...tail] }
405 |
406 | Argument = StringLiteral / BoolLiteral / NullLiteral / MoneyLiteral / VarName
407 |
408 | // Mutate stuff
409 | // For time constraints, only implements inc in numbers
410 |
411 | Mutate =
412 | "mutate" _ v:VarName _ "++" _ StatementEnd
413 | { return { type: 'mutate', var:v.value, mutation: '++' }}
414 |
--------------------------------------------------------------------------------
/node/examples/fdcFizzBuzzDelegator.E™:
--------------------------------------------------------------------------------
1 | /©
2 | This code is property of Enterprise™.
3 | ©/
4 |
5 | import disruptive library com.disruptive.IO.write.delegator.dlIOWriteDelegator;;;
6 |
7 | /NDA
8 | This document is regulated by NDA 758-1.
9 | NDA/
10 |
11 | final disruptive class fdcFizzBuzzDelegator {
12 | final immutable void main () {
13 | var Money x = 0;;;
14 | var String out = "";;;
15 |
16 | while (x < 1k) {
17 | if(x % 5 == 0 && x % 3 == 0) {
18 | write("Fizz Buzz");;;
19 | } else {
20 | if(x % 3 == 0) {
21 | write("Fizz");;;
22 | } else {
23 | if(x % 5 == 0) {
24 | write("Buzz");;;
25 | } else {
26 | write(x);;;
27 | }
28 | }
29 | }
30 |
31 | mutate x++;;;
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/node/examples/fdcUnicornEvaluator.E™:
--------------------------------------------------------------------------------
1 | /©
2 | This code is property of Enterprise™.
3 | ©/
4 |
5 | import disruptive library com.disruptive.IO.read.delegator.dlIOReadDelegator;;;
6 | import disruptive library com.disruptive.IO.write.delegator.dlIOWriteDelegator;;;
7 | import disruptive library com.disruptive.String.contains.delegator.dlStringContainsDelegator;;;
8 |
9 | /NDA
10 | This document is regulated by NDA 694-2.
11 | NDA/
12 |
13 | final disruptive class fdcUnicornEvaluator {
14 | final immutable void main () {
15 | var String answer = read("Tell us your idea: ");;;
16 |
17 | if(contains(answer, "Blockchain")) {
18 | write("Disruptive. 🦄🦄🦄🦄🦄");;;
19 | } else {
20 | if(contains(answer, "Tinder")) {
21 | write("Pain killer. 🦄🦄🦄🦄");;;
22 | } else {
23 | if(contains(answer, "Cloud")) {
24 | write("Vitamin. 🦄🦄🦄");;;
25 | } else {
26 | if(contains(answer, "Facebook")) {
27 | write("Will sleep on that. 🦄🦄");;;
28 | } else {
29 | if(contains(answer, "Chat")) {
30 | write("Meh. 🦄");;;
31 | } else {
32 | write("Cockroach.");;;
33 | }
34 | }
35 | }
36 | }
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/node/fdcFizzBuzzDelegator.E™:
--------------------------------------------------------------------------------
1 | /©
2 | This code is property of Enterprise™.
3 | ©/
4 |
5 | import disruptive library com.disruptive.IO.write.delegator.dlIOWriteDelegator;;;
6 |
7 | /NDA
8 | This document is regulated by NDA 758-1.
9 | NDA/
10 |
11 | final disruptive class fdcFizzBuzzDelegator {
12 | final immutable void main () {
13 | var Money x = 0;;;
14 | var String out = "";;;
15 |
16 | while (x < 1k) {
17 | if(x % 5 == 0 && x % 3 == 0) {
18 | write("Fizz Buzz");;;
19 | } else {
20 | if(x % 3 == 0) {
21 | write("Fizz");;;
22 | } else {
23 | if(x % 5 == 0) {
24 | write("Buzz");;;
25 | } else {
26 | write(x);;;
27 | }
28 | }
29 | }
30 |
31 | mutate x++;;;
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/node/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "enterprise-web",
3 | "version": "3.0.8-xp-tm",
4 | "description": "Enterprise™ programming language for the Web3.0™",
5 | "main": "index.js",
6 | "author": "Juan Lulkin (https://medium.com/@joaomilho/)",
7 | "license": "/© This code is property of Enterprise™. ©/",
8 | "homepage": "https://github.com/joaomilho/Enterprise-Web3.0",
9 | "repository": {
10 | "type" : "git",
11 | "url" : "https://github.com/joaomilho/Enterprise-Web3.0"
12 | },
13 | "dependencies": {
14 | "cli-highlight": "^2.1.4",
15 | "colors": "^1.4.0",
16 | "pegjs": "^0.10.0",
17 | "yargs": "^15.3.1"
18 | },
19 | "scripts": {
20 | "test": "echo 'ITS OK DAMNIT'"
21 | },
22 | "bin": {
23 | "E™": "./E™",
24 | "ETM": "./E™",
25 | "enterprise-web": "./E™"
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/node/yarn.lock:
--------------------------------------------------------------------------------
1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2 | # yarn lockfile v1
3 |
4 |
5 | "@types/color-name@^1.1.1":
6 | version "1.1.1"
7 | resolved "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0"
8 | integrity sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==
9 |
10 | ansi-regex@^5.0.0:
11 | version "5.0.1"
12 | resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304"
13 | integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==
14 |
15 | ansi-styles@^4.0.0, ansi-styles@^4.1.0:
16 | version "4.2.1"
17 | resolved "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz#90ae75c424d008d2624c5bf29ead3177ebfcf359"
18 | integrity sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==
19 | dependencies:
20 | "@types/color-name" "^1.1.1"
21 | color-convert "^2.0.1"
22 |
23 | any-promise@^1.0.0:
24 | version "1.3.0"
25 | resolved "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz#abc6afeedcea52e809cdc0376aed3ce39635d17f"
26 | integrity sha1-q8av7tzqUugJzcA3au0845Y10X8=
27 |
28 | camelcase@^5.0.0:
29 | version "5.3.1"
30 | resolved "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320"
31 | integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==
32 |
33 | chalk@^3.0.0:
34 | version "3.0.0"
35 | resolved "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz#3f73c2bf526591f574cc492c51e2456349f844e4"
36 | integrity sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==
37 | dependencies:
38 | ansi-styles "^4.1.0"
39 | supports-color "^7.1.0"
40 |
41 | cli-highlight@^2.1.4:
42 | version "2.1.4"
43 | resolved "https://registry.npmjs.org/cli-highlight/-/cli-highlight-2.1.4.tgz#098cb642cf17f42adc1c1145e07f960ec4d7522b"
44 | integrity sha512-s7Zofobm20qriqDoU9sXptQx0t2R9PEgac92mENNm7xaEe1hn71IIMsXMK+6encA6WRCWWxIGQbipr3q998tlQ==
45 | dependencies:
46 | chalk "^3.0.0"
47 | highlight.js "^9.6.0"
48 | mz "^2.4.0"
49 | parse5 "^5.1.1"
50 | parse5-htmlparser2-tree-adapter "^5.1.1"
51 | yargs "^15.0.0"
52 |
53 | cliui@^6.0.0:
54 | version "6.0.0"
55 | resolved "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz#511d702c0c4e41ca156d7d0e96021f23e13225b1"
56 | integrity sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==
57 | dependencies:
58 | string-width "^4.2.0"
59 | strip-ansi "^6.0.0"
60 | wrap-ansi "^6.2.0"
61 |
62 | color-convert@^2.0.1:
63 | version "2.0.1"
64 | resolved "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3"
65 | integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==
66 | dependencies:
67 | color-name "~1.1.4"
68 |
69 | color-name@~1.1.4:
70 | version "1.1.4"
71 | resolved "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2"
72 | integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==
73 |
74 | colors@^1.4.0:
75 | version "1.4.0"
76 | resolved "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz#c50491479d4c1bdaed2c9ced32cf7c7dc2360f78"
77 | integrity sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==
78 |
79 | decamelize@^1.2.0:
80 | version "1.2.0"
81 | resolved "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290"
82 | integrity sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=
83 |
84 | emoji-regex@^8.0.0:
85 | version "8.0.0"
86 | resolved "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37"
87 | integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==
88 |
89 | find-up@^4.1.0:
90 | version "4.1.0"
91 | resolved "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19"
92 | integrity sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==
93 | dependencies:
94 | locate-path "^5.0.0"
95 | path-exists "^4.0.0"
96 |
97 | get-caller-file@^2.0.1:
98 | version "2.0.5"
99 | resolved "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e"
100 | integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==
101 |
102 | has-flag@^4.0.0:
103 | version "4.0.0"
104 | resolved "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b"
105 | integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==
106 |
107 | highlight.js@^9.6.0:
108 | version "9.18.5"
109 | resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-9.18.5.tgz#d18a359867f378c138d6819edfc2a8acd5f29825"
110 | integrity sha512-a5bFyofd/BHCX52/8i8uJkjr9DYwXIPnM/plwI6W7ezItLGqzt7X2G2nXuYSfsIJdkwwj/g9DG1LkcGJI/dDoA==
111 |
112 | is-fullwidth-code-point@^3.0.0:
113 | version "3.0.0"
114 | resolved "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d"
115 | integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==
116 |
117 | locate-path@^5.0.0:
118 | version "5.0.0"
119 | resolved "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz#1afba396afd676a6d42504d0a67a3a7eb9f62aa0"
120 | integrity sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==
121 | dependencies:
122 | p-locate "^4.1.0"
123 |
124 | mz@^2.4.0:
125 | version "2.7.0"
126 | resolved "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz#95008057a56cafadc2bc63dde7f9ff6955948e32"
127 | integrity sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==
128 | dependencies:
129 | any-promise "^1.0.0"
130 | object-assign "^4.0.1"
131 | thenify-all "^1.0.0"
132 |
133 | object-assign@^4.0.1:
134 | version "4.1.1"
135 | resolved "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
136 | integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=
137 |
138 | p-limit@^2.2.0:
139 | version "2.3.0"
140 | resolved "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1"
141 | integrity sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==
142 | dependencies:
143 | p-try "^2.0.0"
144 |
145 | p-locate@^4.1.0:
146 | version "4.1.0"
147 | resolved "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz#a3428bb7088b3a60292f66919278b7c297ad4f07"
148 | integrity sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==
149 | dependencies:
150 | p-limit "^2.2.0"
151 |
152 | p-try@^2.0.0:
153 | version "2.0.0"
154 | resolved "https://registry.npmjs.org/p-try/-/p-try-2.0.0.tgz#85080bb87c64688fa47996fe8f7dfbe8211760b1"
155 |
156 | parse5-htmlparser2-tree-adapter@^5.1.1:
157 | version "5.1.1"
158 | resolved "https://registry.npmjs.org/parse5-htmlparser2-tree-adapter/-/parse5-htmlparser2-tree-adapter-5.1.1.tgz#e8c743d4e92194d5293ecde2b08be31e67461cbc"
159 | integrity sha512-CF+TKjXqoqyDwHqBhFQ+3l5t83xYi6fVT1tQNg+Ye0JRLnTxWvIroCjEp1A0k4lneHNBGnICUf0cfYVYGEazqw==
160 | dependencies:
161 | parse5 "^5.1.1"
162 |
163 | parse5@^5.1.1:
164 | version "5.1.1"
165 | resolved "https://registry.npmjs.org/parse5/-/parse5-5.1.1.tgz#f68e4e5ba1852ac2cadc00f4555fff6c2abb6178"
166 | integrity sha512-ugq4DFI0Ptb+WWjAdOK16+u/nHfiIrcE+sh8kZMaM0WllQKLI9rOUq6c2b7cwPkXdzfQESqvoqK6ug7U/Yyzug==
167 |
168 | path-exists@^4.0.0:
169 | version "4.0.0"
170 | resolved "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3"
171 | integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==
172 |
173 | pegjs@^0.10.0:
174 | version "0.10.0"
175 | resolved "https://registry.npmjs.org/pegjs/-/pegjs-0.10.0.tgz#cf8bafae6eddff4b5a7efb185269eaaf4610ddbd"
176 |
177 | require-directory@^2.1.1:
178 | version "2.1.1"
179 | resolved "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42"
180 |
181 | require-main-filename@^2.0.0:
182 | version "2.0.0"
183 | resolved "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b"
184 | integrity sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==
185 |
186 | set-blocking@^2.0.0:
187 | version "2.0.0"
188 | resolved "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7"
189 |
190 | string-width@^4.1.0, string-width@^4.2.0:
191 | version "4.2.0"
192 | resolved "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz#952182c46cc7b2c313d1596e623992bd163b72b5"
193 | integrity sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg==
194 | dependencies:
195 | emoji-regex "^8.0.0"
196 | is-fullwidth-code-point "^3.0.0"
197 | strip-ansi "^6.0.0"
198 |
199 | strip-ansi@^6.0.0:
200 | version "6.0.0"
201 | resolved "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz#0b1571dd7669ccd4f3e06e14ef1eed26225ae532"
202 | integrity sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==
203 | dependencies:
204 | ansi-regex "^5.0.0"
205 |
206 | supports-color@^7.1.0:
207 | version "7.1.0"
208 | resolved "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz#68e32591df73e25ad1c4b49108a2ec507962bfd1"
209 | integrity sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==
210 | dependencies:
211 | has-flag "^4.0.0"
212 |
213 | thenify-all@^1.0.0:
214 | version "1.6.0"
215 | resolved "https://registry.npmjs.org/thenify-all/-/thenify-all-1.6.0.tgz#1a1918d402d8fc3f98fbf234db0bcc8cc10e9726"
216 | integrity sha1-GhkY1ALY/D+Y+/I02wvMjMEOlyY=
217 | dependencies:
218 | thenify ">= 3.1.0 < 4"
219 |
220 | "thenify@>= 3.1.0 < 4":
221 | version "3.3.0"
222 | resolved "https://registry.npmjs.org/thenify/-/thenify-3.3.0.tgz#e69e38a1babe969b0108207978b9f62b88604839"
223 | integrity sha1-5p44obq+lpsBCCB5eLn2K4hgSDk=
224 | dependencies:
225 | any-promise "^1.0.0"
226 |
227 | which-module@^2.0.0:
228 | version "2.0.0"
229 | resolved "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a"
230 |
231 | wrap-ansi@^6.2.0:
232 | version "6.2.0"
233 | resolved "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz#e9393ba07102e6c91a3b221478f0257cd2856e53"
234 | integrity sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==
235 | dependencies:
236 | ansi-styles "^4.0.0"
237 | string-width "^4.1.0"
238 | strip-ansi "^6.0.0"
239 |
240 | y18n@^4.0.0:
241 | version "4.0.1"
242 | resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.1.tgz#8db2b83c31c5d75099bb890b23f3094891e247d4"
243 | integrity sha512-wNcy4NvjMYL8gogWWYAO7ZFWFfHcbdbE57tZO8e4cbpj8tfUcwrwqSl3ad8HxpYWCdXcJUCeKKZS62Av1affwQ==
244 |
245 | yargs-parser@^18.1.1:
246 | version "18.1.2"
247 | resolved "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.2.tgz#2f482bea2136dbde0861683abea7756d30b504f1"
248 | integrity sha512-hlIPNR3IzC1YuL1c2UwwDKpXlNFBqD1Fswwh1khz5+d8Cq/8yc/Mn0i+rQXduu8hcrFKvO7Eryk+09NecTQAAQ==
249 | dependencies:
250 | camelcase "^5.0.0"
251 | decamelize "^1.2.0"
252 |
253 | yargs@^15.0.0, yargs@^15.3.1:
254 | version "15.3.1"
255 | resolved "https://registry.npmjs.org/yargs/-/yargs-15.3.1.tgz#9505b472763963e54afe60148ad27a330818e98b"
256 | integrity sha512-92O1HWEjw27sBfgmXiixJWT5hRBp2eobqXicLtPBIDBhYB+1HpwZlXmbW2luivBJHBzki+7VyCLRtAkScbTBQA==
257 | dependencies:
258 | cliui "^6.0.0"
259 | decamelize "^1.2.0"
260 | find-up "^4.1.0"
261 | get-caller-file "^2.0.1"
262 | require-directory "^2.1.1"
263 | require-main-filename "^2.0.0"
264 | set-blocking "^2.0.0"
265 | string-width "^4.2.0"
266 | which-module "^2.0.0"
267 | y18n "^4.0.0"
268 | yargs-parser "^18.1.1"
269 |
--------------------------------------------------------------------------------
/rust/.gitignore:
--------------------------------------------------------------------------------
1 | /target
2 |
--------------------------------------------------------------------------------
/rust/Cargo.lock:
--------------------------------------------------------------------------------
1 | # This file is automatically @generated by Cargo.
2 | # It is not intended for manual editing.
3 | version = 3
4 |
5 | [[package]]
6 | name = "anyhow"
7 | version = "1.0.32"
8 | source = "registry+https://github.com/rust-lang/crates.io-index"
9 | checksum = "6b602bfe940d21c130f3895acd65221e8a61270debe89d628b9cb4e3ccb8569b"
10 |
11 | [[package]]
12 | name = "bitflags"
13 | version = "1.2.1"
14 | source = "registry+https://github.com/rust-lang/crates.io-index"
15 | checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
16 |
17 | [[package]]
18 | name = "block-buffer"
19 | version = "0.7.3"
20 | source = "registry+https://github.com/rust-lang/crates.io-index"
21 | checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b"
22 | dependencies = [
23 | "block-padding",
24 | "byte-tools",
25 | "byteorder",
26 | "generic-array",
27 | ]
28 |
29 | [[package]]
30 | name = "block-padding"
31 | version = "0.1.5"
32 | source = "registry+https://github.com/rust-lang/crates.io-index"
33 | checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5"
34 | dependencies = [
35 | "byte-tools",
36 | ]
37 |
38 | [[package]]
39 | name = "byte-tools"
40 | version = "0.3.1"
41 | source = "registry+https://github.com/rust-lang/crates.io-index"
42 | checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7"
43 |
44 | [[package]]
45 | name = "byteorder"
46 | version = "1.3.4"
47 | source = "registry+https://github.com/rust-lang/crates.io-index"
48 | checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
49 |
50 | [[package]]
51 | name = "cc"
52 | version = "1.0.59"
53 | source = "registry+https://github.com/rust-lang/crates.io-index"
54 | checksum = "66120af515773fb005778dc07c261bd201ec8ce50bd6e7144c927753fe013381"
55 |
56 | [[package]]
57 | name = "cfg-if"
58 | version = "0.1.10"
59 | source = "registry+https://github.com/rust-lang/crates.io-index"
60 | checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
61 |
62 | [[package]]
63 | name = "cranelift"
64 | version = "0.63.0"
65 | source = "registry+https://github.com/rust-lang/crates.io-index"
66 | checksum = "e1cf507e6587f6c931fab5636291cd95dc66534413887ba1d4e09c816b3a8a4c"
67 | dependencies = [
68 | "cranelift-codegen",
69 | "cranelift-frontend",
70 | ]
71 |
72 | [[package]]
73 | name = "cranelift-bforest"
74 | version = "0.63.0"
75 | source = "registry+https://github.com/rust-lang/crates.io-index"
76 | checksum = "d4425bb6c3f3d2f581c650f1a1fdd3196a975490149cf59bea9d34c3bea79eda"
77 | dependencies = [
78 | "cranelift-entity",
79 | ]
80 |
81 | [[package]]
82 | name = "cranelift-codegen"
83 | version = "0.63.0"
84 | source = "registry+https://github.com/rust-lang/crates.io-index"
85 | checksum = "d166b289fd30062ee6de86284750fc3fe5d037c6b864b3326ce153239b0626e1"
86 | dependencies = [
87 | "byteorder",
88 | "cranelift-bforest",
89 | "cranelift-codegen-meta",
90 | "cranelift-codegen-shared",
91 | "cranelift-entity",
92 | "log",
93 | "regalloc",
94 | "smallvec",
95 | "target-lexicon",
96 | "thiserror",
97 | ]
98 |
99 | [[package]]
100 | name = "cranelift-codegen-meta"
101 | version = "0.63.0"
102 | source = "registry+https://github.com/rust-lang/crates.io-index"
103 | checksum = "02c9fb2306a36d41c5facd4bf3400bc6c157185c43a96eaaa503471c34c5144b"
104 | dependencies = [
105 | "cranelift-codegen-shared",
106 | "cranelift-entity",
107 | ]
108 |
109 | [[package]]
110 | name = "cranelift-codegen-shared"
111 | version = "0.63.0"
112 | source = "registry+https://github.com/rust-lang/crates.io-index"
113 | checksum = "44e0cfe9b1f97d9f836bca551618106c7d53b93b579029ecd38e73daa7eb689e"
114 |
115 | [[package]]
116 | name = "cranelift-entity"
117 | version = "0.63.0"
118 | source = "registry+https://github.com/rust-lang/crates.io-index"
119 | checksum = "926a73c432e5ba9c891171ff50b75e7d992cd76cd271f0a0a0ba199138077472"
120 |
121 | [[package]]
122 | name = "cranelift-frontend"
123 | version = "0.63.0"
124 | source = "registry+https://github.com/rust-lang/crates.io-index"
125 | checksum = "e45f82e3446dd1ebb8c2c2f6a6b0e6cd6cd52965c7e5f7b1b35e9a9ace31ccde"
126 | dependencies = [
127 | "cranelift-codegen",
128 | "log",
129 | "smallvec",
130 | "target-lexicon",
131 | ]
132 |
133 | [[package]]
134 | name = "cranelift-module"
135 | version = "0.63.0"
136 | source = "registry+https://github.com/rust-lang/crates.io-index"
137 | checksum = "b6a1afb05dde53eea3dea586c38867037174bb9aeb8a467d5760fcdf8ef867a5"
138 | dependencies = [
139 | "anyhow",
140 | "cranelift-codegen",
141 | "cranelift-entity",
142 | "log",
143 | "thiserror",
144 | ]
145 |
146 | [[package]]
147 | name = "cranelift-native"
148 | version = "0.63.0"
149 | source = "registry+https://github.com/rust-lang/crates.io-index"
150 | checksum = "488b5d481bb0996a143e55a9d1739ef425efa20d4a5e5e98c859a8573c9ead9a"
151 | dependencies = [
152 | "cranelift-codegen",
153 | "raw-cpuid",
154 | "target-lexicon",
155 | ]
156 |
157 | [[package]]
158 | name = "cranelift-simplejit"
159 | version = "0.63.0"
160 | source = "registry+https://github.com/rust-lang/crates.io-index"
161 | checksum = "19bad89f03c9c9301c1bae9a74039198d510bb5ad4d475805eb54c6e7fea8149"
162 | dependencies = [
163 | "cranelift-codegen",
164 | "cranelift-module",
165 | "cranelift-native",
166 | "errno",
167 | "libc",
168 | "region",
169 | "target-lexicon",
170 | "winapi",
171 | ]
172 |
173 | [[package]]
174 | name = "digest"
175 | version = "0.8.1"
176 | source = "registry+https://github.com/rust-lang/crates.io-index"
177 | checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5"
178 | dependencies = [
179 | "generic-array",
180 | ]
181 |
182 | [[package]]
183 | name = "enterprise"
184 | version = "0.1.0"
185 | dependencies = [
186 | "cranelift",
187 | "cranelift-module",
188 | "cranelift-simplejit",
189 | "pest",
190 | "pest_derive",
191 | "serde",
192 | ]
193 |
194 | [[package]]
195 | name = "errno"
196 | version = "0.2.6"
197 | source = "registry+https://github.com/rust-lang/crates.io-index"
198 | checksum = "6eab5ee3df98a279d9b316b1af6ac95422127b1290317e6d18c1743c99418b01"
199 | dependencies = [
200 | "errno-dragonfly",
201 | "libc",
202 | "winapi",
203 | ]
204 |
205 | [[package]]
206 | name = "errno-dragonfly"
207 | version = "0.1.1"
208 | source = "registry+https://github.com/rust-lang/crates.io-index"
209 | checksum = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067"
210 | dependencies = [
211 | "gcc",
212 | "libc",
213 | ]
214 |
215 | [[package]]
216 | name = "fake-simd"
217 | version = "0.1.2"
218 | source = "registry+https://github.com/rust-lang/crates.io-index"
219 | checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
220 |
221 | [[package]]
222 | name = "gcc"
223 | version = "0.3.55"
224 | source = "registry+https://github.com/rust-lang/crates.io-index"
225 | checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2"
226 |
227 | [[package]]
228 | name = "generic-array"
229 | version = "0.12.4"
230 | source = "registry+https://github.com/rust-lang/crates.io-index"
231 | checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd"
232 | dependencies = [
233 | "typenum",
234 | ]
235 |
236 | [[package]]
237 | name = "libc"
238 | version = "0.2.76"
239 | source = "registry+https://github.com/rust-lang/crates.io-index"
240 | checksum = "755456fae044e6fa1ebbbd1b3e902ae19e73097ed4ed87bb79934a867c007bc3"
241 |
242 | [[package]]
243 | name = "log"
244 | version = "0.4.11"
245 | source = "registry+https://github.com/rust-lang/crates.io-index"
246 | checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b"
247 | dependencies = [
248 | "cfg-if",
249 | ]
250 |
251 | [[package]]
252 | name = "mach"
253 | version = "0.3.2"
254 | source = "registry+https://github.com/rust-lang/crates.io-index"
255 | checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa"
256 | dependencies = [
257 | "libc",
258 | ]
259 |
260 | [[package]]
261 | name = "maplit"
262 | version = "1.0.2"
263 | source = "registry+https://github.com/rust-lang/crates.io-index"
264 | checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d"
265 |
266 | [[package]]
267 | name = "opaque-debug"
268 | version = "0.2.3"
269 | source = "registry+https://github.com/rust-lang/crates.io-index"
270 | checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c"
271 |
272 | [[package]]
273 | name = "pest"
274 | version = "2.1.3"
275 | source = "registry+https://github.com/rust-lang/crates.io-index"
276 | checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53"
277 | dependencies = [
278 | "ucd-trie",
279 | ]
280 |
281 | [[package]]
282 | name = "pest_derive"
283 | version = "2.1.0"
284 | source = "registry+https://github.com/rust-lang/crates.io-index"
285 | checksum = "833d1ae558dc601e9a60366421196a8d94bc0ac980476d0b67e1d0988d72b2d0"
286 | dependencies = [
287 | "pest",
288 | "pest_generator",
289 | ]
290 |
291 | [[package]]
292 | name = "pest_generator"
293 | version = "2.1.3"
294 | source = "registry+https://github.com/rust-lang/crates.io-index"
295 | checksum = "99b8db626e31e5b81787b9783425769681b347011cc59471e33ea46d2ea0cf55"
296 | dependencies = [
297 | "pest",
298 | "pest_meta",
299 | "proc-macro2",
300 | "quote",
301 | "syn",
302 | ]
303 |
304 | [[package]]
305 | name = "pest_meta"
306 | version = "2.1.3"
307 | source = "registry+https://github.com/rust-lang/crates.io-index"
308 | checksum = "54be6e404f5317079812fc8f9f5279de376d8856929e21c184ecf6bbd692a11d"
309 | dependencies = [
310 | "maplit",
311 | "pest",
312 | "sha-1",
313 | ]
314 |
315 | [[package]]
316 | name = "proc-macro2"
317 | version = "1.0.19"
318 | source = "registry+https://github.com/rust-lang/crates.io-index"
319 | checksum = "04f5f085b5d71e2188cb8271e5da0161ad52c3f227a661a3c135fdf28e258b12"
320 | dependencies = [
321 | "unicode-xid",
322 | ]
323 |
324 | [[package]]
325 | name = "quote"
326 | version = "1.0.7"
327 | source = "registry+https://github.com/rust-lang/crates.io-index"
328 | checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37"
329 | dependencies = [
330 | "proc-macro2",
331 | ]
332 |
333 | [[package]]
334 | name = "raw-cpuid"
335 | version = "7.0.3"
336 | source = "registry+https://github.com/rust-lang/crates.io-index"
337 | checksum = "b4a349ca83373cfa5d6dbb66fd76e58b2cca08da71a5f6400de0a0a6a9bceeaf"
338 | dependencies = [
339 | "bitflags",
340 | "cc",
341 | "rustc_version",
342 | ]
343 |
344 | [[package]]
345 | name = "regalloc"
346 | version = "0.0.21"
347 | source = "registry+https://github.com/rust-lang/crates.io-index"
348 | checksum = "b27b256b41986ac5141b37b8bbba85d314fbf546c182eb255af6720e07e4f804"
349 | dependencies = [
350 | "log",
351 | "rustc-hash",
352 | "smallvec",
353 | ]
354 |
355 | [[package]]
356 | name = "region"
357 | version = "2.2.0"
358 | source = "registry+https://github.com/rust-lang/crates.io-index"
359 | checksum = "877e54ea2adcd70d80e9179344c97f93ef0dffd6b03e1f4529e6e83ab2fa9ae0"
360 | dependencies = [
361 | "bitflags",
362 | "libc",
363 | "mach",
364 | "winapi",
365 | ]
366 |
367 | [[package]]
368 | name = "rustc-hash"
369 | version = "1.1.0"
370 | source = "registry+https://github.com/rust-lang/crates.io-index"
371 | checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
372 |
373 | [[package]]
374 | name = "rustc_version"
375 | version = "0.2.3"
376 | source = "registry+https://github.com/rust-lang/crates.io-index"
377 | checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
378 | dependencies = [
379 | "semver",
380 | ]
381 |
382 | [[package]]
383 | name = "semver"
384 | version = "0.9.0"
385 | source = "registry+https://github.com/rust-lang/crates.io-index"
386 | checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
387 | dependencies = [
388 | "semver-parser",
389 | ]
390 |
391 | [[package]]
392 | name = "semver-parser"
393 | version = "0.7.0"
394 | source = "registry+https://github.com/rust-lang/crates.io-index"
395 | checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
396 |
397 | [[package]]
398 | name = "serde"
399 | version = "1.0.115"
400 | source = "registry+https://github.com/rust-lang/crates.io-index"
401 | checksum = "e54c9a88f2da7238af84b5101443f0c0d0a3bbdc455e34a5c9497b1903ed55d5"
402 | dependencies = [
403 | "serde_derive",
404 | ]
405 |
406 | [[package]]
407 | name = "serde_derive"
408 | version = "1.0.115"
409 | source = "registry+https://github.com/rust-lang/crates.io-index"
410 | checksum = "609feed1d0a73cc36a0182a840a9b37b4a82f0b1150369f0536a9e3f2a31dc48"
411 | dependencies = [
412 | "proc-macro2",
413 | "quote",
414 | "syn",
415 | ]
416 |
417 | [[package]]
418 | name = "sha-1"
419 | version = "0.8.2"
420 | source = "registry+https://github.com/rust-lang/crates.io-index"
421 | checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df"
422 | dependencies = [
423 | "block-buffer",
424 | "digest",
425 | "fake-simd",
426 | "opaque-debug",
427 | ]
428 |
429 | [[package]]
430 | name = "smallvec"
431 | version = "1.8.0"
432 | source = "registry+https://github.com/rust-lang/crates.io-index"
433 | checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83"
434 |
435 | [[package]]
436 | name = "syn"
437 | version = "1.0.39"
438 | source = "registry+https://github.com/rust-lang/crates.io-index"
439 | checksum = "891d8d6567fe7c7f8835a3a98af4208f3846fba258c1bc3c31d6e506239f11f9"
440 | dependencies = [
441 | "proc-macro2",
442 | "quote",
443 | "unicode-xid",
444 | ]
445 |
446 | [[package]]
447 | name = "target-lexicon"
448 | version = "0.10.0"
449 | source = "registry+https://github.com/rust-lang/crates.io-index"
450 | checksum = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d"
451 |
452 | [[package]]
453 | name = "thiserror"
454 | version = "1.0.20"
455 | source = "registry+https://github.com/rust-lang/crates.io-index"
456 | checksum = "7dfdd070ccd8ccb78f4ad66bf1982dc37f620ef696c6b5028fe2ed83dd3d0d08"
457 | dependencies = [
458 | "thiserror-impl",
459 | ]
460 |
461 | [[package]]
462 | name = "thiserror-impl"
463 | version = "1.0.20"
464 | source = "registry+https://github.com/rust-lang/crates.io-index"
465 | checksum = "bd80fc12f73063ac132ac92aceea36734f04a1d93c1240c6944e23a3b8841793"
466 | dependencies = [
467 | "proc-macro2",
468 | "quote",
469 | "syn",
470 | ]
471 |
472 | [[package]]
473 | name = "typenum"
474 | version = "1.12.0"
475 | source = "registry+https://github.com/rust-lang/crates.io-index"
476 | checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33"
477 |
478 | [[package]]
479 | name = "ucd-trie"
480 | version = "0.1.3"
481 | source = "registry+https://github.com/rust-lang/crates.io-index"
482 | checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c"
483 |
484 | [[package]]
485 | name = "unicode-xid"
486 | version = "0.2.1"
487 | source = "registry+https://github.com/rust-lang/crates.io-index"
488 | checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
489 |
490 | [[package]]
491 | name = "winapi"
492 | version = "0.3.9"
493 | source = "registry+https://github.com/rust-lang/crates.io-index"
494 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
495 | dependencies = [
496 | "winapi-i686-pc-windows-gnu",
497 | "winapi-x86_64-pc-windows-gnu",
498 | ]
499 |
500 | [[package]]
501 | name = "winapi-i686-pc-windows-gnu"
502 | version = "0.4.0"
503 | source = "registry+https://github.com/rust-lang/crates.io-index"
504 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
505 |
506 | [[package]]
507 | name = "winapi-x86_64-pc-windows-gnu"
508 | version = "0.4.0"
509 | source = "registry+https://github.com/rust-lang/crates.io-index"
510 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
511 |
--------------------------------------------------------------------------------
/rust/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "enterprise"
3 | version = "0.1.0"
4 | authors = ["Juan Lulkin "]
5 | edition = "2018"
6 |
7 | [dependencies]
8 | serde = { version = "1.0", features = ["derive"] }
9 | pest = "2.0"
10 | pest_derive = "2.0"
11 | cranelift = "0.63.0"
12 | cranelift-module = "0.63.0"
13 | cranelift-simplejit = "0.63.0"
14 |
--------------------------------------------------------------------------------
/rust/README.md:
--------------------------------------------------------------------------------
1 | # Enterprise™ rust edition X™
2 |
3 |
4 |
5 | Enterprise™ rust edition X™ is a parser and [soon to be] compiler for the
6 | [Enterprise™](https://github.com/joaomilho/Enterprise) language written in [Rust](https://www.rust-lang.org/).
7 |
8 | Enterprise™ rust edition X™ is reliable and efficient - since it's Rust – but it's
9 | also disruptive – since it's Enterprise™. What a combo!
10 |
11 | ## Roadmap
12 |
13 | ☑ Parser with pest
14 | ☐ Compiler with cranelift
15 |
--------------------------------------------------------------------------------
/rust/src/e.pest:
--------------------------------------------------------------------------------
1 | program = _{ copyright_comment ~ S* ~ import* ~ S* ~ disruptive_class }
2 |
3 | lib = {
4 | "IO.write.delegator.dlIOWriteDelegator" |
5 | "IO.read.delegator.dlIOReadDelegator" |
6 | "String.contains.delegator.dlStringContainsDelegator" }
7 |
8 | import = _{ "import disruptive library com.disruptive." ~ lib ~ eos ~ S* }
9 |
10 | disruptive_class = _{
11 | "final disruptive class fdc" ~
12 | enterprisey_word+ ~ S* ~
13 | class_body }
14 |
15 | class_body = _{ "{" ~ S* ~ main_method ~ S* ~ "}" }
16 |
17 | main_method = _{ "final immutable void main () {" ~ S* ~ expr* ~ S* ~ "}" }
18 |
19 | expr = _{ S* ~ (decl | if_else_clause | if_clause | while_clause | mutate | call_expr) ~ S* }
20 |
21 | call_expr = _{ call ~ eos }
22 | call = { callee ~ "(" ~ S* ~ args? ~ S* ~ ")" }
23 | callee = { var_name }
24 |
25 | args = { arg ~ S* ~ ("," ~ S* ~ arg ~ S*)* }
26 | arg = _{ call | lit | var_name }
27 |
28 | mutate = { "mutate" ~ S+ ~ var_name ~ mutation ~ eos }
29 | mutation = { "++" | "--" }
30 |
31 | exprs = { expr* }
32 |
33 | block = _{ "{" ~ S* ~ exprs ~ S* ~ "}" }
34 | test = _{ S* ~ "(" ~ S* ~ testable ~ S* ~ ")" ~ S* }
35 |
36 | if_clause = { "if" ~ test ~ block }
37 | if_else_clause = { "if" ~ test ~ block ~ S* ~ "else" ~ S* ~ block }
38 | while_clause = { "while" ~ test ~ S* ~ block }
39 |
40 | testable = { binary_unit ~ (S* ~ bin_op ~ S* ~ binary_unit)* }
41 | binary_unit = _{ "(" ~ testable ~ ")" | unary }
42 | bin_op = _{ math_op | rel_op | eq_op | log_op }
43 | unary = _{ arg | (unary_op ~ S* ~ unary) }
44 |
45 | // literals
46 |
47 | lit = _{ bool | money | null | string_box }
48 |
49 | bool = { "true" | "false" }
50 | money = { digits ~ valuation? }
51 | null = { "null" }
52 | string_box = _{ "\"" ~ string ~ "\"" }
53 | string = @{ char* }
54 | digits = { ASCII_DIGIT+ }
55 |
56 | valuation = { "k" | "M" | "B" | "T" }
57 |
58 | // ops
59 |
60 | unary_op = { "!" }
61 | math_op = { "*" | "/" | "%" | "+" | "-" }
62 | rel_op = { "<=" | ">=" | "<" | ">" }
63 | eq_op = { "==" | "!=" }
64 | log_op = { "&&" | "||" }
65 |
66 | // declarations
67 |
68 | var_type = { "String" | "Money" | "Bool" | "Null" }
69 | decl = { "var" ~ S ~ var_type ~ S ~ var_name ~ S ~ "=" ~ S ~ (lit | call) ~ S* ~ eos }
70 | var_name = { 'a'..'z'{1,8} }
71 |
72 | eos = _{ ";;;" }
73 |
74 | char = {
75 | !("\"" | "\\") ~ ANY
76 | | "\\" ~ ("\"" | "\\" | "/" | "b" | "f" | "n" | "r" | "t")
77 | | "\\" ~ ("u" ~ ASCII_HEX_DIGIT{4}) }
78 |
79 | // the words
80 |
81 | enterprisey_word = _{ "Accelerate" | "Acceleration" | "Account" | "Active" | "Activity" | "Agile" |
82 | "Agility" | "Ajax" | "Algo" | "Analytics" | "Analyze" | "Analyzer" | "Ballpark" | "Big" | "Bit" |
83 | "Bizmeth" | "Block" | "Boost" | "Bootstrap" | "Bootstraped" | "Brand" | "Business" | "Buzz" |
84 | "Car" | "Chain" | "Chart" | "Clickthrough" | "Cloud" | "Coin" | "Consumer" | "Content" |
85 | "Converge" | "Convergence" | "Coordinate" | "Coordinator" | "Complex" | "Convert" |
86 | "Convertion" | "Cost" | "Costs" | "Critical" | "Crypto" | "Currency" | "Customer" | "Cyber" |
87 | "Data" | "Deep" | "Delegate" | "Delegator" | "Design" | "Dev" | "Develop" | "Development" |
88 | "Digital" | "Disrupt" | "Disruptor" | "Disruptive" | "Diverse" | "Diversify" | "Diversifier" |
89 | "Diversity" | "Downsize" | "Downsized" | "Drive" | "Driven" | "Driver" | "Economy" | "Economic" |
90 | "Employ" | "Employee" | "Employer" | "Empowered" | "Engine" | "Enterprise" | "Entrepreneur" |
91 | "Entropy" | "Equity" | "Evolution" | "Evolve" | "Evolving" | "Eyeball" | "Eyeballs" |
92 | "Evaluation" | "Evaluator" | "Facade" | "Factory" | "Fast" | "Fee" | "Fizz" | "Flat" | "Founder" |
93 | "Founders" | "Framework" | "Free" | "Future" | "Fuzzy" | "Generate" | "Generation" | "Generator" |
94 | "Global" | "Gluten" | "Graph" | "Graphic" | "Group" | "Growth" | "Guideline" | "Guidelines" |
95 | "Hack" | "Hacking" | "Hardware" | "Holistic" | "Human" | "Hyperlocal" | "Immerse" | "Immersion" |
96 | "Immersive" | "Innovate" | "Innovative" | "Innovativity" | "Innovator" | "Internet" | "Intranet" |
97 | "Invest" | "Investment" | "Item" | "Iterator" | "Java" | "Lactose" | "Learn" | "Learning" |
98 | "Leverage" | "Line" | "List" | "Manage" | "Management" | "Manager" | "Market" | "Marketing" |
99 | "Media" | "Mega" | "Merchant" | "Message" | "Micro" | "Millenial" | "Mindshare" | "Mine" |
100 | "Mining" | "Mission" | "Module" | "Momentum" | "Money" | "Nano" | "Network" | "New" | "Next" |
101 | "Number" | "Nut" | "Object" | "Operation" | "Operator" | "Opportunity" | "Ops" | "Order" |
102 | "Organic" | "Paradigm" | "Passionate" | "Pattern" | "Person" | "Pie" | "Point" | "Policy" |
103 | "Portal" | "Product" | "Proof" | "Provable" | "Proxy" | "Resource" | "Return" | "Roadmap" |
104 | "Scalable" | "Science" | "Self" | "Service" | "Services" | "Share" | "Sharing" | "Simple" |
105 | "Skeuomorphic" | "Speed" | "Software" | "Solution" | "Square" | "Startup" | "Streamline" |
106 | "Streamlined" | "Super" | "Sustainability" | "Sustainable" | "Synergic" | "Synergy" | "System" |
107 | "Tax" | "Text" | "Time" | "Trade" | "Trans" | "Upsize" | "Upsizer" | "User" | "Viral" |
108 | "Virality" | "Viralize" | "Visual" | "Web" | "World" | "Serverless" | "Server" | "Side" |
109 | "Render" | "Universal" | "Native" | "Mobile" | "Angular" |
110 | "React" | "Component" | "Cache" | "Domain" | "Frontend" | "Full" | "Fullstack" |
111 | "Git" | "Hub" | "Information" | "Script" | "Query" | "Minification" | "First" |
112 | "Responsive" | "Ruby" | "Rails" | "Sitemap" | "Wireframe" | "Explorer" | "Netscape" |
113 | "Firefox" | "Chrome" | "Safari" | "Android" | "Apple" | "Opera" | "Scroll" |
114 | "Scrolling" | "Infinite" | "Landing" | "Hero" | "Mock" | "Mockup" | "Parallax" |
115 | "Meta" | "Tag" | "Template" | "Wireframe" | "Vector" | "Metro" | "Above" |
116 | "Fold" | "Grid" | "Canvas" | "Boilerplate" | "Modernizr" | "Blocking" | "Quirks" |
117 | "Sockets" | "Socket" | "Storage" | "Worker" | "Things" | "Unicorn" | "Quantum" }
118 |
119 | // ignorables: comments & spaces
120 |
121 | copyright_comment = _{ "/©" ~ (!"©/" ~ ANY)* ~ "©/" }
122 | nda_comment = _{ "/NDA" ~ (!"NDA/" ~ ANY)* ~ "NDA/" }
123 | passive_aggressive_comment = _{ "/?" ~ (!"?/" ~ ANY)* ~ "?/" }
124 | multi_line_comment = _{ "/*" ~ (!"*/" ~ ANY)* ~ "*/" }
125 | line_comment = _{ "//" ~ (!eol ~ ANY)* }
126 |
127 | comment = _{
128 | copyright_comment |
129 | nda_comment |
130 | passive_aggressive_comment |
131 | multi_line_comment |
132 | line_comment }
133 |
134 | eol = _{ "\u{000A}" | "\u{000D}" | "\u{2028}" | "\u{2029}" }
135 |
136 | S = _{
137 | comment |
138 | "\u{0009}" |
139 | "\u{000B}" |
140 | "\u{000C}" |
141 | "\u{0020}" |
142 | "\u{00A0}" |
143 | "\u{FEFF}" |
144 | SPACE_SEPARATOR |
145 | eol }
146 |
--------------------------------------------------------------------------------
/rust/src/lib.rs:
--------------------------------------------------------------------------------
1 | extern crate pest;
2 | #[macro_use]
3 | extern crate pest_derive;
4 |
5 | pub mod parser;
6 |
--------------------------------------------------------------------------------
/rust/src/main.rs:
--------------------------------------------------------------------------------
1 | use enterprise::parser::to_ast;
2 | use std::fs;
3 |
4 | fn main() {
5 | let fizz = fs::read_to_string("src/samples/fdcFizzBuzzDelegator.E™").expect("Cannot read fizz");
6 | let ast = to_ast(&fizz);
7 | println!("AST: {:?}", ast);
8 | }
9 |
--------------------------------------------------------------------------------
/rust/src/parser.rs:
--------------------------------------------------------------------------------
1 | use pest::iterators::{Pair, Pairs};
2 | use pest::Parser;
3 |
4 | #[derive(Parser)]
5 | #[grammar = "e.pest"]
6 | pub struct EParser;
7 |
8 | #[derive(Debug, Eq, PartialEq)]
9 | pub enum VarType {
10 | r#String,
11 | Boolean,
12 | Money,
13 | Null,
14 | }
15 |
16 | fn to_var_type(var_type: &str) -> VarType {
17 | match var_type {
18 | "String" => VarType::r#String,
19 | "Boolean" => VarType::Boolean,
20 | "Money" => VarType::Money,
21 | "Null" => VarType::Null,
22 | _ => unreachable!("No such var type"),
23 | }
24 | }
25 |
26 | #[derive(Debug, Eq, PartialEq)]
27 | pub enum OpType {
28 | GT,
29 | GTE,
30 | LT,
31 | LTE,
32 | EQ,
33 | NEQ,
34 | NOT,
35 | AND,
36 | OR,
37 | MUL,
38 | DIV,
39 | SUM,
40 | SUB,
41 | MOD,
42 | }
43 |
44 | fn to_op_type(op_type: &str) -> OpType {
45 | match op_type {
46 | ">" => OpType::GT,
47 | ">=" => OpType::GTE,
48 | "<" => OpType::LT,
49 | "<=" => OpType::LTE,
50 | "==" => OpType::EQ,
51 | "!=" => OpType::NEQ,
52 | "!" => OpType::NOT,
53 | "&&" => OpType::AND,
54 | "||" => OpType::OR,
55 | "*" => OpType::MUL,
56 | "/" => OpType::DIV,
57 | "+" => OpType::SUM,
58 | "-" => OpType::SUB,
59 | "%" => OpType::MOD,
60 | _ => unreachable!("No such op type"),
61 | }
62 | }
63 |
64 | #[derive(Debug, Eq, PartialEq)]
65 | pub enum MutType {
66 | INC,
67 | DEC,
68 | }
69 |
70 | fn to_mut_type(mut_type: &str) -> MutType {
71 | match mut_type {
72 | "++" => MutType::INC,
73 | "--" => MutType::DEC,
74 | _ => unreachable!("No such mut type"),
75 | }
76 | }
77 |
78 | #[derive(Debug, Eq, PartialEq)]
79 | pub enum E {
80 | Lib(String),
81 | LitString(String),
82 | LitMoney(usize),
83 | LitNull,
84 | LitBool(bool),
85 | Id(String),
86 | Decl(VarType, String, Box),
87 | If(Box, Vec),
88 | IfElse(Box, Vec, Vec),
89 | While(Box, Vec),
90 | Mutation(String, MutType),
91 | Call(String, Vec),
92 | Op(Box, OpType, Box),
93 | }
94 |
95 | impl E {
96 | fn call(callee: &str, params: Vec) -> E {
97 | E::Call(String::from(callee), params)
98 | }
99 |
100 | fn if_else(cond: E, if_block: Vec, else_block: Vec) -> E {
101 | E::IfElse(Box::new(cond), if_block, else_block)
102 | }
103 |
104 | fn r#if(cond: E, if_block: Vec) -> E {
105 | E::If(Box::new(cond), if_block)
106 | }
107 |
108 | fn mutation(var: &str, mutation: &str) -> E {
109 | E::Mutation(String::from(var), to_mut_type(mutation))
110 | }
111 |
112 | fn lib(s: &str) -> E {
113 | E::Lib(String::from(s))
114 | }
115 |
116 | fn lit_string(s: &str) -> E {
117 | E::LitString(String::from(s))
118 | }
119 |
120 | fn lit_money(v: usize) -> E {
121 | E::LitMoney(v)
122 | }
123 |
124 | fn lit_null() -> E {
125 | E::LitNull
126 | }
127 |
128 | fn lit_bool(b: bool) -> E {
129 | E::LitBool(b)
130 | }
131 |
132 | fn id(s: &str) -> E {
133 | E::Id(String::from(s))
134 | }
135 |
136 | fn decl(var_type: &str, name: &str, expr: E) -> E {
137 | E::Decl(to_var_type(var_type), String::from(name), Box::new(expr))
138 | }
139 |
140 | fn op(l: E, oper: &str, r: E) -> E {
141 | E::Op(Box::new(l), to_op_type(oper), Box::new(r))
142 | }
143 |
144 | fn r#while(cond: E, exprs: Vec) -> E {
145 | E::While(Box::new(cond), exprs)
146 | }
147 | }
148 |
149 | pub fn to_ast(code: &str) -> Vec {
150 | fn pairs_to_ast(pair: Pairs) -> Vec {
151 | return pair.map(pair_to_ast).collect();
152 | }
153 |
154 | fn option_to_ast(pair: Option>) -> Vec {
155 | match pair {
156 | Some(list) => list.into_inner().map(pair_to_ast).collect(),
157 | None => vec![],
158 | }
159 | }
160 |
161 | fn to_multiplier(pair: Option>) -> usize {
162 | match pair {
163 | Some(valuation) => match valuation.as_str() {
164 | "k" => 1000,
165 | "M" => 1000 * 1000,
166 | "B" => 1000 * 1000 * 1000,
167 | "T" => 1000 * 1000 * 1000 * 1000,
168 | _ => 1,
169 | },
170 | None => 1,
171 | }
172 | }
173 |
174 | fn pair_to_ast(pair: Pair) -> E {
175 | match pair.as_rule() {
176 | Rule::lib => E::lib(pair.as_str()),
177 | Rule::string => E::lit_string(pair.as_str()),
178 | Rule::money => {
179 | let mut inner = pair.into_inner();
180 | let value: usize = inner.next().unwrap().as_str().parse().expect("NAN");
181 | let multiplier = to_multiplier(inner.next());
182 |
183 | return E::lit_money(value * multiplier);
184 | }
185 | Rule::null => E::lit_null(),
186 | Rule::bool => E::lit_bool(pair.as_str() == "true"),
187 |
188 | Rule::var_name => E::id(pair.as_str()),
189 | Rule::decl => {
190 | let mut inner = pair.into_inner();
191 | let name = inner.next().unwrap().as_str();
192 | let r#type = inner.next().unwrap().as_str();
193 | let value = inner.next().unwrap();
194 | E::decl(name, r#type, pair_to_ast(value))
195 | }
196 | Rule::mutate => {
197 | let mut inner = pair.into_inner();
198 |
199 | let name = inner.next().unwrap().as_str();
200 | let mutation = inner.next().unwrap().as_str();
201 |
202 | return E::mutation(name, mutation);
203 | }
204 | Rule::call => {
205 | let mut inner = pair.into_inner();
206 |
207 | let callee = inner.next().unwrap().as_str();
208 |
209 | let args = option_to_ast(inner.next());
210 | return E::call(callee, args);
211 | }
212 |
213 | Rule::if_clause => {
214 | let mut inner = pair.into_inner();
215 | let testable = inner.next().unwrap();
216 |
217 | let statements = inner.next().unwrap().into_inner();
218 |
219 | return E::r#if(pair_to_ast(testable), pairs_to_ast(statements));
220 | }
221 |
222 | Rule::if_else_clause => {
223 | let mut inner = pair.into_inner();
224 | let testable = inner.next().unwrap();
225 |
226 | let if_block = inner.next().unwrap().into_inner();
227 | let else_block = inner.next().unwrap().into_inner();
228 |
229 | return E::if_else(
230 | pair_to_ast(testable),
231 | pairs_to_ast(if_block),
232 | pairs_to_ast(else_block),
233 | );
234 | }
235 |
236 | Rule::while_clause => {
237 | let mut inner = pair.into_inner();
238 | let testable = inner.next().unwrap();
239 |
240 | let statements = inner.next().unwrap().into_inner();
241 |
242 | return E::r#while(pair_to_ast(testable), pairs_to_ast(statements));
243 | }
244 |
245 | Rule::testable => {
246 | let mut inner = pair.into_inner();
247 | let len = inner.clone().count();
248 | match len {
249 | 3 => {
250 | return E::op(
251 | pair_to_ast(inner.next().unwrap()),
252 | inner.next().unwrap().as_str(),
253 | pair_to_ast(inner.next().unwrap()),
254 | );
255 | }
256 | _ => pair_to_ast(inner.next().unwrap()),
257 | }
258 | }
259 |
260 | _ => unreachable!(pair),
261 | }
262 | }
263 |
264 | let parsed = EParser::parse(Rule::program, &code).expect("unsuccessful parse");
265 |
266 | pairs_to_ast(parsed)
267 | }
268 |
269 | #[cfg(test)]
270 | mod test {
271 | use super::*;
272 | use std::fs;
273 |
274 | #[test]
275 | fn test_to_ast() {
276 | let fizz =
277 | fs::read_to_string("src/samples/fdcFizzBuzzDelegator.E™").expect("Cannot read fizz");
278 | let uni =
279 | fs::read_to_string("src/samples/fdcUnicornEvaluator.E™").expect("Cannot read uni");
280 |
281 | assert_eq!(
282 | to_ast(&uni),
283 | vec![
284 | E::lib("IO.read.delegator.dlIOReadDelegator"),
285 | E::lib("IO.write.delegator.dlIOWriteDelegator"),
286 | E::lib("String.contains.delegator.dlStringContainsDelegator"),
287 | E::decl(
288 | "String",
289 | "answer",
290 | E::call("read", vec![E::lit_string("Tell us your idea: ")])
291 | ),
292 | E::if_else(
293 | E::call(
294 | "contains",
295 | vec![E::id("answer"), E::lit_string("Blockchain")]
296 | ),
297 | vec![E::call(
298 | "write",
299 | vec![E::lit_string("Disruptive. 🦄🦄🦄🦄🦄")]
300 | )],
301 | vec![E::if_else(
302 | E::call("contains", vec![E::id("answer"), E::lit_string("Tinder")]),
303 | vec![E::call(
304 | "write",
305 | vec![E::lit_string("Pain killer. 🦄🦄🦄🦄")]
306 | )],
307 | vec![E::if_else(
308 | E::call("contains", vec![E::id("answer"), E::lit_string("Cloud")]),
309 | vec![E::call("write", vec![E::lit_string("Vitamin. 🦄🦄🦄")])],
310 | vec![E::if_else(
311 | E::call(
312 | "contains",
313 | vec![E::id("answer"), E::lit_string("Facebook")]
314 | ),
315 | vec![E::call(
316 | "write",
317 | vec![E::lit_string("Will sleep on that. 🦄🦄")]
318 | )],
319 | vec![E::if_else(
320 | E::call(
321 | "contains",
322 | vec![E::id("answer"), E::lit_string("Chat")]
323 | ),
324 | vec![E::call("write", vec![E::lit_string("Meh. 🦄")])],
325 | vec![E::call("write", vec![E::lit_string("Cockroach.")])]
326 | )]
327 | )]
328 | )]
329 | )]
330 | )
331 | ]
332 | );
333 |
334 | assert_eq!(
335 | to_ast(&fizz),
336 | vec![
337 | E::lib("IO.write.delegator.dlIOWriteDelegator"),
338 | E::decl("Money", "x", E::lit_money(0)),
339 | E::decl("String", "out", E::lit_string("")),
340 | E::r#while(
341 | E::op(E::id("x"), "<", E::lit_money(1000)),
342 | vec![
343 | E::if_else(
344 | E::op(
345 | E::op(
346 | E::op(E::id("x"), "%", E::lit_money(5)),
347 | "==",
348 | E::lit_money(0)
349 | ),
350 | "&&",
351 | E::op(
352 | E::op(E::id("x"), "%", E::lit_money(3)),
353 | "==",
354 | E::lit_money(0)
355 | ),
356 | ),
357 | vec![E::call("write", vec![E::lit_string("Fizz Buzz")])],
358 | vec![E::if_else(
359 | E::op(
360 | E::op(E::id("x"), "%", E::lit_money(3)),
361 | "==",
362 | E::lit_money(0)
363 | ),
364 | vec![E::call("write", vec![E::lit_string("Fizz")])],
365 | vec![E::if_else(
366 | E::op(
367 | E::op(E::id("x"), "%", E::lit_money(5)),
368 | "==",
369 | E::lit_money(0)
370 | ),
371 | vec![E::call("write", vec![E::lit_string("Buzz")])],
372 | vec![E::call("write", vec![E::id("x")])]
373 | )]
374 | )]
375 | ),
376 | E::mutation("x", "++")
377 | ]
378 | )
379 | ]
380 | )
381 | }
382 | }
383 |
--------------------------------------------------------------------------------
/rust/src/samples/fdcFizzBuzzDelegator.E™:
--------------------------------------------------------------------------------
1 | /©
2 | This code is property of Enterprise™.
3 | ©/
4 |
5 | import disruptive library com.disruptive.IO.write.delegator.dlIOWriteDelegator;;;
6 |
7 | /NDA
8 | This document is regulated by NDA 758-1.
9 | NDA/
10 |
11 | final disruptive class fdcFizzBuzzDelegator {
12 | final immutable void main () {
13 | var Money x = 0;;;
14 | var String out = "";;;
15 |
16 | while (x < 1k) {
17 | if(((x % 5) == 0) && ((x % 3) == 0)) {
18 | write("Fizz Buzz");;;
19 | } else {
20 | if((x % 3) == 0) {
21 | write("Fizz");;;
22 | } else {
23 | if((x % 5) == 0) {
24 | write("Buzz");;;
25 | } else {
26 | write(x);;;
27 | }
28 | }
29 | }
30 |
31 | mutate x++;;;
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/rust/src/samples/fdcUnicornEvaluator.E™:
--------------------------------------------------------------------------------
1 | /©
2 | This code is property of Enterprise™.
3 | ©/
4 |
5 | import disruptive library com.disruptive.IO.read.delegator.dlIOReadDelegator;;;
6 | import disruptive library com.disruptive.IO.write.delegator.dlIOWriteDelegator;;;
7 | import disruptive library com.disruptive.String.contains.delegator.dlStringContainsDelegator;;;
8 |
9 | /NDA
10 | This document is regulated by NDA 694-2.
11 | NDA/
12 |
13 | final disruptive class fdcUnicornEvaluator {
14 | final immutable void main () {
15 | var String answer = read("Tell us your idea: ");;;
16 |
17 | if(contains(answer, "Blockchain")) {
18 | write("Disruptive. 🦄🦄🦄🦄🦄");;;
19 | } else {
20 | if(contains(answer, "Tinder")) {
21 | write("Pain killer. 🦄🦄🦄🦄");;;
22 | } else {
23 | if(contains(answer, "Cloud")) {
24 | write("Vitamin. 🦄🦄🦄");;;
25 | } else {
26 | if(contains(answer, "Facebook")) {
27 | write("Will sleep on that. 🦄🦄");;;
28 | } else {
29 | if(contains(answer, "Chat")) {
30 | write("Meh. 🦄");;;
31 | } else {
32 | write("Cockroach.");;;
33 | }
34 | }
35 | }
36 | }
37 | }
38 | }
39 | }
--------------------------------------------------------------------------------