1
0
mirror of https://github.com/robertkrimen/otto synced 2025-10-12 20:27:30 +08:00
Commit Graph

52 Commits

Author SHA1 Message Date
Tomoki Yamaguchi
11288b7564
fix: positions of statements (#506)
Fix the positions of various statements:
* Fix Idx1 of BranchStatement so that it points to the character after the label if Label exists,
  or the one after Token if Label does not exist.
* Fix Idx1 of LabelledStatement so that it points to the character after the statement.
* Fix Idx1 of ReturnStatement so that it points to the character after the argument if
  Argument exists, or the one after return keyword if Argument does not exist.
* Set Idx0 of SwitchStatement and fix Idx1 of SwitchStatement so that it points to the
  character after the right brace.
* Fix Idx0 of ThrowStatement to point to the start of throw keyword and fix Idx1 of
  ThrowStatement so that it points to the next character after Argument.
* Fix Idx1 of TryStatement to point to the character after Finally if Finally exists, or after Catch
  if Finally does not exist.
* Set Idx0 of WithStatement which was not previously set.
* Set WhileStatement.While so that Idx0 points to the right place.
* Set Idx0 of DoWhileStatement and fix Idx1 to point to the next character after the right
  parenthesis.
2023-07-25 18:25:01 +01:00
Tomoki Yamaguchi
589611c3ae
fix: positions of expressions (#505)
Fix Idx1 of ConditionalExpression so that it points to the next character after alternate expression.
Fix Idx1 of SequenceExpression to return Idx1 of the last sequence element, not first.
Fix Idx0 of unary expression to point to the start of operand in case of a postfix operator.
Fix Idx1 of VariableExpression so that it points to the character right after the name literal if the
expression does not have an initializer.
2023-07-21 22:47:33 +01:00
Tomoki Yamaguchi
d2ed0a776e
fix: Idx1 of ObjectLiteral and ArrayLiteral (#504)
Fix Idx1 of ObjectLiteral  so that it points to the character immediately after the right brace.

Fix Idx1 of ArrayLiteral so that it points to the character immediately after the right bracket.
2023-07-20 20:54:28 +01:00
Tomoki Yamaguchi
03572093ec
fix: starting positions of for and for-in statements (#503)
Fix Idx0 of ForStatement and ForInStatement to point to the right place which were previously not set.
2023-07-18 10:42:59 +01:00
Tomoki Yamaguchi
f70d418ad2
fix: starting position of if statement (#501)
Fix IfStatement Idx0 to point to the right place. I was pointing to the right parenthesis
after the test expression.
2023-07-17 22:27:09 +01:00
Steven Hartland
ea8bcc30d6
ci: fix lint failures (#502)
Fix lint failures introduced by new 1.53 linters
* Remove naked returns
* Accept times using local time where intended
* Allow unused parameter for now on call method
* Disable depguard which just seems to be noise

Also:
* Correct typo so we use the specified golangci-lint version in CI.
2023-07-16 19:17:11 +01:00
Steven Hartland
5d81e9e02d
chore: rename _parser (#483)
Rename _parser -> parser missed in previous refactor.
2022-12-07 00:23:10 +00:00
Steven Hartland
233dfa4ef0
chore: remove perl, make and local docs. (#476)
Remove the dependencies on perl and make.

inline.pl is replaced by tools/gen-jscore and token/tokenfmt is replaced
by tools/gen-tokens which are both golang text/template utilities.

gen-jscore uses property ordering that matches chromes output ordering
adding missing properties to the Error types.

Local generated documentation have been removed as https://pkg.go.dev/
is more feature rich.

The use of make has been removed as the functionality is now replicated by
standard golang tools go test ./... and go generate ./... as well as integrated
into github actions.
2022-12-05 22:19:34 +00:00
Steven Hartland
026a1d9a9c
chore: lint and naming refactor (#475)
Enable more linters, address the issues and do a major naming refactor
to use golang lower camelCase identifiers for types, functions, methods
and variable names.

Also: 
* Clean up inline generation so it doesn't rely on temporary variables.
* Remove unused functions generated by inline.pl.
2022-12-04 21:49:38 +00:00
Steven Hartland
a5b0adea00
Allow semicolon in nested do-while statements. (#463)
In nested do-while statements, a semicolon after the inner `while` threw
a parsing error. This change checks for the optional semicolon.

Co-authored-by: Brian Graham <bcgraham+github@gmail.com>
2022-11-28 11:25:15 +00:00
Steven Hartland
a3b51c68f2
chore: enable whitespace linter and fix errors (#456)
Enable the whitespace linter and fix the errors resulting from it.

Also:
* Remove unneeded golangci-lint config for disabled linters.
* Correct test number for panic in previous commit.
2022-11-26 13:33:09 +00:00
Steven Hartland
7009038f79
fix: linting errors (#441)
Disable new linters which aren't compatible with this code module.

Upgrade github actions to fix caching issues.

Run go mod to bring in new styling.

Remove space on nolint declarations.

Apply all changes to whitespace as required to pass goimports linter.

Only trigger checks on pull_request which works for pulls from other
forks, where as push only works from the same repo.
2022-10-08 00:12:19 +01:00
Iskander (Alex) Sharipov
edceeed7a9
fix: remove commented-out code (#323)
Remove old commented out code that was found using:
https://go-critic.github.io/overview.html#commentedOutCode-ref
2021-09-27 16:31:07 +01:00
Steven Hartland
9297a9abe4
feat: add github action tests and linting (#418)
Leverage github actions for tests and linting.

This includes fixing a bunch of issues highlighted by golangci
including:
* Dead code.
* Ineffectual assigns.
* Goto warnings.
* Nil return err.
* Reused literal strings.
* Test parameter order.

Also:
* Setup clog.
2021-09-27 16:19:28 +01:00
carterjones
6c383dd335 fix whitespace issues (#297) 2018-03-05 04:20:45 +00:00
Steven Hartland
58e9cfdd5d
Revert "Update sourcemaps to v2 (#293)" (#296)
This reverts commit 67b2826a26.
2018-03-03 15:22:00 +00:00
Eric Reis Figueiredo
67b2826a26 Update sourcemaps to v2 (#293)
Update sourcemaps to gopkg.in/sourcemap.v2 in order to avoid possible golang error discussed in #291
2018-03-03 10:15:14 +00:00
Tao Wen
3b44b4dcb6 fix idx of throw and if (#286)
* fix idx of throw and if

* add test to cover if/throw statement idx
2017-11-30 10:32:05 +00:00
Wael Nasreddine
bc4cd51799 ast: ThisExpression.Idx1() should point to the end of this (#251) 2017-06-02 10:04:14 +01:00
Tyler Sommer
9c716adcc8 Replaced './terst' relative import with qualified name. 2017-03-07 11:15:29 -07:00
deoxxa
99d478d5e8 add support for inline source maps 2016-05-08 21:17:26 +10:00
deoxxa
bd5fb254e3 add source map support
This patch implements source map support in the parser, the runtime, the
script record, and the stack trace printing.

The library used to parse and use the source maps is gopkg.in/sourcemap.v1.
Unlike earlier versions of this patch, the consumer of otto does not need
parse the source map on their own - it's now handled similarly to parsing
JavaScript content.

To use a source map, the consumer must explicitly parse their source into
a `Script` object with `Otto.CompileWithSourceMap`. The script record
returned from that call will carry source map information with it, and
all location-related functions should reflect the original source
positions.
2016-05-02 19:34:04 +10:00
Conrad Pankoff
b283580aea Merge pull request #164 from wolfgarnet/commentmapv2
Commentmapv2
2016-04-25 16:16:03 +10:00
Amjad Masad
cb833c2321 Expose Parser Interface with a Scan method 2016-04-24 23:01:26 -07:00
wolfgarnet
ab433a4a50 Improved comment map
* More precise
* Line break special cases supported
* Less intrusive
2016-02-22 15:16:41 +01:00
wolfgarnet
3b2178bf55 Added FunctionStatement 2016-02-19 13:14:42 +01:00
Christian Wolfgang
d65b096ff3 [#148] Fixed style in lexer 2016-01-17 20:08:44 +01:00
wolfgarnet
54a2be367f [#148] Fixed style 2016-01-12 12:13:04 +01:00
wolfgarnet
9f65b62899 [#148] Grouped statements 2016-01-12 11:14:02 +01:00
wolfgarnet
c356c94888 [#148] Do not make context switch if not necessary 2016-01-12 11:02:09 +01:00
wolfgarnet
8cd2f8fd93 [#148] Added test parser to set mode 2016-01-12 10:17:29 +01:00
wolfgarnet
3903251f9a [#148] Updated lexer unit tests 2016-01-12 10:16:25 +01:00
wolfgarnet
6d8bdc96fd [#148] Added mode to store comments 2016-01-12 10:15:49 +01:00
wolfgarnet
fa2636115f Added parser benchmark 2016-01-11 14:07:31 +01:00
wolfgarnet
f304d96c25 [#148] Including disabled tests 2016-01-11 09:22:15 +01:00
wolfgarnet
09ad467104 [#148] Lower cased errors 2016-01-11 09:20:14 +01:00
wolfgarnet
36da11f822 [#148] Removed temporary comment variables 2016-01-11 09:16:46 +01:00
wolfgarnet
fc505844b4 [#148] Removed superfluous lines 2016-01-11 09:15:29 +01:00
wolfgarnet
6cd63e968f [#148] Added empty expressions instead of nil
Instead of having nils for empty array elements, empty expressions are used.
This will add support for comments for empty array elements.
2016-01-04 11:06:22 +01:00
wolfgarnet
af88758381 [#148] Storing comments to a commentmap 2015-12-17 13:50:33 +01:00
Conrad Pankoff
89a9f14981 Merge pull request #139 from deoxxa/fix-bracket-parsing-with-new
fix parsing of statements like `new a["b"]`
2015-12-03 08:43:55 +11:00
Conrad Pankoff
81e59b239e Merge pull request #129 from zupa-hu/patch-3
Fix missing filename in compile-time error
2015-12-01 15:14:13 +11:00
deoxxa
33ac8bd28a fix parsing of statements like new a["b"] 2015-11-02 16:13:03 +11:00
zupa
8a2b09b14d Fix missing filename in compile-time error 2015-06-26 18:46:52 +01:00
Dmitry Panov
1e5ee63535 Fixed stacktrace positions. 2015-04-01 21:03:24 +01:00
Robert Krimen
e6768252c2 Improve error reporting
* Delay entering global scope on code evaluation, not runtime creation

This fixes #66
2014-06-12 21:27:32 -07:00
Robert Krimen
470b8c3b73 terst
* Update to latest github.com/robertkrimen/terst
* Clean up testing
2014-04-25 22:48:25 -07:00
Robert Krimen
bf7b16f4a3 Add internal compilation step
* Streamline what we get from "otto/parser"
* Get rid of some "otto/parser" cruft
* FunctionExpression => FunctionLiteral
* The debugger statement (debugger) should do nothing (not panic)
* Fix aspects of function expression call evaluation
2014-04-19 14:05:51 -07:00
Robert Krimen
8aca2c886a Disable script marshalling/unmarshalling for now 2014-04-15 18:34:24 -07:00
Robert Krimen
ddca88af9b Add compilation (Script, vm.Compile, etc.) 2014-04-13 15:04:32 -07:00