Skip to content

Commit

Permalink
uploaded pixel grammar
Browse files Browse the repository at this point in the history
  • Loading branch information
rogcg committed Feb 11, 2012
1 parent a15281c commit f77e095
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions Pixel Grammar/Pixel Grammar.txt
@@ -0,0 +1,71 @@
/**
* Copyright 2011 Roger Câmara
*
* Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

*/


"Start Symbol" = <Def>

{ID Head} = {Letter} + [_]
{ID Tail} = {Alphanumeric} + [_]
{String Chars} = {Printable} + {HT} - ["]

Identifier = {ID Head}{ID Tail}*
StringLiteral = '"' {String Chars}* '"'
IntegerLiteral = {Digit}+
RealLiteral = {Digit}+.{Digit}+

! The grammar starts below
<Def> ::= '(' 'def' Identifier '[' <ArgLi> ']' <CommandLi> ')'

<ArgLi> ::= <Arg> <ArgLi> |

<Arg> ::= '(' <Type> Identifier ')'

<Type> ::= 'int' | 'real' | 'str'

<CommandLi> ::= <Command> <CommandLi> |

<Command> ::= '(' <InnerCommand> ')'

<InnerCommand> ::= <Decl> | <Atrib> | <Read> | <Print> | <If> | <While> | <CommandLi>

<Decl> ::= <Type> <IdLi>

<IdLi> ::= Identifier <IdLi2>

<IdLi2> ::= Identifier <IdLi2> |

<Atrib> ::= '=' Identifier <AritExpr>

<AritExpr> ::= <Operan> | '(' <OpArit> <AritExpr> <AritExpr> ')'

<Operan> ::= Identifier | LiteralString | LiteralInteger | LiteralReal

<OpArit> ::= '+' | '-' | '*' | '/' | '&'

<Read> ::= 'read' Identifier

<Print> ::= 'print' <Operan>

<If> ::= 'if' <ExprCond> <Command> <Else>

<Else> ::= <Command> |

<CondExpr> ::= '(' <OpCond> <Operan> <Operan> ')'

<CondOp> ::= '>' |'<' | '<=' | '>=' | '==' | '!='

<While> ::= 'while' <CondExpr> <CommandLi>

0 comments on commit f77e095

Please sign in to comment.