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

Grammar railroad diagram #62

Closed
mingodad opened this issue Apr 24, 2022 · 5 comments
Closed

Grammar railroad diagram #62

mingodad opened this issue Apr 24, 2022 · 5 comments

Comments

@mingodad
Copy link

Trying to generate a parser from the EBNF shown here https://cone.jondgoodwin.com/coneref/ebnf.html using this tool https://www.bottlecaps.de/rex/ it complains about undefined symbols (Command line: -tree -main -javascript).

undefined symbol: append_exp
undefined symbol: logic_exp
undefined symbol: perm_type
undefined symbol: if_exp
undefined symbol: match_exp
undefined symbol: while_exp
undefined symbol: each_exp
undefined symbol: loop_exp
undefined symbol: cast_exp

Notice that I already fixed some of then before send again as shown above see bellwo:

/* Statements */
    program ::= dcl_stmt*
    dcl_stmt ::= var_stmt | fn_stmt
    var_stmt ::= perm_ident ident_token type? (',' ident_token type?)* ('=' append_exp (',' append_exp)*)? ';'
    fn_stmt ::= fntype block
    block ::= '{' stmt* '}'
    stmt ::= if_stmt | match_stmt | block | while_stmt | break_stmt | cont_stmt | each_stmt | return_stmt | do_stmt | exp_stmt | ';'
    if_stmt ::= 'if' logic_exp block ( 'elif' logic_exp block )* ( 'else' block )?
    match_stmt ::= 'match' exp ('using' exp)? ('into' var_list)? ('with' exp ('into' var_list)? block)+ ('else' block)?
    while_stmt ::= 'while' logic_exp block
    each_stmt  ::= 'each' (ident_token ':')? var_list 'in' (exp|'...') block
    break_stmt ::= 'break' ';'
    cont_stmt  ::= 'continue' ';'
    return_stmt ::= 'return' this_exp? ';'
    do_stmt ::= 'do' exp? block
    exp_stmt   ::= this_exp ';'

    this_exp ::= exp (('using' exp)? block)?
    var_list ::= perm_ident? ident_token type (',' perm_ident? ident_token type)*

/* Type declarations */
    type ::= genqualname | nbrtype | arraytype | optiontype | ptrtype | reftype | fntype | structtype
    nbrtype ::= 'Bool' | 'i8' | 'i16' | 'i32' | 'i64' | 'isize' | 'u8' | 'u16' | 'u32' | 'u64' | 'usize' | 'f32' | 'f64'
    arraytype ::= '[' integer_token? ']' type
    optiontype ::= '?' type
    ptrtype ::= '*' type
    lifetype ::= lifetime_token type
    reftype ::= '&' region_type? lifetime_token? perm_type? type
    perm_ident ::= 'mut' | 'imm' | 'uni' | 'ro' | 'mutx' | 'id' | genqualname
    region_type ::= genqualname
    fntype ::= 'fn' (ident_token)? '(' fnparm (',' fnparm)* ')' (type (',' type)*)?
    fnparm ::= perm_ident? ident_token type? ('=' (literal | ident_token))?
    structtype ::= 'struct' ident_token? ('{' structstmt (',' structstmt)* '}')?
    structstmt ::= var_stmt | fn_stmt | 'mixin' genqualname

/* General Use Expressions (with possible assignments) */
    exp ::= assgn_exp
    assgn_exp ::= tuple_exp ('=' | '+='|'-='|'*='|'/='|'%='|'&='|'|='|'^='|'<<='|'>>='|'<-') exp
    tuple_exp ::= simple_exp (',' simple_exp)*

