/
githubmirror
/
oppia
ОбзорДокументацияВойти
/
githubmirror
/
oppia
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
ДокументацияПоддержка
Политика конфиденциальностиПользовательское соглашениеПолитика использования «cookies»Согласие субъекта персональных данных
2026 ©
oppia/
.../templates/expressions/
..
README.txt

Fix #6369: Simplify directory structure (#8693)

6 лет назад
expression-evaluator.service.spec.ts

Fix #9311 - Use TestBed.inject instead of TestBed.get (#24729)

6 месяцев назад
expression-evaluator.service.ts

Fix #7092: Remove downgradeComponent (#21903)

год назад
expression-interpolation.service.spec.ts

Fix #9311 - Use TestBed.inject instead of TestBed.get (#24729)

6 месяцев назад
expression-interpolation.service.ts

Fix #7716: Migrated filters to pipe (#21956)

год назад
expression-parser.service.spec.ts

Apply prettier 2 (#19862)

2 года назад
expression-parser.service.ts

Fix #7092: Remove downgradeComponent (#21903)

год назад
expression-syntax-tree.service.spec.ts

Fix #9311 - Use TestBed.inject instead of TestBed.get (#24729)

6 месяцев назад
expression-syntax-tree.service.ts

Fix part of #22082: Migrate ng-class to ngClass (#22166)

год назад
parser.js

Fix #6369: Simplify directory structure (#8693)

6 лет назад
parser.pegjs

Fix #6369: Simplify directory structure (#8693)

6 лет назад
README.txt
This directory contains files that are necessary to make expressions work.
Expressions can be evaluated at runtime (i.e. when playing an Oppia exploration)
and can reference parameters and system variables to produce textual output
(e.g. used in a message presented to users) as well as boolean results which
may be used to control state transitions.
Example string expressions:
- "Hello " + userName + "!"
- "The answer is " + (x + y * z) + "."
Example boolean expressions:
- answer == "yes"
- loopCounter > 100
 
See comments in parser.pegjs for the description of input expression grammar.
Also see parser.pegjs for the parser output (i.e. parse tree) data format.
See ExpressionEvaluatorService.js for the operator contracts.
 
Files:
parser.pegjs
This is the parser definition which is used to generate the expression-parser.service.js file
that will be used at runtime to parse user-entered expressions.
expression-parser.service.js
This is the JavaScript parser file produced by PEGJS and the input file
parser.pegjs.
ExpressionEvaluatorService.js
Implementation of the expression evaluator. Includes the evaluation engine
as well as the system operators.
ExpressionParserServiceSpec.js
Tests for the parser.
ExpressionEvaluatorServiceSpec.js
Tests for the evaluator.
 
How to update the parser:
1. Modify parser.pegjs.
2. Add tests in test.js for the new or modified grammar.
3. Run
 
python -m scripts.create_expression_parser
 
which updates expression-parser.service.js. Then run the frontend unit tests using
 
python -m scripts.run_frontend_tests
 
to ensure that the new grammar passes the tests in ExpressionParserServiceSpec.js and
ExpressionEvaluatorServiceSpec.js.
4. Repeat 1-3 until the desired grammar is written and tested.
5. Check the changes. You need to check in parser.pegjs as well as expression-parser.service.js
(and probably ExpressionParserServiceSpec.js and ExpressionEvaluatorServiceSpec.js).