| |
| /pliant/language/basic/shortcut.pli |
| |
| 1 |
# Copyright Hubert Tonneau hubert.tonneau@pliant.cx | |
| 2 |
# | |
| 3 |
# This program is free software; you can redistribute it and/or | |
| 4 |
# modify it under the terms of the GNU General Public License version 2 | |
| 5 |
# as published by the Free Software Foundation. | |
| 6 |
# | |
| 7 |
# This program is distributed in the hope that it will be useful, | |
| 8 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 9 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 10 |
# GNU General Public License for more details. | |
| 11 |
# | |
| 12 |
# You should have received a copy of the GNU General Public License | |
| 13 |
# version 2 along with this program; if not, write to the Free Software | |
| 14 |
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
| 15 |
| |
| 16 |
abstract | |
| 17 |
[This will record += -= *= \= %= ^= and /= operators that will be expanded just like a macro would be with a classical compiler] | |
| 18 |
| |
| 19 |
scope "/pliant/language/" "/pliant/install/" | |
| 20 |
module "/pliant/install/ring2.pli" | |
| 21 |
| |
| 22 |
| |
| 23 |
function shortcut e op | |
| 24 |
arg_rw Expression e ; arg Str op | |
| 25 |
if e:size<>2 | |
| 26 |
return | |
| 27 |
# e compile_as (expression duplicate e ident ":=" subexpressions (duplicate e:0) (expression duplicate e ident op subexpressions e:0 e:1)) | |
| 28 |
e compile_as (expression ident ":=" subexpressions (duplicate e:0) (expression ident op subexpressions e:0 e:1)) | |
| 29 |
| |
| 30 |
function shortcut op | |
| 31 |
arg Str op | |
| 32 |
runtime_compile id (cast op+"=" Ident) op op | |
| 33 |
meta id e | |
| 34 |
shortcut e op | |
| 35 |
operator id 510h 1000000000 1000000000 | |
| 36 |
export id | |
| 37 |
| |
| 38 |
shortcut "+" | |
| 39 |
shortcut "-" | |
| 40 |
shortcut "*" | |
| 41 |
shortcut "\" | |
| 42 |
shortcut "%" | |
| 43 |
shortcut "^" | |
| 44 |
shortcut "/" | |
| |