/* Expressions without any assignments */
    simple_exp ::= if_exp | match_exp | while_exp | each_exp | loop_exp | or_exp
    or_exp ::= and_exp ('or' and_exp)?
    and_exp ::= not_exp ('and' not_exp)?
    not_exp ::= '!'* compare_exp
    compare_exp ::= range_exp (('=='|'!='|'~~'|'<=>'|'<'|'<='|'>'|'>=') range_exp)?
    range_exp ::= bit_exp ('..' bit_exp)? ('..' bit_exp)?
    bit_exp ::= shift_exp (('|'|'&'|'^') shift_exp)*
    shift_exp ::= arith_exp (('<<' | '>>') arith_exp)?
    arith_exp ::= cast_exp (('+'|'-'|'*'|'/'|'%') cast_exp)*
    as_exp ::= prefix_exp (('as'|'into') type)?
    prefix_exp ::= ('.'|'<-'|'-'|'~'|'*'|'++'|'--')* term | addr
    addr ::= ('&'|'&<'|'&[]') ((region_type perm_type? suffix_exp) | (perm_type? (fn_stmt | (term suffix*))))
    suffix_exp ::= term suffix*
    suffix ::= '++'|'--'| ('.' property) | ('(' (simple_exp (',' simple_exp)*)? ')') | ('[' (simple_exp (',' simple_exp)*)? ']')
    property ::= ident_token | symbol_token | integer_token
    term ::=  literal | genqualname | pseudo | '(' exp ')'
    genqualname ::= (ident_token '::')* ident_token ('[' type (',' type)* ']')?
    pseudo ::= 'self' | 'this'

/* Literals and other tokens */
<?TOKENS?>
    literal ::= float_token | integer_token | text_token | symbol_token | 'true' | 'false' | array_lit
    array_lit ::= '[' (simple_exp (',' simple_exp) ';')? simple_exp (',' simple_exp) ']'
    float_token ::= [0-9][0-9]* '.' [0-9]* (('e'|'E') ('-'|'+')? [0-9]+)?
    integer_token ::= [0-9][0-9]* | '0x' ([0-9]|[a-f]|[A-F])+
    lifetime_token ::= "'" ident_token
    text_token ::= '"' any_char '"'
    symbol_token ::= "'" any_char "'"

    ident_token ::= '`' any_char* '`' | ('@' | '#' | '_' | alpha_char) (alpha_char | [0-9] | '$' | '_')*
@mingodad
Copy link
Author

Here is an initial attempt to create a LL(1) parser to cone (following the code flow) and it's EBNF, using a variant of https://github.com/SSW-CocoR/CocoR-CPP .

COMPILER Cone

TERMINALS
	TOKEN_REF

CHARACTERS
	letter = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".
	lowline  = "_".
	digit = "0123456789".
	nzdigit    = '1'..'9'.
	oct        = '0'..'7'.
	noquote1 = ANY - "'".
	noquote2 = ANY - '"'.
	norbrack = ANY - ']'.
	cr        = '\r'.
	lf        = '\n'.
	tab       = '\t'.
	notApo     = ANY - '\'' - "\r\n".
	stringCh  = ANY - '"' - '\\' - cr - lf.
	charCh    = ANY - '\'' - '\\' - cr - lf.
	printable = '\u0020' .. '\u007e'.
	hex       = "0123456789abcdef".

