Author: fperrad
Date: Fri Mar 28 01:31:35 2008
New Revision: 26587

Added:
   trunk/languages/lua/src/grammar51.pir
      - copied, changed from r26579, /trunk/languages/lua/src/lua51.pir
Modified:
   trunk/MANIFEST
   trunk/languages/lua/config/makefiles/root.in
   trunk/languages/lua/src/dumplex.tg
   trunk/languages/lua/src/lua51.pir
   trunk/languages/lua/test_lex.pir

Log:
[Lua] PAST-pm deprecation
- test_lex uses PCT/PAST

Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST      (original)
+++ trunk/MANIFEST      Fri Mar 28 01:31:35 2008
@@ -1,7 +1,7 @@
 # ex: set ro:
 # $Id$
 #
-# generated by tools/dev/mk_manifest_and_skip.pl Thu Mar 27 10:44:52 2008 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Thu Mar 27 19:58:55 2008 UT
 #
 # See tools/dev/install_files.pl for documentation on the
 # format of this file.
@@ -1587,6 +1587,7 @@
 languages/lua/src/POST.pir                                  [lua]
 languages/lua/src/POSTGrammar.tg                            [lua]
 languages/lua/src/dumplex.tg                                [lua]
+languages/lua/src/grammar51.pir                             [lua]
 languages/lua/src/lua51.pg                                  [lua]
 languages/lua/src/lua51.pir                                 [lua]
 languages/lua/src/lua51_testlex.pg                          [lua]

Modified: trunk/languages/lua/config/makefiles/root.in
==============================================================================
--- trunk/languages/lua/config/makefiles/root.in        (original)
+++ trunk/languages/lua/config/makefiles/root.in        Fri Mar 28 01:31:35 2008
@@ -116,7 +116,7 @@
 src/POSTGrammar_gen.pir: src/POSTGrammar.tg
        $(TGE) --output=src/POSTGrammar_gen.pir src/POSTGrammar.tg
 
-lua.pbc: lua.pir src/lua51.pir src/lua51_gen.pir src/PASTGrammar_gen.pir 
src/POSTGrammar_gen.pir src/POST.pir $(LIB_SRCS)
+lua.pbc: lua.pir src/lua51.pir src/grammar51.pir src/lua51_gen.pir 
src/PASTGrammar_gen.pir src/POSTGrammar_gen.pir src/POST.pir $(LIB_SRCS)
        $(PARROT) -o lua.pbc --output-pbc lua.pir
 
 [EMAIL PROTECTED]@: lua.pbc

Modified: trunk/languages/lua/src/dumplex.tg
==============================================================================
--- trunk/languages/lua/src/dumplex.tg  (original)
+++ trunk/languages/lua/src/dumplex.tg  Fri Mar 28 01:31:35 2008
@@ -1,4 +1,4 @@
-# Copyright (C) 2006-2007, The Perl Foundation.
+# Copyright (C) 2006-2008, The Perl Foundation.
 # $Id$
 
 =head1 NAME
@@ -26,8 +26,8 @@
 
 transform past (ROOT) :language('PIR') {
     .local pmc past
-    new past, 'PAST::Stmts'
-    past.'init'('node'=>node)
+    $P0 = get_hll_global ['PAST'], 'Stmts'
+    past = $P0.'new'('node'=>node)
     $P0 = node['token']
     if null $P0 goto L1
     .local pmc iter
@@ -39,7 +39,8 @@
     past.'push'($P1)
     goto L2
   L1:
-    .return past.'new'('PAST::Block', past, 'node'=>node, 'name'=>'anon')
+    $P0 = get_hll_global ['PAST'], 'Block'
+    .return $P0.'new'(past, 'node'=>node, 'name'=>'anon')
 }
 
 
@@ -53,7 +54,8 @@
     $P0 = node[$S0]
     $S1 = concat 'Lua::TestLex::', $S0
     past = tree.'get'('past', $P0, $S1)
-    .return past.'new'('PAST::Op', past, 'node'=>node, 'name'=>'println')
+    $P0 = get_hll_global ['PAST'], 'Op'
+    .return $P0.'new'(past, 'node'=>node, 'name'=>'println', 
'pasttype'=>'call')
 }
 
 
