# Copyright (C) 2006-2008, The Perl Foundation.
# $Id: /mirror/trunk/languages/lua/src/lua51_testlex.pg 34462 2008-12-27T17:23:27.572097Z fperrad  $

=head1 NAME

src/lua51_testlex.pg - 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.

 TOP ::= {token}
 token ::= Name | keyword | String | Number | punctuator
 keyword ::= 'and' | 'break' | 'do' | 'elseif' | 'else' | 'end' | 'false'
           | 'for' | 'function' | 'if' | 'in' | 'local' | 'nil' | 'not'
           | 'or' | 'repeat' | 'return' | 'then' | 'true' | 'until' | 'while'
 punctuator ::= '+' | '-' | '#' | '*' | '/' | '%' | '^' | '...' | '..' | '.'
              | '<=' | '<' | '>=' | '>' | '==' | '~=' | '='
              | ',' | ';' | ':' | '(' | ')' | '{' | '}' | '[' | ']'

Used by F<languages/lua/test_lex.pir>.

=cut

grammar Lua::TestLex

rule TOP {
    (^ <shebang>)? <token>* [ $ | <die>]
}

rule token {
    | <Name>
    | <keyword>
    | <String>
    | <Number>
    | <punctuator>
}

token keyword {
    | and
    | break
    | do
    | elseif
    | else
    | end
    | false
    | for
    | function
    | if
    | in
    | local
    | nil
    | not
    | or
    | repeat
    | return
    | then
    | true
    | until
    | while
}

token punctuator {
    | \+
    | \-
    | \#
    | \*
    | \/
    | \%
    | \^
    | \.\.\.
    | \.\.
    | \.
    | \<\=
    | \<
    | \>\=
    | \>
    | \=\=
    | \~\=
    | \=
    | \,
    | \;
    | \:
    | \(
    | \)
    | \{
    | \}
    | \[
    | \]
}