TOKENS
	StringLitToken = '"' { stringCh | '\\' printable } '"' .
	badString = '"' { stringCh | '\\' printable } (cr | lf).
	IdentToken = letter {letter | lowline | digit} .
	//LEXER_CHAR_SET = '[' { norbrack | '\\' printable } ']' . //(~ [\]\\] | EscAny)+ -> more

	FloatLitToken = ( '.' digit {digit} [('e'|'E')  ['+'|'-'] digit {digit}]
						 | digit {digit} '.' {digit} [('e'|'E')  ['+'|'-'] digit {digit}]
						 | digit {digit} ('e'|'E')  ['+'|'-'] digit {digit}
						 )
						 ['f'|'l'|'F'|'L'].

	IntLitToken   = ( nzdigit {digit}
						 | '0' {oct}
						 | ("0x"|"0X") hex {hex}
						 )
						 {'u'|'U'|'l'|'L'}.

	charcon  = '\'' notApo {notApo} '\''. // no check for valid escape sequences

	// Punctuation tokens
	SemiToken = ";" .
	ColonToken = ":" .
	DblColonToken = "::" .
	LCurlyToken = "{" .
	RCurlyToken = "}" .
	LBracketToken = "[" .
	RBracketToken = "]" .
	LParenToken = "(" .
	RParenToken = ")" .
	CommaToken = "," .
	DotToken = "." .
	QuesDotToken = "?." .
	PlusToken = "+" .
	PlusArrayRefToken = "+[]" .
	PlusVirtRefToken = "+<" .
	DashToken = "-" .
	StarToken = "*" .
	PercentToken = "%" .
	SlashToken = "/" .
	AmperToken = "&" .
	ArrayRefToken = "&[]" .
	VirtRefToken = "&<" .
	AndToken = "and" .
	BarToken = "|" .
	OrToken = "or" .
	CaretToken = "^" .
	NotToken = "!" .
	QuesToken = "?" .
	TildeToken = "~" .
	LessDashToken = "<-" .
	AssgnToken = "=" .
	LAssgnToken = ":=" .
	SwapToken = "<=>" .
	IsToken = "is" .
	EqToken = "==" .
	NeToken = "!=" .
	LtToken = "<" .
	LeToken = "<=" .
	GtToken = ">" .
	GeToken = ">=" .
	ShlToken = "<<" .
	ShrToken = ">>" .
	PlusEqToken = "+=" .
	MinusEqToken = "-=" .
	MultEqToken = "*=" .
	DivEqToken = "/=" .
	RemEqToken = "%=" .
	OrEqToken = "|=" .
	AndEqToken = "&=" .
	XorEqToken = "^=" .
	ShlEqToken = "<<=" .
	ShrEqToken = ">>=" .
	IncrToken = "++" .
	DecrToken = "--" .

	// Keywords
	IncludeToken = "include" .
	ImportToken = "import" .
	ExternToken = "extern" .
	MacroToken = "macro" .
	FnToken = "fn" .
	ConstToken = "const" .
	TypedefToken = "typedef" .
	StructToken = "struct" .
	TraitToken = "trait" .
	UnionToken = "union" .
	MoveToken = "@move" .
	OpaqueToken = "@opaque" .
	ExtendsToken = "extends" .
	MixinToken = "mixin" .
	EnumToken = "enum" .
	RegionToken = "region" .
	RetToken = "return" .
	WithToken = "with" .
	IfToken = "if" .
	ElifToken = "elif" .
	ElseToken = "else" .
	CaseToken = "case" .
	MatchToken = "match" .
	WhileToken = "while" .
	EachToken = "each" .
	InToken = "in" .
	ByToken = "step" .
	BreakToken = "break" .
	ContinueToken = "continue" .
	AsToken = "as" .
	IntoToken = "into" .
	InlineToken = "inline" .
	VoidToken = "void" .
	nilToken = "nil" .
	trueToken = "true" .
	falseToken = "false" .
	UndefToken = "undef" .
	LifetimeToken = "'" .


COMMENTS FROM "/*" TO "*/" NESTED
COMMENTS FROM "//" TO lf

IGNORE cr + lf + tab

PRODUCTIONS

// The main entry point for parsing a v4 grammar.
Cone =
	{parseGlobalStmts} EOF
	.

parseGlobalStmts =
	parseInclude
	| parseImport
	| parseTypedef
	| parseStruct
	| parseTrait
	| parseUnion
	| parseMacro
	| ExternToken ["system"] (
		parseBlock
		| parseFnOrVar
	)
	| parseFnOrVar
	| parseConstDcl
	.

parseInclude =
	IncludeToken parseFile parseEndOfStatement
	.

parseImport =
	ImportToken parseFile [DblColonToken StarToken] parseEndOfStatement
	.