@@ -62,11 +64,10 @@
 =cut
 
 transform past (Lua::TestLex::keyword) :language('PIR') {
-    .local pmc past
-    new past, 'PAST::Val'
     $S0 = node.'result_object'()
     $S1 = concat "keyword:\t", $S0
-    .return past.'init'('node'=>node, 'vtype'=>'"String"', 'name'=>$S1, 
'ctype'=>'s~')
+    $P0 = get_hll_global ['PAST'], 'Val'
+    .return $P0.'new'('node'=>node, 'value'=>$S1)
 }
 
 
@@ -75,11 +76,10 @@
 =cut
 
 transform past (Lua::TestLex::punctuator) :language('PIR') {
-    .local pmc past
-    new past, 'PAST::Val'
     $S0 = node.'result_object'()
     $S1 = concat "punct:\t", $S0
-    .return past.'init'('node'=>node, 'vtype'=>'"String"', 'name'=>$S1, 
'ctype'=>'s~')
+    $P0 = get_hll_global ['PAST'], 'Val'
+    .return $P0.'new'('node'=>node, 'value'=>$S1)
 }
 
 
@@ -88,11 +88,10 @@
 =cut
 
 transform past (Lua::TestLex::Name) :language('PIR') {
-    .local pmc past
-    new past, 'PAST::Val'
     $S0 = node.'result_object'()
     $S1 = concat "Name:\t", $S0
-    .return past.'init'('node'=>node, 'vtype'=>'"String"', 'name'=>$S1, 
'ctype'=>'s~')
+    $P0 = get_hll_global ['PAST'], 'Val'
+    .return $P0.'new'('node'=>node, 'value'=>$S1)
 }
 
 
@@ -101,8 +100,6 @@
 =cut
 
 transform past (Lua::TestLex::String) :language('PIR') {
-    .local pmc past
-    new past, 'PAST::Val'
     $I0 = defined node['quoted_literal']
     unless $I0 goto L1
     $P0 = node['quoted_literal']
@@ -119,7 +116,8 @@
   L2:
     internal_error('unknown string')
   L9:
-    .return past.'init'('node'=>node, 'vtype'=>'"String"', 'name'=>$S1, 
'ctype'=>'s~')
+    $P0 = get_hll_global ['PAST'], 'Val'
+    .return $P0.'new'('node'=>node, 'value'=>$S1)
 }
 
 
@@ -128,11 +126,10 @@
 =cut
 
 transform past (Lua::TestLex::Number) :language('PIR') {
-    .local pmc past
-    new past, 'PAST::Val'
     $S0 = node.'result_object'()
     $S1 = concat "Number:\t", $S0
-    .return past.'init'('node'=>node, 'vtype'=>'"String"', 'name'=>$S1, 
'ctype'=>'s~')
+    $P0 = get_hll_global ['PAST'], 'Val'
+    .return $P0.'new'('node'=>node, 'value'=>$S1)
 }
 
 =back

Copied: trunk/languages/lua/src/grammar51.pir (from r26579, 
/trunk/languages/lua/src/lua51.pir)
==============================================================================
--- /trunk/languages/lua/src/lua51.pir  (original)
+++ trunk/languages/lua/src/grammar51.pir       Fri Mar 28 01:31:35 2008
@@ -3,102 +3,14 @@
 
 =head1 NAME
 
-src/lua51.pir -- The compiler for Lua 5.1
+src/grammar51.pir -- elements of grammar for Lua 5.1
 
 =head1 DESCRIPTION
 
-This compiler extends C<PCT::HLLCompiler>
-(see F<compilers/pct/src/PCT/HLLCompiler.pir>)
-
-This compiler defines the following stages:
-
-=over 4
-
-=item * parse F<languages/lua/src/lua51.pg>
-
-=item * PAST  F<languages/lua/src/PASTGrammar.tg>
-
-=item * POST  F<languages/lua/src/POSTGrammar.tg>
-
-=back
-
-Used by F<languages/lua/lua.pir>.
+Used by F<languages/lua/lua.pir> and F<languages/lua/test_lex.pir>.
 
 =cut
 
