537 Commits

Author SHA1 Message Date
Sascha Brawer
df740092d9 [feaLib] Basic test framework for building OpenType features 2015-09-07 11:39:09 +02:00
Sascha Brawer
b54c04f1d4 [feaLib] Enforce language "dflt" for script "DFLT"
Also add ';' to some langaugesystem test cases. This makes the
snippets syntactically valid. The parser is still expected to
reject them for other reasons, just as before this change.
2015-09-07 11:39:09 +02:00
Sascha Brawer
9ddd313577 [feaLib] Merged LexerError and ParserError
This simplifies the public API to the library.  For clients, it does
not matter which exact component was detecting an error.  And we will
soon have more components; there would be little point in declaring
CompilerError, TableBuilderError, and so forth.
2015-09-07 11:39:09 +02:00
Sascha Brawer
fb050c7a7f [feaLib] Parse rules for multiple substitution (GSUB LookupType 2) 2015-08-11 16:45:54 +02:00
Sascha Brawer
72c1f165b4 [feaLib] Parse substitute from statements 2015-08-11 15:54:54 +02:00
Sascha Brawer
8b77f68dec [feaLib] Parse feature blocks with useExtension keyword 2015-08-11 15:28:59 +02:00
Sascha Brawer
f60d49471d [feaLib] Parse subtable statements 2015-08-11 15:14:47 +02:00
Sascha Brawer
e132741b2c [feaLib] Parse languagesystem in the same way as all other statements
In the new version, the parse_languagesystem_() function returns
an ast.LanguageSystemStatement, which then gets appended to the
current list of statements by the caller. Before this change,
the parse_languagesystem_() function would always append the
newly parsed statement to the list of top-level statements.
In practice, it does not matter because `languagesystem` is
only valid at the top level, but there is no good reason why
the parser method would have to be different from all other
constructs.
2015-08-11 12:55:09 +02:00
Sascha Brawer
abb9edacc9 [feaLib] Parse anchorDef statements 2015-08-11 12:53:30 +02:00
Sascha Brawer
00714511f0 [feaLib] Parse chained contextual substitution rules 2015-08-11 12:22:07 +02:00
Sascha Brawer
c165a1e019 [feaLib] Parse lookup blocks and references 2015-08-11 10:59:26 +02:00
Sascha Brawer
6d7540ecac [feaLib] Move block parsing to a separate method
We will soon support additional blocks beyond `feature`,
and keeping this refactoring separate from new functionality
makes it easier for code reviewers to follow the changes.
2015-08-11 10:19:39 +02:00
Sascha Brawer
1f2fadc864 [feaLib] Parse language statements 2015-08-10 16:30:10 +02:00
Sascha Brawer
4ab6e6b169 [feaLib] Parse script statement 2015-08-10 11:30:47 +02:00
Sascha Brawer
4bcdc60ca8 [feaLib] Remove write() methods
For now, it looks like we won't need them for anything; removing this
code makes the codebase a little bit less complicated.
2015-08-10 11:24:24 +02:00
Sascha Brawer
bc8279bab1 [feaLib] Parse ignore sub and ignore substitute statements 2015-08-10 11:17:52 +02:00
Sascha Brawer
482c498943 [feaLib] Improve unit tests for subtitution rules 2015-08-10 11:17:52 +02:00
Sascha Brawer
08d01bb24d [feaLib] Parse substitution rules for LookupTypes 1 and 3
The parsed representation should handle most of other LookupTypes
as well, but the parser cannot recognize them yet.
2015-08-10 11:17:52 +02:00
Sascha Brawer
37fa652fa9 [feaLib] Add unit test for scoping of valueRecordDef statements 2015-08-10 11:17:52 +02:00
Sascha Brawer
402726f02c [feaLib] Clarify an error message 2015-08-10 11:17:52 +02:00
Sascha Brawer
5270a978a9 [feaLib] Support hexadecimal numbers
The OpenType Feature File specification does not specify hex numbers
as explicit token type, but they appear several times in the examples
given by the spec.
2015-08-10 11:17:52 +02:00
Sascha Brawer
c06a377aa3 [feaLib] Implement valueRecordDef statements 2015-08-10 11:17:52 +02:00
Sascha Brawer
4169e584cc [feaLib] Clarify error message for malformed glyph class references
The new message makes clearer what exactly the parser was looking for
when processing a glyph class reference.
2015-08-10 11:17:52 +02:00
Sascha Brawer
bb5a7e7caf [feaLib] Make symbol tables separate objects
For example, named value records follow the same scoping rules
as named glyph classes.
2015-08-10 11:17:52 +02:00
Sascha Brawer
944fab8a5f [feaLib] Implement parsing of feature blocks 2015-08-10 11:17:52 +02:00
Sascha Brawer
3936e334f1 [feaLib] Resolve references to glyph classes 2015-08-10 11:17:52 +02:00
Sascha Brawer
a0bbd5fab9 [feaLib] Detect duplicate glyph class definitions 2015-08-10 11:17:52 +02:00
Sascha Brawer
d72aac035e [feaLib] Restrict length of glyph class names to 30 characters
This is required by the OpenType Feature File specification,
section 2.g.ii "Named glyph classes".
2015-08-10 11:17:52 +02:00
Sascha Brawer
ba238344b1 [feaLib] Implement top-level glyph class definitions 2015-08-10 11:17:52 +02:00
Sascha Brawer
b86e30d7c6 [feaLib] Rename features.py to ast.py, for Abstract Syntax Tree 2015-08-10 11:17:52 +02:00
Sascha Brawer
23997cfd95 [feaLib] Prevent deprecation warnings on Python 3
In Python 3, the method unittest.TestCase.assertRaisesRegexp
has been renamed to "assertRaisesRegex", and the frameworks spits
out deprecation warnings when using the method name from Python 2.
2015-08-10 11:17:52 +02:00
Sascha Brawer
05fe077654 [feaLib] Parse languagesystem 2015-08-10 11:17:52 +02:00
Sascha Brawer
f4ed6b5a85 Make pretty error messages for LexerError 2015-08-10 11:17:52 +02:00
Sascha Brawer
efbcba79a4 Handle inclusion of OpenType feature files 2015-08-10 11:17:52 +02:00
Sascha Brawer
ac700b0af5 Support FILENAME tokens when lexing OpenType feature files
When the lexer encounters the "include" keyword, it now enters
a special mode for scanning file names.  After having scanned over
the file name, the lexer goes back to normal.  The exact format
of file name strings is not defined by the OpenType feature file
specification, so we accept any character that is not a closing
parenthesis.
2015-08-10 11:17:52 +02:00
Sascha Brawer
612d2122ad Store file path in Lexer
This simplifies the implementation of the parser for
OpenType feature files, since it can now just keep
token locations returned by the lexer.  Before this
change, the parser had to un-pack the location tuples
and build new tuples that included the file path.
2015-08-10 11:17:52 +02:00
Sascha Brawer
da29d22748 Add lexer for OpenType feature files 2015-08-10 11:17:52 +02:00