parseTypedef =
	TypedefToken IdentToken parseVtype parseEndOfStatement
	.

parseStruct =
	StructToken parseStructBody
	.

parseTrait =
	TraitToken parseStructBody
	.

parseUnion =
	UnionToken parseStructBody
	.

parseMacro =
	MacroToken parseStructBody
	.

parseStructBody =
	[(MoveToken [OpaqueToken]) | (OpaqueToken [MoveToken])]
		IdentToken [parseGenericParms]
		[ExtendsToken parseTypeName]
	.

parseTypeName =
	parseNameUse [LBracketToken parseVtype {CommaToken parseVtype} RBracketToken]
	.

parseFnOrVar =
	(FnToken | parseVarDcl)
	.

parseBlock =
	(ColonToken | LCurlyToken) {parseFnOrVar} RCurlyToken
	.

parseConstDcl =
	ConstToken IdentToken parseVtype [AssgnToken parseAnyExpr]
	.

parseFile =
	(IdentToken | StringLitToken)
	.

parseVtype =
	parsePrefix
	.

parsePrefix =
	parseDotCall
	| StarToken parsePrefix
	| parseAmper
	| parsePlus
	| QuesToken parsePrefix
	| DashToken parsePrefix
	| TildeToken parsePrefix
	| IncrToken parsePrefix
	| DecrToken parsePrefix
	| (parseTerm | parseSuffixTerm)
	.

parseDotCall =
	DotToken
	.

parseAmper =
	(AmperToken | ArrayRefToken | VirtRefToken) parsePerm [parseFn]
	.

parsePlus =
	(PlusToken | PlusArrayRefToken | PlusVirtRefToken) parseNameUse [DashToken (PermToken | parseNameUse)] parsePrefix
	.

parseNameUse =
	[DblColonToken] IdentToken {DblColonToken IdentToken}
	.

parseSuffixTerm =
	parseTerm parsePrefix
	.

parseTerm =
	nilToken
	| trueToken
	| falseToken
	| VoidToken
	| IntLitToken
	| FloatLitToken
	| StringLitToken
	| parseNameUse
	| LParenToken parseAnyExpr RParenToken
	| parseArrayLit
	| parseIf
	| parseMatch
	| parseWhile
	| parseLifetime
	| parseExprBlock
	.

parseAnyExpr =
	parseAssign
	.

parseArrayLit =
	LBracketToken parseSimpleExpr {CommaToken parseSimpleExpr} [SemiToken parseSimpleExpr {CommaToken parseSimpleExpr}] RBracketToken
	.

parseIf =
	IfToken
	.

parseMatch =
	MatchToken
	.

parseWhile =
	WhileToken
	.

parseLifetime =
	LifetimeToken
	.

parseExprBlock =
	(LCurlyToken | ColonToken) {parseExprBlockBody} RCurlyToken
	.

parseExprBlockBody =
	SemiToken
	| parseReturn
	| parseWith
	| parseIf
	| parseMatch
	| parseWhile
	| parseEach
	| parseLifetime
	| BreakToken [LifetimeToken] [parseAnyExpr] parseEndOfStatement
	| ContinueToken [LifetimeToken] parseEndOfStatement
	| parseExprBlock
	| parseVarDcl parseEndOfStatement
	| parseExpStmt
	.

parseReturn =
	RetToken [parseAnyExpr] parseIsEndOfStatement
	.

parseWith =
	WithToken
	.

parseEach =
	EachToken
	.

parseIsEndOfStatement =
	SemiToken
	| RCurlyToken
	.

parseExpStmt =
	parseAnyExpr parseEndOfStatement
	.

parseAssign =
	parseAppend
	.

