Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
93 lines (79 sloc) 1.49 KB
# Copyright (C) 2006-2009, Parrot Foundation.
# $Id$
=head1 a grammar for testing lexico
=head2 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 {
| \+
| \-
| \#
| \*
| \/
| \%
| \^
| \.\.\.
| \.\.
| \.
| \<\=
| \<
| \>\=
| \>
| \=\=
| \~\=
| \=
| \,
| \;
| \:
| \(
| \)
| \{
| \}
| \[
| \]
}