-.namespace [ 'Lua' ]
-
-.sub '__onload' :anon :load :init
-    load_bytecode 'PCT.pbc'
-    load_bytecode 'PGE/Text.pbc'
-
-    $P0 = subclass 'PCT::HLLCompiler', 'Lua::Compiler'
-    addattribute $P0, '$ostgrammar'
-    new $P0, 'Lua::Compiler'
-    $P0.'language'('Lua')
-    $P0.'parsegrammar'('Lua::Grammar')
-    $P0.'astgrammar'('Lua::PAST::Grammar')
-    $P0.'ostgrammar'('Lua::POST::Grammar')
-
-    $P0.'commandline_prompt'('> ')
-.end
-
-
-.namespace [ 'Lua::Compiler' ]
-
-=head3 Overloaded methods
-
-=over 4
-
-=item C<ostgrammar([string grammar])>
-
-Accessor for the 'ostgrammar' attribute.
-
-=cut
-
-.sub 'ostgrammar' :method
-    .param string value        :optional
-    .param int has_value       :opt_flag
-    .return self.'attr'('$ostgrammar', value, has_value)
-.end
-
-
-=item C<post(source [, adverbs :slurpy :named])>
-
-Transform C<source> using the compiler's C<ostgrammar>
-according to any options given by C<adverbs>, and return the
-resulting ost.
-
-=back
-
-=cut
-
-.sub 'post' :method
-    .param pmc source
-    .param pmc adverbs         :slurpy :named
-    .local string ostgrammar_name
-    .local pmc ostgrammar, ostbuilder
-    ostgrammar_name = self.'ostgrammar'()
-    unless ostgrammar_name goto default_ostgrammar
-    ostgrammar = new ostgrammar_name
-    ostbuilder = ostgrammar.'apply'(source)
-    .return ostbuilder.'get'('post')
-
-  default_ostgrammar:
-    $P0 = compreg 'PAST'
-    .return $P0.'compile'(source, adverbs :flat :named)
-.end
-
-
-.sub 'pir' :method
-    .param pmc source
-    .param pmc adverbs         :slurpy :named
-    $P0 = compreg 'POST'
-    $P1 = $P0.'compile'(source, adverbs :flat :named)
-    .return ($P1)
-.end
-
-
 .namespace [ 'Lua::Grammar' ]
 
 =head2 Functions
@@ -702,101 +614,10 @@
 .end
 
 
-.namespace [ 'Lua::PAST::Grammar' ]
-
-=item C<internal_error>
-
-used in F<languages/lua/src/PASTGrammar.tg>
-
-=cut
-
-.sub internal_error
-    .param string msg
-    $S0 = "ERROR_INTERNAL (PAST): " . msg
-    $S0 .= "\n"
-    printerr $S0
-    exit 1
-.end
-
-
-.namespace [ 'Lua::POST::Grammar' ]
-
-=item C<internal_error>
-
-used in F<languages/lua/src/POSTGrammar.tg>
-
-=cut
-
-.sub internal_error
-    .param string msg
-    $S0 = "ERROR_INTERNAL (POST): " . msg
-    $S0 .= "\n"
-    printerr $S0
-    exit 1
-.end
-
-
-.namespace [ 'Lua::Symbtab' ]
-
-.sub '__onload' :anon :load :init
-    $P0 = subclass 'ResizablePMCArray', 'Lua::Symbtab'
-    new $P0, 'Integer'
-    set $P0, 0
-    set_global '$nb', $P0
-.end
-
-.sub 'insert' :method
-    .param string name
-    $P0 = self[0]
-    $I0 = exists $P0[name]
-    if $I0 goto L1
-    $S0 = name . '_'
-    $P1 = get_global '$nb'
-    $S1 = $P1
-    $S0 .= $S1
-    $P0[name] = $S0
-  L1:
-    $S0 = $P0[name]
-    .return ($S0)
-.end
-
-.sub 'lookup' :method
-    .param string name
-    .local pmc iter
-    new iter, 'Iterator', self
-  L1:
-    unless iter goto L2
-    $P0 = shift iter
-    $I0 = exists $P0[name]
-    unless $I0 goto L1
-    $S0 = $P0[name]
-    .return (1, $S0)
-  L2:
-    .return (0)
-.end
-
-.sub 'push_scope' :method
-    new $P0, 'Hash'
-    unshift self, $P0
-    $P1 = get_global '$nb'
-    inc $P1
-.end
-
-.sub 'pop_scope' :method
-    $P0 = shift self
-.end
-
-.include 'languages/lua/src/lua51_gen.pir'
-.include 'languages/lua/src/PASTGrammar_gen.pir'
-.include 'languages/lua/src/POSTGrammar_gen.pir'
-.include 'languages/lua/src/POST.pir'
-
 =back
 
 =head1 AUTHORS
 
-Klaas-Jan Stol <[EMAIL PROTECTED]>
-
 Francois Perrad
 
 =cut

