Skip to content

dtwelch/resilientL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

resilientL

Some experimentation with a resilient lexer and LL parser. The parser and lexer are designed to be "IDE Amenable" -- targeting a small language called L.

Follows notes from a rust-analyzer developer documented here. Original rust implementation here.

Update - 04/24/24: checkpointing this for now; lexer is pretty much there; parser code minimal; handles fn defns with no params and basic blocks consisting of a named statement expr

Ungrammar (regex-style BNF) for language L

File = Fn*

Fn = 'fn' 'name' ParamList ('->' TypeExpr)? Block

ParamList = '(' Param* ')'
Param = 'name' ':' TypeExpr ','?

TypeExpr = 'name'

Block = '{' Stmt* '}'

Stmt =
  StmtLet
| StmtReturn
| StmtExpr

StmtLet    = 'let' 'name' '=' Expr ';'
StmtReturn = 'return' Expr ';'
StmtExpr   = Expr ';'

Expr =
  ExprLiteral
| ExprName
| ExprParen
| ExprBinary
| ExprCall

ExprLiteral = 'int' | 'true' | 'false'
ExprName    = 'name'
ExprParen   = '(' Expr ')'
ExprBinary  = Expr ('+' | '-' | '*' | '/') Expr
ExprCall    = Expr ArgList

ArgList = '(' Arg* ')'
Arg = Expr ','?

About

Playing around with a resilient parser

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages