Skip to content

Commit d62e5b7

Browse files
committed
Define parser based on EBNF: References are unmentionable...
1 parent 5f3ffbb commit d62e5b7

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

fluent/syntax.lua

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,15 @@ local ftlparser = epnf.define(function (_ENV)
4646
local inline_text = text_char^1
4747
local block_text = blank_block * blank_inline * indented_char * inline_text^-1
4848
StringLiteral = P'"' * quoted_char^0 * P'"'
49-
FunctionReference = P"foof"
50-
MessageReference = P"foom"
51-
TermReference = P"foot"
52-
VariableReference = P"foov"
49+
FunctionReference = V"Identifier" * V"CallArguments"
50+
MessageReference = V"Identifier" * V"AttributeAccessor"^-1
51+
TermReference = P"-" * V"Identifier" * V"AttributeAccessor"^-1 * V"CallArguments"^-1
52+
VariableReference = P"$" * V"Identifier"
53+
AttributeAccessor = P"." * V"Identifier"
54+
NamedArgument = V"Identifier" * blank^-1 * P":" * blank^-1 * (V"StringLiteral" + V"NumberLiteral")
55+
Argument = V"NamedArgument" + V"InlineExpression"
56+
local argument_list = (V"Argument" * blank^-1 * P"," * blank^-1)^0 * V"Argument"^-1
57+
CallArguments = blank^-1 * P"(" * blank^-1 * argument_list * blank^-1 * P")"
5358
SelectExpression = V"InlineExpression" * blank^-1 * P"->" * blank_inline^-1 * variant_list
5459
InlineExpression = V"StringLiteral" + V"NumberLiteral" + V"FunctionReference" + V"MessageReference" + V"TermReference" + V"VariableReference" + inline_placeable
5560
PatternElement = inline_text + block_text + inline_placeable + block_placeable
@@ -67,8 +72,6 @@ local ftlparser = epnf.define(function (_ENV)
6772
end)
6873
-- luacheck: pop
6974

70-
-- TODO: Spec L66-L75
71-
7275
local FluentSyntax = class({
7376
parser = ftlparser,
7477
parse = function (self, input)

0 commit comments

Comments
 (0)