# New Ticket Created by "Bryan C. Warnock" # Please include the string: [perl #22386] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=22386 >
As mentioned previously. Makes IMCC and PASM constant keywords consistent, with '.const'. -- Bryan C. Warnock bwarnock@(gtemail.net|raba.com) -- attachment 1 ------------------------------------------------------ url: http://rt.perl.org/rt2/attach/58433/43430/dc2b5c/const.patch
Index: assemble.pl =================================================================== RCS file: /cvs/public/parrot/assemble.pl,v retrieving revision 1.102 diff -u -d -r1.102 assemble.pl --- assemble.pl 26 May 2003 19:21:54 -0000 1.102 +++ assemble.pl 30 May 2003 23:34:03 -0000 @@ -55,15 +55,15 @@ Constants are new, and the syntax looks like: - .constant PerlHash 6 # Again, . marks the directive + .const PerlHash 6 # Again, . marks the directive new P0, .PerlHash # . marks the special variable for expansion. Several constants are predefined in the Macro class, but are not generated dynamically as they should be, at least not yet. - .constant Array 0 - .constant PerlUndef 1 + .const Array 0 + .const PerlUndef 1 ... This should be generated from include/parrot/pmc.h, but my plans are to add a @@ -203,15 +203,15 @@ Preprocesses constants, macros, include statements, and eventually conditional compilation. - .constant name {register} - .constant name {signed_integer} - .constant name {signed_float} - .constant name {"string constant"} - .constant name {'string constant'} + .const name {register} + .const name {signed_integer} + .const name {signed_float} + .const name {"string constant"} + .const name {'string constant'} are removed from the array. Given the line: - '.constant HelloWorld "Hello, World!"' + '.const HelloWorld "Hello, World!"' one can expand HelloWorld via: @@ -292,19 +292,19 @@ next; } - if(/^\.constant \s+ + if(/^\.const \s+ ($label_re) \s+ - ($reg_re)/xo) { # .constant {name} {register} + ($reg_re)/xo) { # .const {name} {register} $self->{constants}{$1} = $2; } - elsif(/^\.constant \s+ + elsif(/^\.const \s+ ($label_re) \s+ - ($num_re)/xo) { # .constant {name} {number} + ($num_re)/xo) { # .const {name} {number} $self->{constants}{$1} = $2; } - elsif(/^\.constant \s+ + elsif(/^\.const \s+ ($label_re) \s+ - ($str_re)/xo) { # .constant {name} {string} + ($str_re)/xo) { # .const {name} {string} $self->{constants}{$1} = $2; } elsif(/^\.include \s+ Index: languages/BASIC/compiler/RT_builtins.pasm =================================================================== RCS file: /cvs/public/parrot/languages/BASIC/compiler/RT_builtins.pasm,v retrieving revision 1.3 diff -u -d -r1.3 RT_builtins.pasm --- languages/BASIC/compiler/RT_builtins.pasm 22 May 2003 02:54:49 -0000 1.3 +++ languages/BASIC/compiler/RT_builtins.pasm 30 May 2003 23:34:05 -0000 @@ -482,8 +482,8 @@ # ############################################ # RND # I12 has the seed! -.constant RANDMAX 65536 -.constant RANDMAXF 65536.0 +.const RANDMAX 65536 +.const RANDMAXF 65536.0 BUILTIN_RND: bsr ARGCK eq I3, 1, RND_GEN # There are no more args @@ -558,7 +558,7 @@ # ######################################## # SQR # Newton's Method -.constant EPSILON 0.000001 +.const EPSILON 0.000001 BUILTIN_SQR: bsr GETARGS bsr MAKEFLO Index: languages/BASIC/compiler/RT_initialize.pasm =================================================================== RCS file: /cvs/public/parrot/languages/BASIC/compiler/RT_initialize.pasm,v retrieving revision 1.3 diff -u -d -r1.3 RT_initialize.pasm --- languages/BASIC/compiler/RT_initialize.pasm 16 May 2003 16:58:40 -0000 1.3 +++ languages/BASIC/compiler/RT_initialize.pasm 30 May 2003 23:34:05 -0000 @@ -1,4 +1,4 @@ -.constant LINE I11 +.const LINE I11 # Globals of note: # P8, P9 -- Working stacks for Postfix Machine # Index: languages/BASIC/compiler/RT_platform_ANSIscreen.pasm =================================================================== RCS file: /cvs/public/parrot/languages/BASIC/compiler/RT_platform_ANSIscreen.pasm,v retrieving revision 1.3 diff -u -d -r1.3 RT_platform_ANSIscreen.pasm --- languages/BASIC/compiler/RT_platform_ANSIscreen.pasm 13 May 2003 02:13:41 -0000 1.3 +++ languages/BASIC/compiler/RT_platform_ANSIscreen.pasm 30 May 2003 23:34:05 -0000 @@ -1,13 +1,13 @@ # ANSIScreen Specific routines # P24 is ours to use, but I don't really know why we'd need it. -.constant BLACK 0 -.constant RED 1 -.constant GREEN 2 -.constant YELLOW 3 -.constant BLUE 4 -.constant MAGENTA 5 -.constant CYAN 6 -.constant WHITE 7 +.const BLACK 0 +.const RED 1 +.const GREEN 2 +.const YELLOW 3 +.const BLUE 4 +.const MAGENTA 5 +.const CYAN 6 +.const WHITE 7 ANSI_SETUP: new P24, .PerlHash new P0, .PerlArray Index: languages/BASIC/compiler/RT_platform_win32.pasm =================================================================== RCS file: /cvs/public/parrot/languages/BASIC/compiler/RT_platform_win32.pasm,v retrieving revision 1.7 diff -u -d -r1.7 RT_platform_win32.pasm --- languages/BASIC/compiler/RT_platform_win32.pasm 13 May 2003 00:15:04 -0000 1.7 +++ languages/BASIC/compiler/RT_platform_win32.pasm 30 May 2003 23:34:06 -0000 @@ -1,6 +1,6 @@ # Win32 Specific routines -.constant SIZEOF_CONSOLE_SCREEN_BUFFER_INFO 22 -.constant SIZEOF_DWORD 4 +.const SIZEOF_CONSOLE_SCREEN_BUFFER_INFO 22 +.const SIZEOF_DWORD 4 WIN32_SETUP: noop @@ -157,14 +157,14 @@ # 1 = blue 5 = magenta 9 = light blue 13 = light magenta # 2 = green 6 = brown 10 = light green 14 = yellow # 3 = cyan 7 = white 11 = light cyan 15 = bright white -.constant FOREGROUND_BLUE 1 -.constant FOREGROUND_GREEN 2 -.constant FOREGROUND_RED 4 -.constant FOREGROUND_INTENSITY 8 -.constant BACKGROUND_BLUE 16 -.constant BACKGROUND_GREEN 32 -.constant BACKGROUND_RED 64 -.constant BACKGROUND_INTENSITY 128 +.const FOREGROUND_BLUE 1 +.const FOREGROUND_GREEN 2 +.const FOREGROUND_RED 4 +.const FOREGROUND_INTENSITY 8 +.const BACKGROUND_BLUE 16 +.const BACKGROUND_GREEN 32 +.const BACKGROUND_RED 64 +.const BACKGROUND_INTENSITY 128 WIN32_SCREEN_GETFORE: set P1, P24["console"] set I0, P1["attr"] Index: languages/BASIC/interpreter/basicvar.pasm =================================================================== RCS file: /cvs/public/parrot/languages/BASIC/interpreter/basicvar.pasm,v retrieving revision 1.1 diff -u -d -r1.1 basicvar.pasm --- languages/BASIC/interpreter/basicvar.pasm 9 Mar 2003 23:08:58 -0000 1.1 +++ languages/BASIC/interpreter/basicvar.pasm 30 May 2003 23:34:06 -0000 @@ -71,9 +71,9 @@ # Revision 1.2 2002/03/31 05:13:48 Clinton # Id Keywords # -.constant NTYPE 0 -.constant STYPE 1 -.constant CTYPE 2 +.const NTYPE 0 +.const STYPE 1 +.const CTYPE 2 # All of these routines use, misuse and abuse I0, I1, S0, S1, S2 # Should be saved/restored okay though. Index: languages/BASIC/interpreter/expr.pasm =================================================================== RCS file: /cvs/public/parrot/languages/BASIC/interpreter/expr.pasm,v retrieving revision 1.1 diff -u -d -r1.1 expr.pasm --- languages/BASIC/interpreter/expr.pasm 9 Mar 2003 23:08:58 -0000 1.1 +++ languages/BASIC/interpreter/expr.pasm 30 May 2003 23:34:07 -0000 @@ -50,7 +50,7 @@ # # Width of things on the pseudo-stack -.constant FUNCMARK "\x00" +.const FUNCMARK "\x00" # Create an artificial "stack" so that I can shift from one stack to the other. PUSHOPSTACK: pushi @@ -299,8 +299,8 @@ # I24 is the seed. The period is 65536 # and probably isn't fair in the low bits. # -.constant RANDMAX 65536 -.constant RANDMAXF 65536.0 +.const RANDMAX 65536 +.const RANDMAXF 65536.0 FUNC_RND: inc I10 gt I10, 1, ENDISFUNC # Only checking! @@ -690,7 +690,7 @@ # # Bit-O-Magic, | is used to separate tokens on output stream -.constant SEPARATOR "|" +.const SEPARATOR "|" INFIXPOSTFIX: pushi Index: languages/befunge/maths.pasm =================================================================== RCS file: /cvs/public/parrot/languages/befunge/maths.pasm,v retrieving revision 1.2 diff -u -d -r1.2 maths.pasm --- languages/befunge/maths.pasm 24 Nov 2002 21:17:34 -0000 1.2 +++ languages/befunge/maths.pasm 30 May 2003 23:34:07 -0000 @@ -3,7 +3,7 @@ # before: ... max # after: ... rand # 0 <= rand < max -.constant RANDMAX 65536.0 +.const RANDMAX 65536.0 MATHS_RAND: pushi restore I10 Index: languages/cola/gen.c =================================================================== RCS file: /cvs/public/parrot/languages/cola/gen.c,v retrieving revision 1.15 diff -u -d -r1.15 gen.c --- languages/cola/gen.c 10 Dec 2002 08:56:05 -0000 1.15 +++ languages/cola/gen.c 30 May 2003 23:34:08 -0000 @@ -108,7 +108,7 @@ void gen_constant_decl(AST * p) { /* Just to generate the comment */ - printf("#.constant %s = %s\n", p->arg1->sym->name, p->arg1->sym->literal->name); + printf("#.const %s = %s\n", p->arg1->sym->name, p->arg1->sym->literal->name); } void gen_field_decl(AST * p) { Index: languages/forth/forth.pasm =================================================================== RCS file: /cvs/public/parrot/languages/forth/forth.pasm,v retrieving revision 1.1 diff -u -d -r1.1 forth.pasm --- languages/forth/forth.pasm 22 Jun 2002 04:32:55 -0000 1.1 +++ languages/forth/forth.pasm 30 May 2003 23:34:08 -0000 @@ -2,45 +2,45 @@ # Forth interpreter # -.constant STDIN 0 -.constant InterpretPrompt "> " -.constant CompilePrompt ">> " +.const STDIN 0 +.const InterpretPrompt "> " +.const CompilePrompt ">> " -.constant InterpretMode 0 -.constant CompileMode 1 -.constant CommentMode 2 +.const InterpretMode 0 +.const CompileMode 1 +.const CommentMode 2 -.constant Space 32 -.constant Tab 9 +.const Space 32 +.const Tab 9 # # Allocate registers # -.constant CommandLength I0 -.constant WordStart I1 -.constant WordEnd I2 -.constant WordLength I3 -.constant Mode I4 +.const CommandLength I0 +.const WordStart I1 +.const WordEnd I2 +.const WordLength I3 +.const Mode I4 -.constant TempInt I5 -.constant TempInt2 I6 -.constant TempInt3 I7 +.const TempInt I5 +.const TempInt2 I6 +.const TempInt3 I7 -.constant IntStack I31 +.const IntStack I31 # -.constant Commands S0 -.constant CurrentWord S1 -.constant CompileWord S2 -.constant CompileBuffer S3 -.constant TempString S4 +.const Commands S0 +.const CurrentWord S1 +.const CompileWord S2 +.const CompileBuffer S3 +.const TempString S4 # -.constant CoreOps P0 -.constant UserOps P1 +.const CoreOps P0 +.const UserOps P1 # Index: languages/imcc/imcc.l =================================================================== RCS file: /cvs/public/parrot/languages/imcc/imcc.l,v retrieving revision 1.34 diff -u -d -r1.34 imcc.l --- languages/imcc/imcc.l 19 May 2003 12:23:48 -0000 1.34 +++ languages/imcc/imcc.l 30 May 2003 23:34:09 -0000 @@ -187,7 +187,7 @@ fataly (EX_SOFTWARE, "", line, "Macros only allowed in assembly mode"); } -<emit>".constant" { +<emit>".const" { int c; char *name; struct macro_t *m; @@ -195,7 +195,7 @@ BEGIN(macro); c = yylex_skip(valp, interp, " "); if (c != IDENTIFIER) - fataly(EX_SOFTWARE, ".constant", line, + fataly(EX_SOFTWARE, ".const", line, "Constant names must be identifiers"); name = str_dup(valp->s); Index: languages/imcc/imclexer.c =================================================================== RCS file: /cvs/public/parrot/languages/imcc/imclexer.c,v retrieving revision 1.33 diff -u -d -r1.33 imclexer.c --- languages/imcc/imclexer.c 19 May 2003 12:24:07 -0000 1.33 +++ languages/imcc/imclexer.c 30 May 2003 23:34:11 -0000 @@ -1234,7 +1234,7 @@ BEGIN(macro); c = yylex_skip(valp, interp, " "); if (c != IDENTIFIER) - fataly(EX_SOFTWARE, ".constant", line, + fataly(EX_SOFTWARE, ".const", line, "Constant names must be identifiers"); name = str_dup(valp->s); Index: languages/imcc/docs/macros.pod =================================================================== RCS file: /cvs/public/parrot/languages/imcc/docs/macros.pod,v retrieving revision 1.2 diff -u -d -r1.2 macros.pod --- languages/imcc/docs/macros.pod 4 Mar 2003 15:58:24 -0000 1.2 +++ languages/imcc/docs/macros.pod 30 May 2003 23:34:11 -0000 @@ -47,14 +47,14 @@ Constants are new, and the syntax looks like: - .constant PerlHash 6 # Again, . marks the directive + .const PerlHash 6 # Again, . marks the directive new P0, .PerlHash # . marks the special variable for expansion. Several constants are predefined, namely the PMC-Classes. - .constant Array 0 - .constant PerlUndef 1 + .const Array 0 + .const PerlUndef 1 ... The ".include" statement is followed by a string literal. The file of @@ -64,17 +64,17 @@ Constant definitions have the form - .constant name {register} - .constant name {signed_integer} - .constant name {signed_float} - .constant name {"string constant"} - .constant name {'string constant'} + .const name {register} + .const name {signed_integer} + .const name {signed_float} + .const name {"string constant"} + .const name {'string constant'} They don't generate any code, but create a new macro directive .name Given the line: - '.constant HelloWorld "Hello, World!"' + '.const HelloWorld "Hello, World!"' one can expand HelloWorld via: Index: t/op/macro.t =================================================================== RCS file: /cvs/public/parrot/t/op/macro.t,v retrieving revision 1.11 diff -u -d -r1.11 macro.t --- t/op/macro.t 18 Oct 2002 21:19:52 -0000 1.11 +++ t/op/macro.t 30 May 2003 23:34:12 -0000 @@ -120,26 +120,26 @@ OUTPUT output_is(<<'CODE', '32', "constant defined and used"); -.constant FOO 32 +.const FOO 32 print .FOO end CODE output_is(<<'CODE', 'foo', "constant defined and used"); -.constant FOO "foo" +.const FOO "foo" print .FOO end CODE output_is(<<'CODE', 'foo', "constant defined and used"); -.constant FOO S0 +.const FOO S0 set .FOO,"foo" print .FOO end CODE output_is(<<'CODE', 'foo', "constant defined, used in a macro call"); -.constant FOO S0 +.const FOO S0 .macro answer (bar) print .bar .endm