parseAppend =
	LessDashToken
	| parseTuple (
		(
			AssgnToken
			| LAssgnToken
			| SwapToken
			| PlusEqToken
			| MinusEqToken
			| MultEqToken
			| DivEqToken
			| RemEqToken
			| OrEqToken
			| AndEqToken
			| XorEqToken
			| ShlEqToken
			| ShrEqToken
		) parseAnyExpr
		| LessDashToken parseAppend
	)
	.

parseFn =
	IdentToken [parseGenericParms] parseFnSig [InlineToken] (parseExprBlock | parseEndOfStatement)
	.

parseGenericParms =
	LBracketToken IdentToken {CommaToken IdentToken} RBracketToken
	.

parseFnSig =
	LParenToken [parseVarDcl {CommaToken parseVarDcl}] RParenToken
	.

parseVarDcl =
	parsePerm IdentToken parseVtype [AssgnToken parseAnyExpr]
	.

parsePerm =
	PermToken
	.

parseTuple =
	parseSimpleExpr {CommaToken parseSimpleExpr}
	.

parseSimpleExpr =
	parseOrExpr
	.

parseOrExpr =
	parseAndLogic {OrToken parseAndLogic}
	.

parseAndLogic =
	parseNotLogic {AndToken parseNotLogic}
	.

parseNotLogic =
	NotToken parseNotLogic
	| parseCmp
	.

parseCmp =
	parseOr [ (EqToken | NeToken | LtToken | LeToken | GtToken | GeToken) parseOr ]
	.

parseOr =
	parseXor {BarToken parseXor}
	.

parseXor =
	parseShift {AmperToken parseShift}
	.

parseShift =
	parseAdd {(ShlToken | ShrToken) parseAdd}
	.

parseAdd =
	parseMult {(PlusToken | DashToken) parseMult}
	.

parseMult =
	parseCast {(StarToken | SlashToken | PercentToken) parseCast}
	.

parseCast =
	parsePrefix {(AsToken | IntoToken) parseVtype}
	.

parseEndOfStatement =
	SemiToken
	.

PermToken =
	("uni" | "imm" | "mut" | "ro" | "opaq")
	.

END Cone.

EBNF:

//
// EBNF generated by CocoR parser generator to be viewed with https://www.bottlecaps.de/rr/ui
//

//
// productions
//

