flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > Get first/Follow and Director set of the ebnf grammer

Author
Thread Post new topic Reply to topic
loones



Joined: 09 Apr 2005
Posts: 1
loones
following is the ebnf grammar that i wish to get their first/follow and director set and convert it into LL(1). please help if can..

Program = { ClassDecl } EOF.
ClassDecl = “class” ident “{“ DeclSeq “}”.
DeclSeq = Declaration { Declaration }.
Declaration = ConstDecl | FieldDecl | MethodDecl.
ConstDecl = Attribute “const” BasicType ident “=” Expression “;”.
FieldDecl = Attribute Type ident IdDecl “;”
MethodDecl = Attribute Type ident “(“ [ Params ] “)”“{“ { Statement } “}”.
BasicType = “int” | “bool” | “char” | “string” | “void”.
TypeName = BasicType | ClassIdent.
Type = TypeName [ “[]” ].
Params = Type ident { “,” Type ident }.
Attribute = (“public” | “private”) [ “static” ].
Statement = “;” | “{“ { Statement } “}” | Assignment “;”| MethodCall “;”
| LocalDecl “;” | “if” “(“ Expression “)” Statement [ else Statement ]
| “while” “(“ Expression “)” Statement
|“do” Statement “while” “(“ Expression “)” | “return” [ Expression ] “;”.
Assignment=Designator “=” Expression.
MethodCall =Designator “(“ [ Expression { “,” Expression } ] “)”.
LocalDecl=Type ident IdDecl.
Expression=AndExpression { “||” AndExpression }.
AndExpression=RelExpression { “&&” RelExpression }.
RelExpression =SimpleExpression [ Relop SimpleExpression].
SimpleExpression=Term { Addop Term}.
Term =Factor { Mulop Factor }.
Factor=Primary | (“+” | “-“ | “!” ) Factor.
Primary=Designator [“(“ [ Expression { “,” Expression } ] “)” ] | “(“ Expression )”
| Constructor | “true” | “false” | “null” | number | litString | charLit.
Designator =(“this” | ident) { “.” ident | “[“ SimpleExpression “]” }.
Constructor =“new” ( TypeName “[“ SimpleExpression “]” | ClassIdent “(“ ”)” ).
ClassIdent =ident.
IdDecl=[“=” Expression] {“,” ident [ “=” Expression] }
Relop=“<=” | “<” | “>” | “>=” | “==” | “!=”.
Addop=“+” | “-“.
Mulop=“*” | “/”.
Post 09 Apr 2005, 13:28
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.