grammar-kit

Re-write Parsing Expression Grammar (PEG) without left recursion

≡放荡痞女 提交于 2019-12-22 09:33:30
问题 Using https://github.com/JetBrains/Grammar-Kit how to rewrite grammar without left recursion? grammar ::= exprs exprs::= (sum_expr (';')?)* private sum_expr::= sum_expr_infix | sum_expr_prefix sum_expr_infix ::= number sum_expr_prefix left sum_expr_prefix::= op_plus number private op_plus ::= '+' number ::= float | integer float ::= digit+ '.' digit* integer ::= digit+ private digit ::=('0'|'1'|'2'|'3'|'4'|'5'|'6'|'7'|'8'|'9') Sample input: 10+20+30.0; 10+20+30.0 Answer shall maintain parse

Lexing The VHDL ' (tick) Token

泄露秘密 提交于 2019-12-22 08:45:08
问题 In VHDL it the ' character can be used to encapsulate a character token ie '.' or it can as an attribute separator (similarish to CPP's :: token) ie string'("hello") . The issue comes up when parsing an attribute name containing a character ie string'('a','b','c') . In this case a naive lexer will incorrectly tokenize the first '(' as a character, and all of the following actual character will be messed up. There is a thread in comp.lang.vhdl google group from 2007 which asks a similar