Cone ::=  parseGlobalStmts* EOF
parseGlobalStmts ::=  parseInclude | parseImport | parseTypedef | parseStruct | parseTrait | parseUnion | parseMacro | ExternToken "system"? ( parseBlock | parseFnOrVar ) | parseFnOrVar | parseConstDcl
parseInclude ::=  IncludeToken parseFile parseEndOfStatement
parseImport ::=  ImportToken parseFile ( DblColonToken StarToken )? parseEndOfStatement
parseTypedef ::=  TypedefToken IdentToken parseVtype parseEndOfStatement
parseStruct ::=  StructToken parseStructBody
parseTrait ::=  TraitToken parseStructBody
parseUnion ::=  UnionToken parseStructBody
parseMacro ::=  MacroToken parseStructBody
parseBlock ::=  ( ColonToken | LCurlyToken ) parseFnOrVar* RCurlyToken
parseFnOrVar ::=  FnToken | parseVarDcl
parseConstDcl ::=  ConstToken IdentToken parseVtype ( AssgnToken parseAnyExpr )?
parseFile ::=  IdentToken | StringLitToken
parseEndOfStatement ::=  SemiToken
parseVtype ::=  parsePrefix
parseStructBody ::=  ( MoveToken OpaqueToken? | OpaqueToken MoveToken? )? IdentToken parseGenericParms? ( ExtendsToken parseTypeName )?
parseGenericParms ::=  LBracketToken IdentToken ( CommaToken IdentToken )* RBracketToken
parseTypeName ::=  parseNameUse ( LBracketToken parseVtype ( CommaToken parseVtype )* RBracketToken )?
parseNameUse ::=  DblColonToken? IdentToken ( DblColonToken IdentToken )*
parseVarDcl ::=  parsePerm IdentToken parseVtype ( AssgnToken parseAnyExpr )?
parseAnyExpr ::=  parseAssign
parsePrefix ::=  parseDotCall | StarToken parsePrefix | parseAmper | parsePlus | QuesToken parsePrefix | DashToken parsePrefix | TildeToken parsePrefix | IncrToken parsePrefix | DecrToken parsePrefix | ( parseTerm | parseSuffixTerm )
parseDotCall ::=  DotToken
parseAmper ::=  ( AmperToken | ArrayRefToken | VirtRefToken ) parsePerm parseFn?
parsePlus ::=  ( PlusToken | PlusArrayRefToken | PlusVirtRefToken ) parseNameUse ( DashToken ( PermToken | parseNameUse ) )? parsePrefix
parseTerm ::=  nilToken | trueToken | falseToken | VoidToken | IntLitToken | FloatLitToken | StringLitToken | parseNameUse | LParenToken parseAnyExpr RParenToken | parseArrayLit | parseIf | parseMatch | parseWhile | parseLifetime | parseExprBlock
parseSuffixTerm ::=  parseTerm parsePrefix
parsePerm ::=  PermToken
parseFn ::=  IdentToken parseGenericParms? parseFnSig InlineToken? ( parseExprBlock | parseEndOfStatement )
PermToken ::=  "uni" | "imm" | "mut" | "ro" | "opaq"
parseArrayLit ::=  LBracketToken parseSimpleExpr ( CommaToken parseSimpleExpr )* ( SemiToken parseSimpleExpr ( CommaToken parseSimpleExpr )* )? RBracketToken
parseIf ::=  IfToken
parseMatch ::=  MatchToken
parseWhile ::=  WhileToken
parseLifetime ::=  LifetimeToken
parseExprBlock ::=  ( LCurlyToken | ColonToken ) parseExprBlockBody* RCurlyToken
parseAssign ::=  parseAppend
parseSimpleExpr ::=  parseOrExpr
parseExprBlockBody ::=  SemiToken | parseReturn | parseWith | parseIf | parseMatch | parseWhile | parseEach | parseLifetime | BreakToken LifetimeToken? parseAnyExpr? parseEndOfStatement | ContinueToken LifetimeToken? parseEndOfStatement | parseExprBlock | parseVarDcl parseEndOfStatement | parseExpStmt
parseReturn ::=  RetToken parseAnyExpr? parseIsEndOfStatement
parseWith ::=  WithToken
parseEach ::=  EachToken
parseExpStmt ::=  parseAnyExpr parseEndOfStatement
parseIsEndOfStatement ::=  SemiToken | RCurlyToken
parseAppend ::=  LessDashToken | parseTuple ( ( AssgnToken | LAssgnToken | SwapToken | PlusEqToken | MinusEqToken | MultEqToken | DivEqToken | RemEqToken | OrEqToken | AndEqToken | XorEqToken | ShlEqToken | ShrEqToken ) parseAnyExpr | LessDashToken parseAppend )
parseTuple ::=  parseSimpleExpr ( CommaToken parseSimpleExpr )*
parseFnSig ::=  LParenToken ( parseVarDcl ( CommaToken parseVarDcl )* )? RParenToken
parseOrExpr ::=  parseAndLogic ( OrToken parseAndLogic )*
parseAndLogic ::=  parseNotLogic ( AndToken parseNotLogic )*
parseNotLogic ::=  NotToken parseNotLogic | parseCmp
parseCmp ::=  parseOr ( ( EqToken | NeToken | LtToken | LeToken | GtToken | GeToken ) parseOr )?
parseOr ::=  parseXor ( BarToken parseXor )*
parseXor ::=  parseShift ( AmperToken parseShift )*
parseShift ::=  parseAdd ( ( ShlToken | ShrToken ) parseAdd )*
parseAdd ::=  parseMult ( ( PlusToken | DashToken ) parseMult )*
parseMult ::=  parseCast ( ( StarToken | SlashToken | PercentToken ) parseCast )*
parseCast ::=  parsePrefix ( ( AsToken | IntoToken ) parseVtype )*