Modified: trunk/languages/lua/src/lua51.pir
==============================================================================
--- trunk/languages/lua/src/lua51.pir   (original)
+++ trunk/languages/lua/src/lua51.pir   Fri Mar 28 01:31:35 2008
@@ -99,609 +99,6 @@
 .end
 
 
-.namespace [ 'Lua::Grammar' ]
-
-=head2 Functions
-
-Some grammar routines are handly written in PIR.
-
-See "Lua 5.1 Reference Manual", section 2.1 "Lexical Conventions",
-L<http://www.lua.org/manual/5.1/manual.html#2.1>.
-
-=over 4
-
-=item C<syntaxerror (match, [message])>
-
-=cut
-
-.sub 'syntaxerror' :method
-    .param string message :optional
-    .param pmc adv :slurpy :named
-    unless null message goto L1
-    message = 'syntax error'
-  L1:
-    lexerror(self, message)
-.end
-
-
-.sub 'lexerror' :anon
-    .param pmc mob
-    .param string message
-    .local int lineno
-#    .local pmc infile
-#    infile = get_hll_global ['TGE::Compiler'], '$!infile'
-#    $S0 = infile
-#    $S0 .= ':'
-    $S0 = '_._:'
-    $P0 = get_hll_global ['PGE::Util'], 'line_number'
-    lineno = mob.$P0()
-    inc lineno
-    $S1 = lineno
-    $S0 .= $S1
-    $S0 .= ': '
-    $S0 .= message
-    $S1 = mob.'text'()
-    if $S1 == '' goto L1
-    $S0 .= " near '"
-    $S0 .= $S1
-    $S0 .= "'"
-  L1:
-    die $S0
-.end
-
-
-=item C<name>
-
-I<Names> (also called I<identifiers>) in Lua can be any string of letters,
-digits, and underscores, not beginning with a digit. This coincides with the
-definition of names in most languages. (The definition of letter depends on
-the current locale: any character considered alphabetic by the current locale
-can be used in an identifier.) Identifiers are used to name variables and
-table fields.
-
-The following keywords are reserved and cannot be used as names:
-
-     and       break     do        else      elseif
-     end       false     for       function  if
-     in        local     nil       not       or
-     repeat    return    then      true      until     while
-
-Lua is a case-sensitive language: C<and> is a reserved word, but C<And> and
-C<AND> are two different, valid names. As a convention, names starting with
-an underscore followed by uppercase letters (such as C<_VERSION>) are reserved
-for internal global variables used by Lua.
-
-=cut
-
-.include 'cclass.pasm'
-
-.sub 'Name'
-    .param pmc tgt
-    .param pmc adverbs         :slurpy :named
-    .local string target
-    .local int pos, lastpos
-    .local pmc mob
-
-    $P0 = get_hll_global ['PGE'], 'Match'
-    (mob, pos, target) = $P0.'new'(tgt)
-
-    lastpos = length target
-    $S0 = substr target, pos, 1
-    if $S0 == '_' goto L1
-    $I0 = is_cclass .CCLASS_ALPHABETIC, target, pos
-    if $I0 == 0 goto L2
-  L1:
-    $I0 = pos
-    pos = find_not_cclass .CCLASS_WORD, target, pos, lastpos
-    $I1 = pos - $I0
-    $S0 = substr target, $I0, $I1
-    .local pmc kw
-    kw = get_global 'keyword'
-    unless null kw goto L3
-    kw = _const_keyword()
-    set_global 'keyword', kw
-  L3:
-    $I0 = exists kw[$S0]
-    if $I0 goto L2
-    mob.'to'(pos)
-  L2:
-    .return (mob)
-.end
-
-.sub _const_keyword :anon
-    .local pmc kw
-    new kw, 'Hash'
-    kw['and'] = 1
-    kw['break'] = 1
-    kw['do'] = 1
-    kw['else'] = 1
-    kw['elseif'] = 1
-    kw['end'] = 1
-    kw['false'] = 1
-    kw['for'] = 1
-    kw['function'] = 1
-    kw['if'] = 1
-    kw['in'] = 1
-    kw['local'] = 1
-    kw['nil'] = 1
-    kw['not'] = 1
-    kw['or'] = 1
-    kw['repeat'] = 1
-    kw['return'] = 1
-    kw['then'] = 1
-    kw['true'] = 1
-    kw['until'] = 1
-    kw['while'] = 1
-    .return (kw)
-.end
-
-
-=item C<number>
-
-A I<numerical constant> may be written with an optional decimal part and an
-optional decimal exponent. Lua also accepts integer hexadecimal constants,
-by prefixing them with C<0x>. Examples of valid numerical constants are
-
-     3   3.0   3.1416   314.16e-2   0.31416E1   0xff   0x56
-
-=cut
-
-.sub 'number'
-    .param pmc mob
-    .param pmc params :slurpy
-
-    mob = read_numeral(mob)
-    unless mob goto L1
-
-    .local string target
-    .local int pos, lastpos
-
-    target = mob.'text'()
-    lastpos = length target
-  L_alt1:     #   0 [Xx] <xdigit>+
-    pos = 0
-    $S0 = substr target, pos, 1
-    unless $S0 == '0' goto L_alt2
-    inc pos
-    $S0 = substr target, pos, 1
-    $I0 = index 'Xx', $S0
-    if $I0 < 0 goto L_alt2
-    inc pos
-    $I0 = is_cclass .CCLASS_HEXADECIMAL, target, pos
-    if $I0 == 0 goto L_alt2
-    pos = find_not_cclass .CCLASS_HEXADECIMAL, target, pos, lastpos
-    goto L_end
-  L_alt2:     #   <digit>+ [\.]?
-    pos = 0
-    $I0 = is_cclass .CCLASS_NUMERIC, target, pos
-    if $I0 == 0 goto L_alt3
-    pos = find_not_cclass .CCLASS_NUMERIC, target, pos, lastpos
-    $S0 = substr target, pos, 1
-    unless $S0 == '.' goto L_opt2
-    inc pos
-    goto L_opt1
-  L_alt3:     #   \. <digit>
-    pos = 0
-    $S0 = substr target, pos, 1
-    unless $S0 == '.' goto L_end
-    inc pos
-    $I0 = is_cclass .CCLASS_NUMERIC, target, pos
-    if $I0 == 0 goto L_end
-  L_opt1:     #   <digit>*
-    pos = find_not_cclass .CCLASS_NUMERIC, target, pos, lastpos
-  L_opt2:     #   [Ee] [+\-]? <digit>+
-    .local int pos2
-    pos2 = pos
-    $S0 = substr target, pos2, 1
-    $I0 = index 'Ee', $S0
-    if $I0 < 0 goto L_end
-    inc pos2
-    $S0 = substr target, pos2, 1
-    $I0 = index '+-', $S0
-    if $I0 < 0 goto L_opt3
-    inc pos2
-  L_opt3:
-    $I0 = is_cclass .CCLASS_NUMERIC, target, pos2
-    if $I0 == 0 goto L_end
-    pos = find_not_cclass .CCLASS_NUMERIC, target, pos2, lastpos
-  L_end:
-    if pos == lastpos goto L1
-    lexerror(mob, 'malformed number')
-  L1:
-    .return (mob)
-.end
-
-
-.sub 'read_numeral' :anon
-    .param pmc tgt
-    .param pmc adverbs         :slurpy :named
-    .local string target
-    .local int pos, lastpos
-    .local pmc mob
-
-    $P0 = get_hll_global ['PGE'], 'Match'
-    (mob, pos, target) = $P0.'new'(tgt)
-
-    lastpos = length target
-    $S0 = substr target, pos, 1
-    unless $S0 == '.' goto L1
-    inc pos
-  L1:
-    $I0 = is_cclass .CCLASS_NUMERIC, target, pos
-    if $I0 == 0 goto L2
-    inc pos
-  L3:
-    $I0 = is_cclass .CCLASS_NUMERIC, target, pos
-    if $I0 == 0 goto L4
-    pos = find_not_cclass .CCLASS_NUMERIC, target, pos, lastpos
-    $S0 = substr target, pos, 1
-    unless $S0 == '.' goto L5
-    inc pos
-    goto L3
-  L4:
-    $S0 = substr target, pos, 1
-    unless $S0 == '.' goto L5
-    inc pos
-    goto L3
-  L5:
-    $S0 = substr target, pos, 1
-    $I0 = index 'Ee', $S0
-    if $I0 < 0 goto L6
-    inc pos
-    $S0 = substr target, pos, 1
-    $I0 = index '+-', $S0
-    if $I0 < 0 goto L6
-    inc pos
-  L6:
-    $I0 = .CCLASS_NUMERIC | .CCLASS_WORD
-    pos = find_not_cclass $I0, target, pos, lastpos
-    mob.'to'(pos)
-  L2:
-    .return (mob)
-.end
-
-
-=item C<quoted_literal>
-
-I<Literal strings> can be delimited by matching single or double quotes,
-and can contain the following C-like escape sequences: C<'\a'> (bell),
-C<'\b'> (backspace), C<'\f'> (form feed), C<'\n'> (newline), C<'\r'>
-(carriage return), C<'\t'> (horizontal tab), C<'\v'> (vertical tab),
-C<'\\'> (backslash), C<'\"'> (quotation mark [double quote]),
-and C<'\''> (apostrophe [single quote]). Moreover, a backslash followed by
-a real newline results in a newline in the string. A character in a string
-may also be specified by its numerical value using the escape sequence C<\ddd>,
-where I<ddd> is a sequence of up to three decimal digits. (Note that if a
-numerical escape is to be followed by a digit, it must be expressed using
-exactly three digits.) Strings in Lua may contain any 8-bit value, including
-embedded zeros, which can be specified as C<'\0'>.
-
-To put a double (single) quote, a newline, a backslash, or an embedded zero
-inside a literal string enclosed by double (single) quotes you must use an
-escape sequence. Any other character may be directly inserted into the literal.
-(Some control characters may cause problems for the file system, but Lua has
-no problem with them.)
-
-=cut
-
-.sub 'quoted_literal'
-    .param pmc tgt
-    .param string delim
-    .param pmc adv :slurpy :named
-
-    .local string target
-    .local int pos, lastpos
-    .local pmc mob
-
-    $P0 = get_hll_global ['PGE'], 'Match'
-    (mob, pos, target) = $P0.'new'(tgt)
-    lastpos = length target
-
-    .local string literal
-    literal = ''
-  LOOP:
-    if pos < lastpos goto L1
-    mob.'to'(pos)
-    lexerror(mob, "unfinished string")
-  L1:
-    $S0 = substr target, pos, 1
-    if $S0 != delim goto L2
-    mob.'result_object'(literal)
-    mob.'to'(pos)
-    .return (mob)
-  L2:
-    $I0 = index "\n\r", $S0
-    if $I0 < 0 goto L3
-    mob.'to'(pos)
-    lexerror(mob, "unfinished string")
-  L3:
-    if $S0 != "\\" goto CONCAT
-    inc pos
-    if pos == lastpos goto LOOP # error
-    $S0 = substr target, pos, 1
-    $I0 = index 'abfnrtv', $S0
-    if $I0 < 0 goto L4
-    $S0 = substr "\a\b\f\n\r\t\x0b", $I0, 1
-    goto CONCAT
-  L4:
-    $I0 = index "\n\r", $S0
-    if $I0 < 0 goto L5
-    $S0 = "\n"
-    goto CONCAT
-  L5:
-    $I0 = index '0123456789', $S0
-    if $I0 < 0 goto CONCAT
-    inc pos
-    $S0 = substr target, pos, 1
-    $I1 = index '0123456789', $S0
-    if $I1 < 0 goto L6
-    $I0 *= 10
-    $I0 += $I1
-    inc pos
-    $S0 = substr target, pos, 1
-    $I1 = index '0123456789', $S0
-    if $I1 < 0 goto L6
-    $I0 *= 10
-    $I0 += $I1
-    goto L7
-  L6:
-    dec pos
-  L7:
-    if $I0 < 256 goto L8
-    mob.'to'(pos)
-    lexerror(mob, "escape sequence too large")
-  L8:
-    $S0 = chr $I0
-
-  CONCAT:
-    concat literal, $S0
-    inc pos
-    goto LOOP
-.end
-
-
-=item C<long_string>
-
-Literal strings can also be defined using a long format enclosed by
-I<long brackets>. We define an I<opening long bracket of level n> as an
-opening square bracket followed by I<n> equal signs followed by another
-opening square bracket. So, an opening long bracket of level 0 is written
-as C<[[>, an opening long bracket of level 1 is written as C<[=[>, and so on.
-A I<closing long bracket> is defined similarly; for instance, a closing long
-bracket of level 4 is written as C<]====]>. A long string starts with an
-opening long bracket of any level and ends at the first closing long bracket
-of the same level. Literals in this bracketed form may run for several lines,
-do not interpret any escape sequences, and ignore long brackets of any other
-level. They may contain anything except a closing bracket of the proper level.
-
-For convenience, when the opening long bracket is immediately followed by
-a newline, the newline is not included in the string. As an example, in
-a system using ASCII (in which C<'a'> is coded as 97, newline is coded as 10,
-and C<'1'> is coded as 49), the five literals below denote the same string:
-
-     a = 'alo\n123"'
-     a = "alo\n123\""
-     a = '\97lo\10\04923"'
-     a = [[alo
-     123"]]
-     a = [==[
-     alo
-     123"]==]
-
-=cut
-
-.sub 'long_string'
-    .param pmc tgt
-    .param pmc adv :slurpy :named
-
-    .local string target
-    .local int pos, lastpos
-    .local pmc mob
-
-    $P0 = get_hll_global ['PGE'], 'Match'
-    (mob, pos, target) = $P0.'new'(tgt)
-    lastpos = length target
-
-    .local int sep
-    sep = 0
-    $S0 = substr target, pos, 1
-    if $S0 != '[' goto END
-    inc pos
-    (pos, sep) = _skip_sep(target, pos, '[')
-    if sep >= 0 goto L1
-    if sep == -1 goto END
-    mob.'to'(pos)
-    lexerror(mob, "invalid long string delimiter")
-  L1:
-    inc pos
-    $S0 = substr target, pos, 1
-    $I0 = index "\n\r", $S0
-    if $I0 < 0 goto L2
-    inc pos
-  L2:
-
-    .local string literal
-    literal = ''
-  LOOP:
-    if pos < lastpos goto L3
-    lexerror(mob, "unfinished long string")
-  L3:
-    $S0 = substr target, pos, 1
-    if $S0 != '[' goto L4
-    inc pos
-    $S0 = substr target, pos, 1
-    if $S0 != '[' goto L5
-    inc pos
-    mob.'to'(pos)
-    lexerror(mob, "nesting of [[...]] is deprecated")
-  L5:
-    dec pos
-    goto CONCAT
-  L4:
-    if $S0 != ']' goto L6
-    inc pos
-    ($I0, $I1) = _skip_sep(target, pos, ']')
-    if $I1 != sep goto L7
-    pos = $I0 + 1
-    mob.'result_object'(literal)
-    mob.'to'(pos)
-    goto END
-  L7:
-    dec pos
-    goto CONCAT
-  L6:
-    $I0 = index "\n\r", $S0
-    if $I0 < 0 goto L8
-    $S0 = "\n"
-    goto CONCAT
-  L8:
-
-  CONCAT:
-    concat literal, $S0
-    inc pos
-    goto LOOP
-
-  END:
-    .return (mob)
-.end
-
-
-=item C<long_comment>
-
-A I<comment> starts with a double hyphen (C<-->) anywhere outside a string.
-If the text immediately after C<--> is not an opening long bracket,
-the comment is a I<short comment>, which runs until the end of the line.
-Otherwise, it is a I<long comment>, which runs until the corresponding closing
-long bracket. Long comments are frequently used to disable code temporarily.
-
-=cut
-
-.sub 'long_comment'
-    .param pmc tgt
-    .param pmc adv :slurpy :named
-
-    .local string target
-    .local int pos, lastpos
-    .local pmc mob
-
-    $P0 = get_hll_global ['PGE'], 'Match'
-    (mob, pos, target) = $P0.'new'(tgt)
-    lastpos = length target
-
-    .local int sep
-    sep = 0
-    $S0 = substr target, pos, 1
-    if $S0 != '[' goto END
-    inc pos
-    (pos, sep) = _skip_sep(target, pos, '[')
-    if sep < 0 goto END
-    inc pos
-#    $S0 = substr target, pos, 1
-#    $I0 = index "\n\r", $S0
-#    if $I0 < 0 goto L2
-#    inc pos
-#  L2:
-
-#    .local string literal
-#    literal = ''
-  LOOP:
-    if pos < lastpos goto L3
-    lexerror(mob, "unfinished long comment")
-  L3:
-    $S0 = substr target, pos, 1
-    if $S0 != '[' goto L4
-    inc pos
-    $S0 = substr target, pos, 1
-    if $S0 != '[' goto L5
-    inc pos
-    mob.'to'(pos)
-    lexerror(mob, "nesting of [[...]] is deprecated")
-  L5:
-    dec pos
-    goto CONCAT
-  L4:
-    if $S0 != ']' goto L6
-    inc pos
-    ($I0, $I1) = _skip_sep(target, pos, ']')
-    if $I1 != sep goto L7
-    pos = $I0 + 1
-#    mob.'result_object'(literal)
-    mob.'to'(pos)
-    goto END
-  L7:
-    dec pos
-    goto CONCAT
-  L6:
-    $I0 = index "\n\r", $S0
-    if $I0 < 0 goto L8
-#    $S0 = "\n"
-    goto CONCAT
-  L8:
-
-  CONCAT:
-#    concat literal, $S0
-    inc pos
-    goto LOOP
-
-  END:
-    .return (mob)
-.end
-
-.sub '_skip_sep' :anon
-    .param string target
-    .param int pos
-    .param string delim
-    .local int count
-    count = 0
-  L1:
-    $S0 = substr target, pos, 1
-    if $S0 != '=' goto L2
-    inc count
-    inc pos
-    goto L1
-  L2:
-    if $S0 == delim goto L3
-    neg count
-    dec count
-  L3:
-    .return (pos, count)
-.end
-
-
-=item C<unexpected>
-
-=cut
-
-.sub 'unexpected'
-    .param pmc tgt
-    .param pmc adverbs         :slurpy :named
-    .local string target
-    .local int pos, lastpos
-    .local pmc mob
-
-    $P0 = get_hll_global ['PGE'], 'Match'
-    (mob, pos, target) = $P0.'new'(tgt)
-
-    $I0 = index target, ';', pos
-    unless $I0 > 1 goto L1
-    lastpos = length target
-    $I1 = find_not_cclass .CCLASS_WORD, target, pos, lastpos
-    $I2 = $I1 - pos
-    unless $I2 goto L2
-    $S0 = substr target, pos, $I2
-    if $S0 == 'end' goto L1
-    if $S0 == 'else' goto L1
-    if $S0 == 'elseif' goto L1
-    if $S0 == 'until' goto L1
-    $I0 = $I1
-  L2:
-    mob.'to'($I0)
-    lexerror(mob, "unexpected symbol")
-  L1:
-    .return (mob)
-.end
-
-
 .namespace [ 'Lua::PAST::Grammar' ]
 
 =item C<internal_error>
@@ -786,6 +183,7 @@
     $P0 = shift self
 .end
 
+.include 'languages/lua/src/grammar51.pir'
 .include 'languages/lua/src/lua51_gen.pir'
 .include 'languages/lua/src/PASTGrammar_gen.pir'
 .include 'languages/lua/src/POSTGrammar_gen.pir'

Modified: trunk/languages/lua/test_lex.pir
==============================================================================
--- trunk/languages/lua/test_lex.pir    (original)
+++ trunk/languages/lua/test_lex.pir    Fri Mar 28 01:31:35 2008
@@ -15,7 +15,7 @@
 
 =head1 DESCRIPTION
 
-This compiler extends C<Lua::Compiler> (and C<PCT::HLLCompiler>,
+This compiler is a C<PCT::HLLCompiler>,
 see F<compilers/pct/src/PCT/HLLCompiler.pir>)
 
 This compiler defines the following stages:
@@ -34,14 +34,15 @@
 =cut
 
 .sub '__onload' :anon :load :init
-    load_bytecode 'languages/lua/lua.pbc'
+    load_bytecode 'PCT.pbc'
+    load_bytecode 'PGE/Text.pbc'
 
-    new $P0, 'Lua::Compiler'
+    new $P0, 'PCT::HLLCompiler'
     $P0.'language'('LuaTestLex')
     $P0.'parsegrammar'('Lua::TestLex')
     $P0.'astgrammar'('Lua::DumpLex')
 
-    $S0 = "Lexico of Lua 5.1 on Parrot  Copyright (C) 2005-2007, The Perl 
Foundation.\n"
+    $S0 = "Lexico of Lua 5.1 on Parrot  Copyright (C) 2005-2008, The Perl 
Foundation.\n"
     $P0.'commandline_banner'($S0)
     $P0.'commandline_prompt'('> ')
 
@@ -79,6 +80,8 @@
 
 .include 'languages/lua/src/dumplex_gen.pir'
 .include 'languages/lua/src/lua51_testlex_gen.pir'
+.include 'languages/lua/src/lua51_gen.pir'
+.include 'languages/lua/src/grammar51.pir'
 
 .namespace
 

Reply via email to