Advertisement
Manhydra

alcohol.c

Jul 15th, 2014
484
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.75 KB | None | 0 0
  1.  
  2. /*
  3.  * The ALCOHOL Programming Language
  4.  * alcohol.c
  5.  *
  6.  * Copyright 2014 Marc Sylvestre <marc.sylvestre@manhydra.com>
  7.  *
  8.  * This program is free software; you can redistribute it and/or modify
  9.  * it under the terms of the GNU General Public License as published by
  10.  * the Free Software Foundation; either version 3 of the License, or
  11.  * (at your option) any later version.
  12.  *
  13.  * This program is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.  * GNU General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU General Public License
  19.  * along with this program; if not, see <http://www.gnu.org/licenses/>,
  20.  * or if prefer good old fashion postal mail, write to the Free Software
  21.  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  22.  * MA 02110-1301, USA.
  23.  */
  24.  
  25. #include <stdio.h>
  26. #include <stdlib.h>
  27. #include <string.h>
  28.  
  29. // Link: http://pastebin.com/DGHAXe5Y
  30. #include "alcohol.h"
  31.  
  32. INTEGER masterValFive;
  33. INTEGER masterValTen;
  34. INTEGER masterValOne;
  35.  
  36. INTEGER getFive
  37.     BEGIN_ARGS
  38.         GENERIC
  39.     END_ARGS
  40. BEGIN_ROUTINE
  41.     RET masterValFive;
  42. END_ROUTINE
  43.  
  44. INTEGER getTen
  45.     BEGIN_ARGS
  46.         GENERIC
  47.     END_ARGS
  48. BEGIN_ROUTINE
  49.     RET masterValTen;
  50. END_ROUTINE
  51.  
  52. INTEGER getOne
  53.     BEGIN_ARGS
  54.         GENERIC
  55.     END_ARGS
  56. BEGIN_ROUTINE
  57.     RET masterValOne;
  58. END_ROUTINE
  59.  
  60. INTEGER getNum
  61.     BEGIN_ARGS
  62.         STRING numState
  63.     END_ARGS
  64. BEGIN_ROUTINE
  65.     TEST(
  66.         (NOT strncmp
  67.         BEGIN_ARGS
  68.             numState, "Five", 4
  69.         END_ARGS
  70.         ))
  71.         RET getFive NO_ARG
  72.         ;
  73.     END_TEST
  74.     TEST((
  75.         NOT strncmp
  76.         BEGIN_ARGS
  77.             numState, "Ten", 3
  78.         END_ARGS
  79.         ))
  80.         RET getFive NO_ARG
  81.         ;
  82.     END_TEST
  83.     TEST((
  84.         NOT strncmp
  85.         BEGIN_ARGS
  86.             numState, "One", 3
  87.         END_ARGS
  88.         ))
  89.         RET getOne NO_ARG
  90.         ;
  91.     END_TEST
  92.     RET 1
  93.     ;
  94. END_ROUTINE
  95.  
  96. INTEGER plusFive
  97.     BEGIN_ARGS
  98.         INTEGER a
  99.     END_ARGS
  100. BEGIN_ROUTINE
  101.     RET a + 5;
  102. END_ROUTINE
  103.  
  104. BEGIN_PROG
  105.     INTEGER var
  106.     ;
  107.     SET(var,0)
  108.     ;
  109.     ITERATE(var IS_LT 100)
  110.         OUTPUT
  111.             BEGIN_ARGS
  112.                 "%d\n",
  113.                 plusFive
  114.                     BEGIN_ARGS
  115.                         var
  116.                     END_ARGS
  117.             END_ARGS
  118.             ;
  119.         SET(
  120.             var,
  121.             plusFive
  122.                 BEGIN_ARGS
  123.                     var
  124.                 END_ARGS
  125.         )
  126.         ;
  127.         TEST(var EQUALS 50)
  128.             OUTPUTL
  129.                 BEGIN_ARGS
  130.                     "We're somewhere in the middle"
  131.                 END_ARGS
  132.                 ;
  133.         END_TEST
  134.         TEST_CASES(var)
  135.             CASE(25)
  136.                 OUTPUTL
  137.                     BEGIN_ARGS
  138.                         "We're a quarter of the way there."
  139.                     END_ARGS
  140.                     ;
  141.             END_CASE
  142.             CASE(75)
  143.                 OUTPUTL
  144.                     BEGIN_ARGS
  145.                         "We're a three-quarter of the way there."
  146.                     END_ARGS
  147.                     ;
  148.             END_CASE
  149.         END_TEST_CASES
  150.     END_ITERATE
  151.  
  152.     OUTPUT
  153.         BEGIN_ARGS
  154.             "%d\n",
  155.             getNum
  156.                 BEGIN_ARGS
  157.                     "Five"
  158.                 END_ARGS
  159.         END_ARGS
  160.         ;
  161. END_PROG
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement