Skip to content

Implement Syntax 0.8 #317

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

Merged
merged 29 commits into from
Dec 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
d009ea2
Support astral Unicode characters in TextElements and StringLiterals
stasm Nov 15, 2018
5941f1b
Don't store the term sigil in the identifier name
stasm Nov 15, 2018
bf3f6c8
Treat backslash as normal char in TextElements
stasm Nov 15, 2018
1758b95
End comment lines on EOLs recognized by JS RegExp
stasm Nov 16, 2018
eb0493b
Forbid the closing brace in text
stasm Nov 16, 2018
fd37e32
Merge pull request #307 from stasm/zeroeight-part1
stasm Nov 22, 2018
b449a66
Syntax 0.8, part 2: Dedent multiline text to preserve content indenta…
stasm Nov 28, 2018
30d13b4
Add FunctionReference
stasm Nov 22, 2018
50f226f
Inline trivial serialization functions
stasm Nov 22, 2018
fb5cbef
Store unescaped content in StringLiteral.value and raw content in .raw
stasm Nov 22, 2018
271b7ec
Merge pull request #310 from stasm/zeroeight-part3
stasm Nov 29, 2018
a7c58ea
(fluent) Print missing variables with the $ sigil
stasm Nov 26, 2018
8d5306d
(fluent-syntax) Add parameterized terms
stasm Nov 26, 2018
ecf3207
(fluent) Add parameterized terms
stasm Nov 26, 2018
67bca4b
Merge pull request #311 from stasm/zeroeight-part4-macros
stasm Nov 29, 2018
f210973
Update reference fixtures wrt. Junk content
stasm Nov 27, 2018
2044437
Update reference fixtures wrt. allowing all Unicode characters
stasm Nov 27, 2018
4374b3b
Merge pull request #312 from stasm/zeroeight-part5
stasm Nov 29, 2018
758a0a2
(fluent-syntax) Parameterized term attributes
stasm Nov 27, 2018
9b7849d
(fluent) Use references with extra data rather than member expressions
stasm Nov 26, 2018
df1de5e
(fluent) Parse variant keys in a strict way
stasm Nov 30, 2018
cb22f54
(fluent) Enforce the default variant during parsing
stasm Nov 30, 2018
2cad174
Merge pull request #313 from stasm/zeroeight-part6-macro-attrs
stasm Nov 30, 2018
d2ce2f7
Recognize \UHHHHHH as an escape sequence
stasm Nov 28, 2018
e8c4d3e
Comment lines may only end with Fluent EOLs.
stasm Nov 28, 2018
c8ecf45
Forbid nested VariantLists
stasm Nov 28, 2018
730f005
Merge pull request #314 from stasm/zeroeight-part7
stasm Nov 30, 2018
1cc091f
Refactor getInlineExpression (#318)
stasm Dec 4, 2018
a1e4230
Remove unecessary hasDefault assignment (#325)
stasm Dec 13, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions eslint_src.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,6 @@
],
"no-implied-eval": 2,
"no-loop-func": 2,
"no-magic-numbers": [
1,
{
"ignore": [
-1,
0,
1,
2
]
}
],
"no-useless-call": 2,
"no-useless-concat": 2,
"no-delete-var": 2,
Expand All @@ -59,7 +48,6 @@
"no-extend-native": 2,
"no-global-assign": 2,
"no-extra-bind": 2,
"no-redeclare": 2,
"array-bracket-spacing": 2,
"brace-style": [
1,
Expand Down
1 change: 1 addition & 0 deletions fluent-syntax/.gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
test/fixtures_reference/crlf.ftl eol=crlf
test/fixtures_reference/cr.ftl eol=cr
test/fixtures_structure/crlf.ftl eol=crlf
18 changes: 10 additions & 8 deletions fluent-syntax/src/ast.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,10 @@ export class Placeable extends PatternElement {
export class Expression extends SyntaxNode {}

export class StringLiteral extends Expression {
constructor(value) {
constructor(raw, value) {
super();
this.type = "StringLiteral";
this.raw = raw;
this.value = value;
}
}
Expand Down Expand Up @@ -135,6 +136,14 @@ export class VariableReference extends Expression {
}
}

export class FunctionReference extends Expression {
constructor(id) {
super();
this.type = "FunctionReference";
this.id = id;
}
}

export class SelectExpression extends Expression {
constructor(selector, variants) {
super();
Expand Down Expand Up @@ -236,13 +245,6 @@ export class ResourceComment extends BaseComment {
}
}

export class Function extends Identifier {
constructor(name) {
super(name);
this.type = "Function";
}
}

export class Junk extends SyntaxNode {
constructor(content) {
super();
Expand Down
16 changes: 9 additions & 7 deletions fluent-syntax/src/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ function getErrorMessage(code, args) {
}
case "E0006": {
const [id] = args;
return `Expected term "${id}" to have a value`;
return `Expected term "-${id}" to have a value`;
}
case "E0007":
return "Keyword cannot end with a whitespace";
case "E0008":
return "The callee has to be a simple, upper-case identifier";
return "The callee has to be an upper-case identifier or a term";
case "E0009":
return "The key has to be a simple identifier";
case "E0010":
Expand All @@ -51,7 +51,7 @@ function getErrorMessage(code, args) {
case "E0016":
return "Message references cannot be used as selectors";
case "E0017":
return "Variants cannot be used as selectors";
return "Terms cannot be used as selectors";
case "E0018":
return "Attributes of messages cannot be used as selectors";
case "E0019":
Expand All @@ -62,18 +62,20 @@ function getErrorMessage(code, args) {
return "Positional arguments must not follow named arguments";
case "E0022":
return "Named arguments must be unique";
case "E0023":
return "VariantLists are only allowed inside of other VariantLists.";
case "E0024":
return "Cannot access variants of a message.";
case "E0025": {
const [char] = args;
return `Unknown escape sequence: \\${char}.`;
}
case "E0026": {
const [char] = args;
return `Invalid Unicode escape sequence: \\u${char}.`;
const [sequence] = args;
return `Invalid Unicode escape sequence: ${sequence}.`;
}
case "E0027":
return "Unbalanced closing brace in TextElement.";
case "E0028":
return "Expected an inline expression";
default:
return code;
}
Expand Down
Loading