//
// tokens
//

SemiToken ::= ";"
ColonToken ::= ":"
DblColonToken ::= "::"
LCurlyToken ::= "{"
RCurlyToken ::= "}"
LBracketToken ::= "["
RBracketToken ::= "]"
LParenToken ::= "("
RParenToken ::= ")"
CommaToken ::= ","
DotToken ::= "."
QuesDotToken ::= "?."
PlusToken ::= "+"
PlusArrayRefToken ::= "+[]"
PlusVirtRefToken ::= "+<"
DashToken ::= "-"
StarToken ::= "*"
PercentToken ::= "%"
SlashToken ::= "/"
AmperToken ::= "&"
ArrayRefToken ::= "&[]"
VirtRefToken ::= "&<"
AndToken ::= "and"
BarToken ::= "|"
OrToken ::= "or"
CaretToken ::= "^"
NotToken ::= "!"
QuesToken ::= "?"
TildeToken ::= "~"
LessDashToken ::= "<-"
AssgnToken ::= "="
LAssgnToken ::= ":="
SwapToken ::= "<=>"
IsToken ::= "is"
EqToken ::= "=="
NeToken ::= "!="
LtToken ::= "<"
LeToken ::= "<="
GtToken ::= ">"
GeToken ::= ">="
ShlToken ::= "<<"
ShrToken ::= ">>"
PlusEqToken ::= "+="
MinusEqToken ::= "-="
MultEqToken ::= "*="
DivEqToken ::= "/="
RemEqToken ::= "%="
OrEqToken ::= "|="
AndEqToken ::= "&="
XorEqToken ::= "^="
ShlEqToken ::= "<<="
ShrEqToken ::= ">>="
IncrToken ::= "++"
DecrToken ::= "--"
IncludeToken ::= "include"
ImportToken ::= "import"
ExternToken ::= "extern"
MacroToken ::= "macro"
FnToken ::= "fn"
ConstToken ::= "const"
TypedefToken ::= "typedef"
StructToken ::= "struct"
TraitToken ::= "trait"
UnionToken ::= "union"
MoveToken ::= "@move"
OpaqueToken ::= "@opaque"
ExtendsToken ::= "extends"
MixinToken ::= "mixin"
EnumToken ::= "enum"
RegionToken ::= "region"
RetToken ::= "return"
WithToken ::= "with"
IfToken ::= "if"
ElifToken ::= "elif"
ElseToken ::= "else"
CaseToken ::= "case"
MatchToken ::= "match"
WhileToken ::= "while"
EachToken ::= "each"
InToken ::= "in"
ByToken ::= "step"
BreakToken ::= "break"
ContinueToken ::= "continue"
AsToken ::= "as"
IntoToken ::= "into"
InlineToken ::= "inline"
VoidToken ::= "void"
nilToken ::= "nil"
trueToken ::= "true"
falseToken ::= "false"
UndefToken ::= "undef"
LifetimeToken ::= "'"

@jondgoodwin
Copy link
Owner

Wow! Thanks for doing all this. Will study it more closely when I have some free time.

@jondgoodwin
Copy link
Owner

I have looked it through, and you have captured quite a bit of the syntax accurately from the code. It appears there are some productions that are currently incomplete - e.g., the control flow (parseIf, etc.).

What future plans do you have for this work?

@mingodad
Copy link
Author

At first I already have done with it, I believe that the railroad diagram is a nice way to communicate the global view of a programming language and help work with it.
I hope it could be useful and I use it (or any other programming language) as an excuse to exercise my skills in parsers/parsing.

@jondgoodwin
Copy link
Owner

Good on you, and thanks for sharing it for our benefit. All the best to you!

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

2 participants