summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/ast/parser
Commit message (Collapse)AuthorAgeFilesLines
...
* | Merge pull request #4590 from som-snytt/issue/6810Lukas Rytz2015-08-241-3/+5
|\ \ | | | | | | SI-6810 Disallow EOL in char literal
| * | SI-6810 Disallow EOL in char literalSom Snytt2015-06-291-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's clear that char literals are one-lined like normal string literals. By the same token, pun intended, char literals accept unicode escapes the same as string literals, including `\u000A`. This commit adds the usual exclusions (CR, NL, SU). The spec is outdated in outlawing chars that are not "printable", in particular, the ASCII control codes. The original intention may have been that the ordinary string escapes are required, such as "\b\n". Note that some common escapes are absent, such as "\a".
* | | Merge remote-tracking branch 'origin/2.11.x' into 2.12.xSeth Tisue2015-08-201-1/+1
|\ \ \ | |/ / |/| / | |/ | | | | | | | | | | | | all conflicts were because the changes changed code that doesn't exist anymore in 2.12; they were resolved with `git checkout --ours` c201eac changed bincompat-forward.whitelist.conf but I dropped the change in this merge because it refers to AbstractPromise which no longer exists in 2.12
| * ScalaDoc fixes for compilerJanek Bogucki2015-07-291-1/+1
| |
* | Merge remote-tracking branch 'origin/2.11.x' into ↵Jason Zaugg2015-05-011-1/+1
|\| | | | | | | merge/2.11.x-to-2.12.x-20150501
| * Fix many typosMichał Pociecha2015-04-211-1/+1
| | | | | | | | | | This commit corrects many typos found in scaladocs and comments. There's also fixed the name of a private method in ICodeCheckers.
* | Merge commit '555f8f0' into merge/2.11-to-2.12-apr-21Lukas Rytz2015-04-212-57/+96
|\|
| * SI-3368 Default to coalescing for 2.11Som Snytt2015-04-161-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Preserve current behavior (no PCData nodes, only Text) for 2.11. The coalescing flag is on if enabled or if source level is not 2.12 and no flag was supplied. The subtle change is that adjacent Text nodes are thereby coalesced. This happens in the presence of CData sections, but this is at the discretion of the parser anyway. Also, no PCData nodes are emitted under coalescing, even if there were no sibling text nodes. That is the correct behavior: the general idea is that coalescing mode says, I only want to deal with text.
| * SI-3368 Promote xml option to -XxmlSom Snytt2015-04-082-2/+2
| | | | | | | | | | | | | | | | | | As long as Scala does XML literals, there is probably parsing behavior worth configuring. Therefore, the umbrella option is promoted to `-Xxml`. It was tempting to make it `-XML`, but we resisted.
| * SI-3368 CDATA gets a NodeSom Snytt2015-04-082-57/+97
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | XML Parser uses `scala.xml.PCData`. A compiler flag `-Yxml:coalescing`, analogous to `DocumentBuilderFactory.setCoalescing`, turns `PCData` nodes into `Text` nodes and coalesces sibling text nodes. This change also fixes parse errors such as rejecting a sequence of CDATA sections. A sequence of "top level" nodes are not coalesced. ``` scala> <a><b/>start<![CDATA[hi & bye]]><c/>world<d/>stuff<![CDATA[red & black]]></a> res0: scala.xml.Elem = <a><b/>start<![CDATA[hi & bye]]><c/>world<d/>stuff<![CDATA[red & black]]></a> scala> :replay -Yxml:coalescing Replaying: <a><b/>start<![CDATA[hi & bye]]><c/>world<d/>stuff<![CDATA[red & black]]></a> res0: scala.xml.Elem = <a><b/>starthi &amp; bye<c/>world<d/>stuffred &amp; black</a> ```
* | Merge commit '32f520f' into merge/2.11-to-2.12-apr-1Lukas Rytz2015-04-012-2/+3
|\|
| * Removed warningsEECOLOR2015-03-262-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Added `since` to deprecation statement - Added unit to parameter list - Removed usage of deprecated method polyType - Replaced deprecated `debugwarn` with `devWarning` - Changed switch statement to if else in order to remove a warning - Switched implementation of `init` and `processOptions` to prevent warning - Replaced deprecated `Console.readLine` with `scala.io.StdIn.readLine` - Replaced deprecated `startOrPoint` with `start` - Replaced deprecated `tpe_=` with `setType` - Replaced deprecated `typeCheck` with `typecheck` - Replaced deprecated `CompilationUnit.warning` with `typer.context.warning` - Replaced deprecated `scala.tools.nsc.util.ScalaClassLoader` with `scala.reflect.internal.util.ScalaClassLoader` - Replaced deprecated `scala.tools.ListOfNil` with `scala.reflect.internal.util.ListOfNil` - Replaced deprecated `scala.tools.utils.ScalaClassLoader` with `scala.reflect.internal.util.ScalaClassLoader` - Replaced deprecated `emptyValDef` with `noSelfType` - In `BoxesRunTime` removed unused method and commented out unused values. Did not delete to keep a reference to the values. If they are deleted people might wonder why `1` and `2` are not used. - Replaced deprecated `scala.tools.nsc.util.AbstractFileClassLoader` with `scala.reflect.internal.util.AbstractFileClassLoader`
* | SI-8918 Unary ids are plain idsSom Snytt2015-02-081-5/+17
|/ | | | | | | | Allow +,-,!,~ to be used as unprefixed identifiers. As prefix operators, they must be followed by a simple expression, so otherwise, consume the id itself as the start of a simple expression.
* SI-5154 Parse leading literal brace in XML patternSom Snytt2014-12-161-4/+3
| | | | | | | Don't consume literal brace as Scala pattern. Previously, leading space would let the text parser `xText` handle it correctly instead.
* Merge pull request #4182 from som-snytt/issue/multizeroAdriaan Moors2014-12-091-119/+73
|\ | | | | SI-9015 Reject 0x and minor parser cleanup
| * SI-9015 Reject 0x and minor parser cleanupSom Snytt2014-12-051-119/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Only print error results. Show deprecated forms. Test for rejected literals and clean up parser There was no negative test for what constitutes a legal literal. The ultimate goal is for the test to report all errors in one compilation. This commit follows up the removal of "1." syntax to simplify number parsing. It removes previous paulp code to contain the erstwhile complexity. Leading zero is not immediately put to the buffer. Instead, the empty buffer is handled on evaluation. In particular, an empty buffer due to `0x` is a syntax error. The message for obsolete octal syntax is nuanced and deferred until evaluation by the parser, which is slightly simpler to reason about. Improve comment on usage of base The slice-and-dicey usage of base deserves a better comment. The difference is that `intVal` sees an empty char buffer for input `"0"`.
* | Merge pull request #4185 from som-snytt/issue/9027Grzegorz Kossakowski2014-12-041-4/+3
|\ \ | |/ |/| SI-9027 Parser no longer consumes space after multi XML elements
| * SI-9027 Parser eagerly consumes space on multi XML elementsSom Snytt2014-12-031-4/+3
| | | | | | | | | | | | Once the parser starts looking for more <elements>, it should still lookahead speculatively, leaving any remaining whitespace, including newlines, after the last element.
* | Merge pull request #4123 from retronym/ticket/8253Jason Zaugg2014-11-201-1/+2
|\ \ | |/ |/| SI-8253 Fix incorrect parsing of <elem xmlns={f("a")}/>
| * SI-8253 Fix incorrect parsing of <elem xmlns={f("a")}/>Jason Zaugg2014-11-101-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The spliced application was placed in the `attrMap` in `SymbolicXMLBuilder` and later incorrectly matched by a pattern intended only to match: xml.Text(s) That attribute value is generated by parsing: <elem xmlns='a'/> So the net effect was that the two fragments of XML were identical! This commit sharpens up the match to really look for a syntactic `_root_.scala.xml.Text("...")`. The test just prints the parse trees of a variety of cases, as we we should not test the modularized XML library in scala/scala.
* | SI-6856 Fix incorrect EBNF in comment in ParsersJason Zaugg2014-11-071-1/+1
|/ | | | '&' isn't a prefix operator, perhaps to the chagrin of the C crowd.
* SI-8459 fix incorrect positions for incomplete selection treesghik2014-09-171-1/+1
| | | | | | The mentioned issue is a presentation compiler issue, but its root cause is a bug in the parser which incorrectly assigned positions to incomplete selection trees (i.e. selections that lack an indentifier after dot and have some whitespace instead). In detail: for such incomplete selection trees, the "point" of the position should be immediately after the dot but instead was at the start of next token after the dot. For range positions, this caused a pathological situation where the "point" was greater than the "end" of the position. This position is later used by the typechecker during resolution of dynamic calls and causes it to crash. Of course, because a syntactically incorrect code is required for the bug to manifest, it only happens in the presentation compiler.
* Merge pull request #3886 from adriaanm/report-filterGrzegorz Kossakowski2014-08-263-3/+3
|\ | | | | part 2 of the big error reporting refactoring
| * Move more parsing hooks out of reporting.Adriaan Moors2014-07-173-3/+3
| | | | | | | | | | | | Create a trait Parsing, which, like Reporting, factors our functionality from Global (aka. "the cake"), that is related to global aspects of configuring parsing.
* | SI-6476 Unitize ALL the procedures!Som Snytt2014-07-192-27/+26
| |
* | SI-6476 Unitize procedures, readabilitySom Snytt2014-07-192-28/+24
| | | | | | | | | | | | | | | | Strictly trivial updates for readability. I used to prefer procedure syntax, but since it was scheduled for removal, I can't scan a def without an equals sign.
* | SI-6476 DocumentationSom Snytt2014-07-181-0/+2
|/ | | | And adjust the test.
* Rip out reporting indirection from CompilationUnitAdriaan Moors2014-07-043-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Inline the forwarders from CompilationUnit, which should not affect behavior. Since all forwarders lead to global.reporter, don't first navigate to a compilation unit, only to then forward back to global.reporter. The cleanup in the previous commits revealed a ton of confusion regarding how to report an error. This was a mechanical search/replace, which has low potential for messing things up, since the list of available methods are disjoint between `reporter` and `currentRun.reporting`. The changes involving `typer.context` were done previously. Essentially, there are three ways to report: - via typer.context, so that reporting can be silenced (buffered) - via global.currentRun.reporting, which summarizes (e.g., deprecation) - via global.reporter, which is (mostly) stateless and straightforward. Ideally, these should all just go through `global.currentRun.reporting`, with the typing context changing that reporter to buffer where necessary. After the refactor, these are the ways in which we report (outside of typer): - reporter.comment - reporter.echo - reporter.error - reporter.warning - currentRun.reporting.deprecationWarning - currentRun.reporting.incompleteHandled - currentRun.reporting.incompleteInputError - currentRun.reporting.inlinerWarning - currentRun.reporting.uncheckedWarning Before: - c.cunit.error - c.enclosingUnit.deprecationWarning - context.unit.error - context.unit.warning - csymCompUnit.warning - cunit.error - cunit.warning - currentClass.cunit.warning - currentIClazz.cunit.inlinerWarning - currentRun.currentUnit.error - currentRun.reporting - currentUnit.deprecationWarning - currentUnit.error - currentUnit.warning - getContext.unit.warning - getCurrentCUnit.error - global.currentUnit.uncheckedWarning - global.currentUnit.warning - global.reporter - icls.cunit.warning - item.cunit.warning - reporter.comment - reporter.echo - reporter.error - reporter.warning - reporting.deprecationWarning - reporting.incompleteHandled - reporting.incompleteInputError - reporting.inlinerWarning - reporting.uncheckedWarning - typer.context.unit.warning - unit.deprecationWarning - unit.echo - unit.error - unit.incompleteHandled - unit.incompleteInputError - unit.uncheckedWarning - unit.warning - v1.cunit.warning All these methods ended up calling a method on `global.reporter` or on `global.currentRun.reporting` (their interfaces are disjoint). Also clean up `TypeDiagnostics`: inline nearly-single-use private methods.
* Move reporting logic into Reporting traitAdriaan Moors2014-07-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Move code from Global/SymbolTable to separate Reporting traits to start carving out an interface in scala.reflect.internal.Reporting, with internals in scala.tools.nsc. Reporting is mixed into the cake. It contains a nested class PerRunReporting. Should do the same for debugging/logging. The idea is that CompilationUnit and Global forward all reporting to Reporter. The Reporting trait contains these forwarders, and PerRunReporting, which accumulates warning state during a run. In the process, I slightly changed the behavior of `globalError` in reflect.internal.SymbolTable: it used to abort, weirdly. I assume that was dummy behavior to avoid introducing an abstract method. It's immediately overridden in Global, and I couldn't find any other subclasses, so I don't think the behavior in SymbolTable was ever observed. Provide necessary hooks for scala.reflect.macros.Parsers#parse. See scala/reflect/macros/contexts/Parsers.scala's parse method, which overrides the reporter to detect when parsing goes wrong. This should be refactored, but that goes beyond the scope of this PR. Don't pop empty macro context stack. (Ran into this while reworking -Xfatal-warnings logic.) Fix -Xfatal-warnings behavior (and check files): it wasn't meant to influence warning reporting, except for emitting one final error; if necessary to fail the compile (when warnings but no errors were reported). Warnings should stay warnings. This was refactored in fbbbb22946, but we soon seem to have relapsed. An hour of gitfu did not lead to where it went wrong. Must've been a merge.
* SI-8325 Accept infix star type outside patternsSom Snytt2014-05-051-9/+21
| | | | | | | | | | | | | | | This is a follow-up to SI-5702 which enabled use of `*` in infix notation in patterns. Most of the work is in distinguishing infix from a sequence pattern. Also, do not take backticked star as the repeated parameter marker in postfix position. That is, `Int``*``` is not `Int*` -- I hope double-tick renders as tick. There is not a special use case except that backticks mean "I am an identifier, as is, and not a keyword."
* SI-8333 can't use modifiers if class is in a blockDenys Shabalin2014-02-281-4/+4
| | | | | | Was caused by the ordering of parser cases. Need to check for definition first due to the fact that modifiers unquote looks like identifier from parser point of view.
* Merge remote-tracking branch 'origin/master' into topic/palladium0Eugene Burmako2014-02-162-7/+6
|\ | | | | | | | | | | | | | | Conflicts: src/compiler/scala/reflect/macros/compiler/Resolvers.scala src/compiler/scala/reflect/macros/contexts/Typers.scala src/compiler/scala/tools/reflect/ToolBoxFactory.scala src/reflect/scala/reflect/api/BuildUtils.scala
| * Merge pull request #3455 from densh/topic/patdefEugene Burmako2014-02-162-1/+3
| |\ | | | | | | Fix SI-8202 and improve support for splicing patterns into vals
| | * SI-8202 bug compatibility with SI-8211 for quasiquotesDenys Shabalin2014-02-092-1/+3
| | |
| * | SI-7711 Do not emit extra argv in script bodySom Snytt2014-02-141-6/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Take away `argv` and make `args` the standard parameter name. This is a quick fix to avoid "unused local" lint error. All the examples use `args`; in particular, "Step 4. Write some Scala scripts" in "Programming in Scala" uses `args`. I see the footnote there is also where Odersky concatenation is specified, `"Hello, "+ args(0) +"!"` with no space next to the literals. Also removes `argv` from `StdNames`. Was torn whether just to add `argc`. Maybe start a new project to house Names, emeritus.
* | | disambiguates uses of “local” in internal symbol APIEugene Burmako2014-02-121-1/+1
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There’s been a conflation of two distinct meanings of the word “local” in the internal symbol API: the first meaning being “local to this” (as in has the LOCAL flag set), the second meaning being “local to block” (as in declared in a block, i.e. having owner being a term symbol). Especially confusing is the fact that sym.isLocal isn’t the same as sym.hasFlag(LOCAL), which has led to now fixed SI-6733. This commit fixes the semantic mess by deprecating both Symbol.isLocal and Symbol.hasLocalFlag (that we were forced to use, because Symbol.isLocal had already been taken), and replacing them with Symbol.isLocalToThis and Symbol.isLocalToBlock. Unfortunately, we can’t remove the deprecated methods right away, because they are used in SBT, so I had to take small steps.
* / SI-8226 Deduplicate Scala's Tokens and JavaTokensSimon Ochsenreither2014-02-102-108/+154
|/
* Merge pull request #3424 from som-snytt/issue/7322Adriaan Moors2014-02-011-1/+1
|\ | | | | SI-7322 Interpolator idents must be encoded
| * SI-7322 Interpolator idents must be encodedSom Snytt2014-01-291-1/+1
| | | | | | | | | | | | | | | | | | | | Otherwise, they are not found. This matters for term names with a differential encoding. Footnote, normally ident() encodes, but INTERPOLATIONID is !isIdent, so that is not used here. Maybe that would be the better improvement.
* | Merge pull request #3374 from densh/si/6844-8076Jason Zaugg2014-01-291-53/+52
|\ \ | | | | | | SI-6844 SI-8076 improve handling of function parameters in quasiquotes
| * | SI-6844 restrict splicing in parameter positionDenys Shabalin2014-01-161-53/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously were a bit too permissive on how splicing in function parameter position worked. This made confusing things like possible: val x = TermName(“x”) q”def foo($x)” Now you can either splice trees in that position (ValDefs) or you have to provide type if you splice a name.
* | | Merge pull request #3402 from densh/si/7275Eugene Burmako2014-01-291-1/+1
|\ \ \ | | | | | | | | SI-7275 allow flattening of blocks with ..$
| * | | Addresses feedback from JasonDenys Shabalin2014-01-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. Adds tests for new synthetic unit stripping. 2. Marks implementation-specific parts of Holes as private. 3. Trims description of iterated method a bit. 4. Provides a bit more clear wrapper for q interpolator. 5. Refactors SyntacticBlock, adds documentation. 6. Makes q"{ ..$Nil }" return q"" to be consist with extractor.
* | | | SI-8182 Avert crash due to type args in patternSom Snytt2014-01-272-3/+9
| |_|/ |/| | | | | | | | | | | Error out type args on binary op after emitting error. Let the parse limp into the whirring blades.
* | | SI-7919 Newline after empty string interpSom Snytt2014-01-241-2/+5
|/ / | | | | | | | | Consume the newline non-raw for safe handling after single-line interpolation.
* | Merge commit '97b9b2c06a' from 2.10.x into masterAdriaan Moors2014-01-172-5/+6
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | Check files updated: test/files/presentation/t8085*.check Conflicts: build.xml src/compiler/scala/tools/nsc/ast/parser/Parsers.scala src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala
| * | Revert "SI-6426, importable _."Adriaan Moors2013-12-102-6/+6
| | | | | | | | | | | | | | | | | | | | | This reverts commit d2316df920ffa4804fe51e8f8780240c46efa982. We can't make `_` an illegal identifier -- it's legal in Java, so we must be able to name these Java underscores.
* | | Merge pull request #3283 from paulp/pr/dotless-targsAdriaan Moors2014-01-172-11/+23
|\ \ \ | |_|/ |/| | Dotless type application for infix operators.
| * | Dotless type application for infix operators.Paul Phillips2013-12-172-11/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When you have an aesthetic expresion like def f(xs: Iterator[Int]) = ( xs takeWhile (_ < 1000) map (_ * -1) filter (_ % 2 == 0) flatMap (x => List(x, x)) reduceOption (_ + _) maxBy (_.toString) ) And then for whatever reason you have to perform explicit type application in the midst of that expression, it's aggravating in the extreme that it has (had) to be rewritten in its entirety to accommodate that change. So now you can perform type application in the middle of it. For reasons not entirely clear to me postfix operators are excluded. The discussion as well as the approval for the infix variation of it can be found at: https://groups.google.com/forum/#!msg/scala-language/eJl1wnkEz9M/hR984-lqC5EJ
* | | Merge pull request #3285 from som-snytt/issue/8015-FF-NLsAdriaan Moors2014-01-151-3/+3
|\ \ \ | | | | | | | | Count lines by EOLs