aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/syntax
Commit message (Collapse)AuthorAge
* Enable support for multiple variable assignments.Gravatar Laurent Le Brun2015-03-23
| | | | | | | | | | This happens in for loops, list comprehensions and simple assigment. e.g. a, b = expr [a for a, b in expr] -- MOS_MIGRATED_REVID=89123977
* Parser: Allow more complex expressions as for loop variables.Gravatar Laurent Le Brun2015-03-23
| | | | | | | Also, use LValue in ForStatement. -- MOS_MIGRATED_REVID=89122760
* Parser: Support tuples without parens.Gravatar Laurent Le Brun2015-03-20
| | | | | | | | | | | | | | | In Python, tuples normally don't need parens, e.g. a, b = c, d for i, j in e: pass However, they are sometimes required to avoid ambiguity: fct((x, y)) [(1, 2), (3, 4)] This distinction is handled with parseExpression vs parseNonTupleExpression. -- MOS_MIGRATED_REVID=89118478
* Move cast* utilities to SkylarkTypeGravatar Francois-Rene Rideau2015-03-20
| | | | | | | | Move castList, castMap, toMap utilities away from SkylarkFunction to SkylarkType where the cast utility already has been moved. -- MOS_MIGRATED_REVID=89042835
* Skylark: Use LValue class in loops and comprehensions.Gravatar Laurent Le Brun2015-03-20
| | | | | -- MOS_MIGRATED_REVID=89020190
* Refactoring: Introduce a new class LValue.Gravatar Laurent Le Brun2015-03-20
| | | | | | | | | | | | | | | | | | | | | | | | | This CL is just moving code from AssignmentStatement to a new class. The goal is to share code dealing with LValues. LValues can be found here: - lvalue = 2 - [for lvalue in exp] - {a: b for lvalue in exp] - for lvalue in exp: pass The LValue itself can have different forms: - a - a, b - a[0] - a, (b, c) - [a[0], (b, c)] - a[1:5] Although we may not handle everything, we need to make sure that the same things can be used in variable assignment and in for loops. -- MOS_MIGRATED_REVID=89015483
* New class hierarchy for Skylark functionsGravatar Francois-Rene Rideau2015-03-20
| | | | | | | | | | | | | | | | | | | | | | | | | | * New hierarchy BaseFunction > UserModeFunction, BuiltinFunction. The old hierarchy still exists for now, to be deleted after migration: Function > AbstractFunction > MixedModeFunction > (UserModeFunction, SkylarkFunction > SimpleSkylarkFunction) (UserModeFunction is already migrated, and BaseFunction implements Function, for now.) * Function supports *args and **kwargs when calling functions, and mandatory named-only parameters in the style of Python 3. Notable difference with Python: *args binds the variable to a tuple, because a Skylark list would have to be monomorphic. * A better, simpler, safer FFI using reflection with BuiltinFunction. Handles typechecking, passes parameters in a more Java style. (Not used for now, will be used later.) * A new annotation @SkylarkSignature, intended to replace @SkylarkBuiltin, supports the full function call protocol, including default arguments. * Support for annotating function Factory-s rather than functions. -- MOS_MIGRATED_REVID=88958581
* Automated [] rollback of [].Gravatar Laurent Le Brun2015-03-20
| | | | | | | | | | | | | *** Reason for rollback *** This CL broke [] *** Original change description *** Skylark: New error message in the lexer when an unsupported Python keyword is used. -- MOS_MIGRATED_REVID=88954426
* Skylark: New error message in the lexer when an unsupported Python keyword ↵Gravatar Laurent Le Brun2015-03-18
| | | | | | | is used. -- MOS_MIGRATED_REVID=88930203
* Lift differences between Skylark and BUILD evaluation, wrt to concatenation.Gravatar Laurent Le Brun2015-03-18
| | | | | | | In particular, struct, dict and set addition work like in Skylark files. -- MOS_MIGRATED_REVID=88929558
* Skylark: Define dict iteration order (sorted by key).Gravatar Laurent Le Brun2015-03-18
| | | | | -- MOS_MIGRATED_REVID=88924033
* Parser: Add the 'pass' keywordGravatar Laurent Le Brun2015-03-18
| | | | | -- MOS_MIGRATED_REVID=88857682
* Parser: allow multiple statements on the same line as the colonGravatar Laurent Le Brun2015-03-18
| | | | | | | | | e.g. def foo(x, y): print(x); print(y) Bug found when adding the pass statement. -- MOS_MIGRATED_REVID=88852710
* Print singleton tuples with a commaGravatar Francois-Rene Rideau2015-03-18
| | | | | | | | | | Like python, print singleton tuples with a terminating comma before the closing parenthesis, so you can read them back as tuples. Also, have toString() call the pretty-printer for Skylark lists and tuples. -- MOS_MIGRATED_REVID=88831764
* Skylark: Fix an infinite loop in the parserGravatar Laurent Le Brun2015-03-18
| | | | | -- MOS_MIGRATED_REVID=88830705
* Parser: Update error message when using 'def' in a BUILD file.Gravatar Laurent Le Brun2015-03-18
| | | | | -- MOS_MIGRATED_REVID=88813915
* Skylark: Allow list slicesGravatar Laurent Le Brun2015-03-16
| | | | | -- MOS_MIGRATED_REVID=88727892
* Skylark: Allow traling comma in load statementsGravatar Laurent Le Brun2015-03-16
| | | | | -- MOS_MIGRATED_REVID=88726457
* Skylark: Static checks allows None value everywhere.Gravatar Laurent Le Brun2015-03-16
| | | | | -- MOS_MIGRATED_REVID=88713932
* Implement ConditionalExpressionGravatar Francois-Rene Rideau2015-03-13
| | | | | | | Also add tests. -- MOS_MIGRATED_REVID=88474801
* Skylark: DictionaryLiteral is immutable (like every dict).Gravatar Laurent Le Brun2015-03-13
| | | | | -- MOS_MIGRATED_REVID=88440711
* Misc Skylark cleanups and small featuresGravatar Francois-Rene Rideau2015-03-10
| | | | | -- MOS_MIGRATED_REVID=88224368
* Skylark: Show ordering when pretty-printing sets.Gravatar Laurent Le Brun2015-03-10
| | | | | -- MOS_MIGRATED_REVID=88149329
* Restore Skylark "support" for inheritanceGravatar Francois-Rene Rideau2015-03-06
| | | | | | | | | | Classes of the same EvalUtils.getSkylarkType are once again the same for the type inferencer. Also, for debugging purposes, only print SkylarkClassObject as struct, not all classes that implement ClassObject yet are considered disjoint by the type engine. -- MOS_MIGRATED_REVID=87933890
* Fix Bazel compileGravatar Kristina Chodorow2015-03-06
| | | | | -- MOS_MIGRATED_REVID=87858855
* Some cleanup changes.Gravatar Ulf Adams2015-03-05
| | | | | -- MOS_MIGRATED_REVID=87821306
* Skylark: fix auto type conversion between the BUILD language and Skylark. ↵Gravatar Googler2015-03-05
| | | | | | | SkylarkList#toList() behaves consistently for all implementations. -- MOS_MIGRATED_REVID=87817550
* Skylark: 'enumerate' function is fixed (see the extra check in ↵Gravatar Googler2015-03-05
| | | | | | | | | MethodLibraryTest#testEnumerate), it returns a SkylarkList of tuples. MethodLibrary tests are cleaned up. -- MOS_MIGRATED_REVID=87592639
* Minor cleanups in SkylarkGravatar Francois-Rene Rideau2015-03-05
| | | | | -- MOS_MIGRATED_REVID=87535290
* Publish a static ASTNode setLocationGravatar Francois-Rene Rideau2015-03-05
| | | | | -- MOS_MIGRATED_REVID=87519507
* Fix race condition in SkylarkType.ofGravatar Francois-Rene Rideau2015-03-05
| | | | | | | | | | | Fix race condition in SkylarkType.of(), whereby .equals() but not same (==) types were created, by making Simple.of() synchronized. Also make SkylarkType#includes() more robust by using .equals() instead of == (it's a little bit slower in the case of Simple types once fixed, but also works on complex types that don't hash-cons their values). Also, distinguish SkylarkList (printed as list) and java.util.List (printed as List) and similarly for tuple vs Tuple, when printing types in debugging messages. -- MOS_MIGRATED_REVID=87490176
* Add Union, contains() to SkylarkTypeGravatar Francois-Rene Rideau2015-03-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Refactor SkylarkType, notably adding Union types and runtime typechecks. These are pre-requisites to unifying all Skylark function calls to use the same code path, that will check types (like SkylarkFunction currently does) as well handle a more complete Python calling convention (like MixedModeFunction is almost but not quite able to do). A SkylarkType can be either * a Simple type corresponding to a Java class, with special types TOP and BOTTOM corresponding respectively to Object and EmptyType (similar to Void). * a Combination of a generic class (LIST, MAP or SET) and an argument type * a Union of a finite number of types * a FunctionType associated with a name and a returnType (with ugly validation-time side-effects that we should probably move out of the type) Unions are necessary because: 1- the type of some builtin function arguments are actually the Union of some type and a function type for a callback that computes the actual value. 2- the type of some builtin function arguments declared as "List" is actually the Union of java List and SkylarkList. 3- instead of adding lots of special cases at the point of argument validation, it's cleaner and more generally useful to have explicit Union types, that can then be displayed to users for documentation or debugging purposes. Validation-time "type inference" is re-expressed simply as type intersection. None is treated specially as inferred into TOP instead of NoneType. Combination types are printed as genericType of argTypes, e.g. "dict of ints". "type" and "generic1" become "genericType" and "argType". In SkylarkList and SkylarkNestedSet, genericType becomes contentType. -- MOS_MIGRATED_REVID=87340881
* Skylark: path in load statement either has to be absolute or has to have ↵Gravatar Googler2015-02-26
| | | | | | | exactly one segment. -- MOS_MIGRATED_REVID=87234901
* Tweaks off of upcoming changes to SkylarkType.Gravatar Francois-Rene Rideau2015-02-25
| | | | | -- MOS_MIGRATED_REVID=87154772
* Make an error message more robust.Gravatar Francois-Rene Rideau2015-02-23
| | | | | | | Make it not depend on the iteration order on the hash table of **kwargs. -- MOS_MIGRATED_REVID=86986044
* Move .accept() from Argument to PassedGravatar Francois-Rene Rideau2015-02-20
| | | | | | | This fixes the visit/accept protocol for Argument.Passed. -- MOS_MIGRATED_REVID=86799044
* Introduce first class function signatures; make the parser use them.Gravatar Francois-Rene Rideau2015-02-19
| | | | | | | | | | | | | | | | | | | This is the first meaty cl in a series to refactor the Skylark function call protocol. 1- We introduce a first-class notion of FunctionSignature, that supports positional and named-only arguments, mandatory and optional, default values, type-checking, *stararg and **kwarg; 2- To keep things clean, we distinguish two different kinds of Argument's: Argument.Passed that appears in function calls, and Parameter, that appears in function definitions. 3- We refactor the Parser so it uses this infrastructure, and make minimal changes to MixedModeFunction so that it works with it (but don't actually implement *starparam and **kwparam yet). 4- As we modify FuncallExpression, we ensure that the args and kwargs arguments it passes to the underlying function are immutable, as a prerequisite to upcoming implementation of *starparam and **kwparam as being provided directly from a skylark list or dict. Further changes under review will take advantage of this FunctionSignature to redo all our function call protocol, to be used uniformly for both UserDefinedFunction's and builtin function. The result will be a simpler inheritance model, with better type-checking, builtin functions that are both simpler and better documented, and many redundant competing functionality-limited codepaths being merged and replaced by something better. NB: The changes to MixedModeFunction, SkylarkFunction and MethodLibrary are temporary hacks to be done away with in an upcoming CL. The rest is the actual changes. -- MOS_MIGRATED_REVID=86704072
* Lots of comments, clarification and correction in Skylark docs.Gravatar Laszlo Csomor2015-02-16
| | | | | -- MOS_MIGRATED_REVID=86436572
* Cosmetic changes moved out of []Gravatar Francois-Rene Rideau2015-02-11
| | | | | | | | These shouldn't affect the semantic of the program in any significant way, but will hush the linter and other such metaprograms. -- MOS_MIGRATED_REVID=86089271
* Skylark: Validate function arguments.Gravatar Laurent Le Brun2015-02-11
| | | | | -- MOS_MIGRATED_REVID=86087783
* Fix linter issues in lib/syntax.Gravatar Laurent Le Brun2015-02-09
| | | | | -- MOS_MIGRATED_REVID=85882605
* Skylark: fixing a crash. It occurred when the files field of the struct ↵Gravatar Googler2015-02-09
| | | | | | | returned by the rule implementation function doesn't have the correct generic type. Error messages are unified. -- MOS_MIGRATED_REVID=85874511
* Skylark: Fix SkylarkNestedSet.toStringGravatar Laurent Le Brun2015-02-09
| | | | | -- MOS_MIGRATED_REVID=85874312
* Fix or suppress warnings in Blaze code. #fixitGravatar Laszlo Csomor2015-02-06
| | | | | -- MOS_MIGRATED_REVID=85722639
* Update from Google.Gravatar Han-Wen Nienhuys2015-02-25
-- MOE_MIGRATED_REVID=85702957