Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test out Lua EBNF #1

Open
mattmassicotte opened this issue Apr 12, 2024 · 0 comments
Open

Test out Lua EBNF #1

mattmassicotte opened this issue Apr 12, 2024 · 0 comments

Comments

@mattmassicotte
Copy link
Contributor

Seems like a good thing to try!

http://parrot.github.io/parrot-docs0/0.4.7/html/languages/lua/doc/lua51.bnf.html

chunk ::= {stat [`;´]} [laststat[`;´]]

        block ::= chunk

        stat ::=  varlist1 `=´ explist1  |
                 functioncall  |
                 do block end  |
                 while exp do block end  |
                 repeat block until exp  |
                 if exp then block {elseif exp then block} [else block] end  |
                 for Name `=´ exp `,´ exp [`,´ exp] do block end  |
                 for namelist in explist1 do block end  |
                 function funcname funcbody  |
                 local function Name funcbody  |
                 local namelist [`=´ explist1]

        laststat ::= return [explist1]  |  break

        funcname ::= Name {`.´ Name} [`:´ Name]

        varlist1 ::= var {`,´ var}

        var ::=  Name  |  prefixexp `[´ exp `]´  |  prefixexp `.´ Name

        namelist ::= Name {`,´ Name}

        explist1 ::= {exp `,´} exp

        exp ::=  nil  |  false  |  true  |  Number  |  String  |  `...´  |
                 function  |  prefixexp  |  tableconstructor  |  exp binop exp  |  unop exp

        prefixexp ::= var  |  functioncall  |  `(´ exp `)´

        functioncall ::=  prefixexp args  |  prefixexp `:´ Name args

        args ::=  `(´ [explist1] `)´  |  tableconstructor  |  String

        function ::= function funcbody

        funcbody ::= `(´ [parlist1] `)´ block end

        parlist1 ::= namelist [`,´ `...´]  |  `...´

        tableconstructor ::= `{´ [fieldlist] `}´

        fieldlist ::= field {fieldsep field} [fieldsep]

        field ::= `[´ exp `]´ `=´ exp  |  Name `=´ exp  |  exp

        fieldsep ::= `,´  |  `;´

        binop ::= `+´  |  `-´  |  `*´  |  `/´  |  `^´  |  `%´  |  `..´  |
                 `<´  |  `<=´  |  `>´  |  `>=´  |  `==´  |  `~=´  |
                 and  |  or

        unop ::= `-´  |  not  |  `#´
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant