@@ -30,19 +30,28 @@ local ftlparser = epnf.define(function (_ENV)
3030 local special_text_char = P " {" + P " }"
3131 local any_char = R (" \0\127 " ) / f1 + R (" \194\223 " ) * R (cont ) / f2 + R (" \224\239 " ) * R (cont ) * R (cont ) / f3 + R (" \240\244 " ) * R (cont ) * R (cont ) * R (cont ) / f4
3232 local text_char = any_char - special_text_char - line_end
33+ local special_quoted_char = P ' "' + P " \\ "
34+ local special_escape = P " \\ " * special_quoted_char
35+ local unicode_escape = (P " \\ u" * P (4 ) * R (" 09" , " af" , " AF" )^ 4 ) + (P " \\ u" * P (6 ) * R (" 09" , " af" , " AF" )^ 6 )
36+ local quoted_char = (any_char - special_quoted_char - line_end ) + special_escape + unicode_escape
3337 local indented_char = text_char - P " {" - P " *" - P " ."
3438 Identifier = R (" az" , " AZ" ) * (R (" az" , " AZ" , " 09" ) + P " _" + P " -" )^ 0
3539 local variant_list = V " Variant" ^ 0 * V " DefaultVariant" * V " Variant" * line_end
3640 Variant = line_end * blank ^- 1 * V " VariantKey" * blank_inline ^- 1 * V " Pattern"
3741 DefaultVariant = line_end * blank ^- 1 * P " *" * V " VariantKey" * blank_inline ^- 1 * V " Pattern"
3842 VariantKey = P " [" * blank ^- 1 * (V " NumberLiteral" + V " Identifier" ) * blank ^- 1 * P " ]"
3943 NumberLiteral = P " -" ^- 1 * digits * (P " ." * digits )^- 1
40- SelectExpression = V " InlineExpression" * blank ^- 1 * P " ->" * blank_inline ^- 1 * variant_list
41- InlineExpression = P " foo"
4244 local inline_placeable = P " {" * blank ^- 1 * (V " SelectExpression" + V " InlineExpression" ) * blank ^- 1 * P " }"
4345 local block_placeable = blank_block * blank_inline ^- 1 * inline_placeable
4446 local inline_text = text_char ^ 1
4547 local block_text = blank_block * blank_inline * indented_char * inline_text ^- 1
48+ StringLiteral = P ' "' * quoted_char ^ 0 * P ' "'
49+ FunctionReference = P " foof"
50+ MessageReference = P " foom"
51+ TermReference = P " foot"
52+ VariableReference = P " foov"
53+ SelectExpression = V " InlineExpression" * blank ^- 1 * P " ->" * blank_inline ^- 1 * variant_list
54+ InlineExpression = V " StringLiteral" + V " NumberLiteral" + V " FunctionReference" + V " MessageReference" + V " TermReference" + V " VariableReference" + inline_placeable
4655 PatternElement = inline_text + block_text + inline_placeable + block_placeable
4756 Pattern = V " PatternElement" ^ 1
4857 Attribute = line_end * blank ^- 1 * P " ." * V " Identifier" * blank_inline ^- 1 * " =" * blank_inline ^- 1 * V " Pattern"
@@ -58,7 +67,7 @@ local ftlparser = epnf.define(function (_ENV)
5867end )
5968-- luacheck: pop
6069
61- -- TODO: Spec L53-62, L66-L75, L122-L129
70+ -- TODO: Spec L66-L75
6271
6372local FluentSyntax = class ({
6473 parser = ftlparser ,
0 commit comments