Author: fperrad
Date: Tue May 1 22:46:50 2007
New Revision: 18390
Added:
trunk/languages/lua/src/lua51.pg
- copied, changed from r18345, /trunk/languages/lua/src/lua.pg
Removed:
trunk/languages/lua/src/lua.pg
Modified:
trunk/languages/lua/config/makefiles/root.in
trunk/languages/lua/src/ASTGrammar.tg
trunk/languages/lua/src/dumplex.tg
trunk/languages/lua/src/lua51.pir
trunk/languages/lua/src/lua51_testlex.pg
Log:
[Lua]
- add doc
- rename src/lua.pg to src/lua51.pg
Modified: trunk/languages/lua/config/makefiles/root.in
==============================================================================
--- trunk/languages/lua/config/makefiles/root.in (original)
+++ trunk/languages/lua/config/makefiles/root.in Tue May 1 22:46:50 2007
@@ -78,8 +78,8 @@
src/dumplex_gen.pir: src/dumplex.tg
$(TGE) --output=src/dumplex_gen.pir src/dumplex.tg
-src/lua51_grammar_gen.pir: src/lua.pg
- $(PGE) --output=src/lua51_grammar_gen.pir src/lua.pg
+src/lua51_grammar_gen.pir: src/lua51.pg
+ $(PGE) --output=src/lua51_grammar_gen.pir src/lua51.pg
src/ASTGrammar.pir: src/ASTGrammar.tg
$(TGE) --output=src/ASTGrammar.pir src/ASTGrammar.tg
Modified: trunk/languages/lua/src/ASTGrammar.tg
==============================================================================
--- trunk/languages/lua/src/ASTGrammar.tg (original)
+++ trunk/languages/lua/src/ASTGrammar.tg Tue May 1 22:46:50 2007
@@ -1,3 +1,15 @@
+# Copyright (C) 2006-2007, The Perl Foundation.
+# $Id$
+
+=head1 NAME
+
+ASTGrammar.tg - A grammar for transforming the output of a PGE parse into
+an abstract syntax tree.
+
+=head1 DESCRIPTION
+
+
+=cut
grammar Lua::PAST::Grammar is TGE::Grammar;
@@ -462,3 +474,9 @@
printerr "Unknown string\n"
}
+=head1 AUTHORS
+
+Klaas-Jan Stol <[EMAIL PROTECTED]>
+
+=cut
+
Modified: trunk/languages/lua/src/dumplex.tg
==============================================================================
--- trunk/languages/lua/src/dumplex.tg (original)
+++ trunk/languages/lua/src/dumplex.tg Tue May 1 22:46:50 2007
@@ -1,6 +1,18 @@
# Copyright (C) 2006-2007, The Perl Foundation.
# $Id$
+=head1 NAME
+
+src/dumplex.tg - a grammar for testing lexico
+
+=head1 DESCRIPTION
+
+Just print node.
+
+Used by F<languages/lua/test_lex.pir>.
+
+=cut
+
grammar Lua::DumpLex is TGE::Grammar;
transform past (ROOT) :language('PIR') {
@@ -101,3 +113,9 @@
print "ws\n"
}
+=head1 AUTHOR
+
+Francois Perrad
+
+=cut
+
Copied: trunk/languages/lua/src/lua51.pg (from r18345,
/trunk/languages/lua/src/lua.pg)
==============================================================================
--- /trunk/languages/lua/src/lua.pg (original)
+++ trunk/languages/lua/src/lua51.pg Tue May 1 22:46:50 2007
@@ -1,8 +1,13 @@
+# Copyright (C) 2006-2007, The Perl Foundation.
+# $Id$
+
=head1 NAME
-lua.pg - a Lua grammar in PGE
+lua.pg - a Lua 5.1 grammar in PGE
+
+=head1 DESCRIPTION
-=head1 GRAMMAR RULES
+=head2 GRAMMAR RULES
The grammar rules are according to the original Lua parser as defined lparser.c
in the lua distribution.
@@ -178,7 +183,7 @@
}
-=head1 EXPRESSIONS
+=head2 EXPRESSIONS
Operator precedence is implemented using an optable.
@@ -217,7 +222,7 @@
proto 'infix:or' is looser('infix:and') { ... }
-=head1 HELPER RULES
+=head2 HELPER RULES
Helper rules will match a specific token, otherwise a syntax error is
generated.
These rules make the grammar more readable, so the calls to syntax_error() are
@@ -266,9 +271,9 @@
}
-=head1 TOKENS
+=head2 TOKENS
-=head2 Name
+=head3 Name
an identifier MUST start on a word boundary. If the \b is removed,
this is allowed: a=1b=2, which of course should be an error.
@@ -280,7 +285,7 @@
}
-=head2 Strings
+=head3 Strings
A string can be either a single-quoted, double-quoted or a long string.
Long strings are parsed using a custom parsing method.
@@ -308,7 +313,7 @@
]*
}
-=head2 Keywords
+=head3 Keywords
Lua keywords may B<not> be used as identifiers. To make sure the longest
identifier is matched, so that identifiers that B<start> with a keyword
@@ -326,3 +331,9 @@
| <'while'> ] \b
}
+=head1 AUTHORS
+
+Klaas-Jan Stol <[EMAIL PROTECTED]>
+
+=cut
+
Modified: trunk/languages/lua/src/lua51.pir
==============================================================================
--- trunk/languages/lua/src/lua51.pir (original)
+++ trunk/languages/lua/src/lua51.pir Tue May 1 22:46:50 2007
@@ -1,3 +1,34 @@
+# Copyright (C) 2006-2007, The Perl Foundation.
+# $Id$
+
+=head1 NAME
+
+src/lua51.pir -- The compiler for Lua 5.1
+
+=head1 DESCRIPTION
+
+This compiler extends C<HLLCompiler>
+(see F<runtime/parrot/library/Parrot/HLLCompiler.pir>)
+
+This compiler defines the following stages:
+
+=over 4
+
+=item * parse F<languages/lua/src/lua51.pg>
+
+=item * past F<languages/lua/src/ASTGrammar.tg>
+
+=item * post F<languages/lua/src/OSTGrammar.tg>
+
+=item * pir F<languages/lua/src/PIRGrammar.tg>
+
+=item * run
+
+=back
+
+Used by F<languages/lua/luac.pir>.
+
+=cut
.namespace [ 'Lua' ]
@@ -21,6 +52,16 @@
.namespace [ 'Lua::Grammar' ]
+=head2 Functions
+
+Some grammar routines are handly written in PIR.
+
+=over 4
+
+=item C<warning (message)>
+
+=cut
+
.sub 'warning'
.param pmc self
.param string message
@@ -46,6 +87,10 @@
.end
+=item C<syntax_error (message)>
+
+=cut
+
.sub 'syntax_error'
.param pmc self
.param string message
@@ -76,6 +121,10 @@
.end
+=item C<quoted_literal>
+
+=cut
+
.sub 'quoted_literal'
.param pmc mob
.param string delim
@@ -148,6 +197,10 @@
.end
+=item C<long_string>
+
+=cut
+
.sub 'long_string'
.param pmc mob
.param pmc adv :slurpy :named
@@ -197,7 +250,7 @@
($I0, $I1) = _skip_sep(target, pos, ']')
if $I1 != sep goto L7
pos = $I0 + 1
- mob.'value'(literal)
+ mob.'result_object'(literal)
mpos = pos
goto END
L7:
@@ -220,6 +273,10 @@
.end
+=item C<long_comment>
+
+=cut
+
.sub 'long_comment'
.param pmc mob
.param pmc adv :slurpy :named
@@ -266,7 +323,7 @@
($I0, $I1) = _skip_sep(target, pos, ']')
if $I1 != sep goto L7
pos = $I0 + 1
-# mob.'value'(literal)
+# mob.'result_object'(literal)
mpos = pos
goto END
L7:
@@ -312,12 +369,7 @@
.include 'languages/lua/src/ASTGrammar.pir'
.include 'languages/lua/src/lua51_grammar_gen.pir'
-=head1 LICENSE
-
-Copyright (C) 2007, The Perl Foundation.
-
-This is free software; you may redistribute it and/or modify
-it under the same terms as Parrot.
+=back
=head1 AUTHORS
Modified: trunk/languages/lua/src/lua51_testlex.pg
==============================================================================
--- trunk/languages/lua/src/lua51_testlex.pg (original)
+++ trunk/languages/lua/src/lua51_testlex.pg Tue May 1 22:46:50 2007
@@ -1,6 +1,21 @@
# Copyright (C) 2006-2007, The Perl Foundation.
# $Id$
+=head1 NAME
+
+src/lua51_testlex.tg - a grammar for testing lexico
+
+=head1 DESCRIPTION
+
+This grammar allows to test the lexico part of Lua::Grammar.
+
+So, it just defines some top rules, the rules that we want to test are
+imported from the whole Lua grammar.
+
+Used by F<languages/lua/test_lex.pir>.
+
+=cut
+
grammar Lua::TestLex
rule TOP {
@@ -44,3 +59,9 @@
| \]
}
+=head1 AUTHOR
+
+Francois Perrad
+
+=cut
+