parselly 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +56 -9
- data/Rakefile +10 -0
- data/lib/parselly/lexer.rb +278 -68
- data/lib/parselly/node.rb +434 -205
- data/lib/parselly/parser.rb +799 -325
- data/lib/parselly/version.rb +1 -1
- data/lib/parselly.rb +57 -10
- data/parser.y +454 -101
- metadata +3 -3
data/lib/parselly/parser.rb
CHANGED
|
@@ -656,52 +656,125 @@ end
|
|
|
656
656
|
require 'set'
|
|
657
657
|
|
|
658
658
|
# Pre-computed sets for faster lookup
|
|
659
|
-
CAN_END_COMPOUND = Set[:IDENT, :STAR, :RPAREN, :RBRACKET].freeze
|
|
659
|
+
CAN_END_COMPOUND = Set[:IDENT, :STAR, :RPAREN, :RBRACKET, :NUMBER].freeze
|
|
660
660
|
CAN_START_COMPOUND = Set[:IDENT, :STAR, :DOT, :HASH, :LBRACKET, :COLON].freeze
|
|
661
|
-
TYPE_SELECTOR_TYPES = Set[:IDENT, :STAR].freeze
|
|
662
|
-
SUBCLASS_SELECTOR_TYPES = Set[:DOT, :HASH, :LBRACKET, :COLON].freeze
|
|
663
|
-
SUBCLASS_SELECTOR_END_TYPES = Set[:IDENT, :RBRACKET, :RPAREN].freeze
|
|
664
661
|
NTH_PSEUDO_NAMES = Set['nth-child', 'nth-last-child', 'nth-of-type', 'nth-last-of-type', 'nth-col', 'nth-last-col'].freeze
|
|
665
|
-
AN_PLUS_B_REGEX = /^(even|odd|[+-]?\d*n(?:[+-]\d+)?|[+-]?n(?:[+-]\d+)?|\d+)
|
|
662
|
+
AN_PLUS_B_REGEX = /^(even|odd|[+-]?\d*n(?:[+-]\d+)?|[+-]?n(?:[+-]\d+)?|\d+)$/i.freeze
|
|
663
|
+
SELECTOR_LIST_PSEUDO_NAMES = Set['is', 'where', 'not'].freeze
|
|
664
|
+
RELATIVE_SELECTOR_LIST_PSEUDO_NAMES = Set['has'].freeze
|
|
665
|
+
LEGACY_PSEUDO_ELEMENT_NAMES = Set['before', 'after', 'first-line', 'first-letter'].freeze
|
|
666
|
+
ATTRIBUTE_MODIFIERS = Set['i', 's'].freeze
|
|
666
667
|
|
|
667
668
|
module Parselly
|
|
668
669
|
class Parser < Racc::Parser
|
|
669
670
|
|
|
670
|
-
module_eval(<<'...end parser.y/module_eval...', 'parser.y',
|
|
671
|
-
def parse(input, tolerant: false)
|
|
671
|
+
module_eval(<<'...end parser.y/module_eval...', 'parser.y', 425)
|
|
672
|
+
def parse(input, tolerant: false, max_length: nil, max_tokens: nil, max_depth: nil, freeze: false)
|
|
672
673
|
@tolerant = tolerant
|
|
673
674
|
@errors = []
|
|
674
675
|
@error_index = nil
|
|
675
676
|
@suppress_errors = false
|
|
677
|
+
@max_depth = max_depth
|
|
678
|
+
@freeze_tree = freeze
|
|
679
|
+
|
|
680
|
+
unless input.is_a?(String)
|
|
681
|
+
error = parse_error('Input must be a String', { line: 1, column: 1, offset: 0 })
|
|
682
|
+
return Parselly::ParseResult.new(nil, [error]) if tolerant
|
|
683
|
+
|
|
684
|
+
raise Parselly::ParseError, error
|
|
685
|
+
end
|
|
686
|
+
|
|
687
|
+
if max_length && input.length > max_length
|
|
688
|
+
error = parse_error("Input exceeds max_length #{max_length}", { line: 1, column: 1, offset: 0 })
|
|
689
|
+
return Parselly::ParseResult.new(nil, [error]) if tolerant
|
|
690
|
+
|
|
691
|
+
raise Parselly::ParseError, error
|
|
692
|
+
end
|
|
693
|
+
|
|
676
694
|
@lexer = Parselly::Lexer.new(input)
|
|
677
695
|
begin
|
|
678
696
|
@tokens = @lexer.tokenize
|
|
679
|
-
rescue RuntimeError => e
|
|
697
|
+
rescue Parselly::ParseError, RuntimeError => e
|
|
680
698
|
if tolerant
|
|
681
699
|
@errors << parse_error_from_exception(e)
|
|
682
700
|
return Parselly::ParseResult.new(nil, @errors)
|
|
683
701
|
end
|
|
684
702
|
raise
|
|
685
703
|
end
|
|
704
|
+
|
|
705
|
+
if max_tokens && @tokens.size > max_tokens
|
|
706
|
+
error = parse_error("Input exceeds max_tokens #{max_tokens}", @tokens[max_tokens][2])
|
|
707
|
+
return Parselly::ParseResult.new(nil, [error]) if tolerant
|
|
708
|
+
|
|
709
|
+
raise Parselly::ParseError, error
|
|
710
|
+
end
|
|
711
|
+
|
|
686
712
|
preprocess_tokens!
|
|
687
713
|
@index = 0
|
|
688
714
|
@current_position = { line: 1, column: 1, offset: 0 }
|
|
689
715
|
|
|
690
716
|
if tolerant
|
|
691
717
|
ast = parse_with_recovery
|
|
692
|
-
|
|
718
|
+
ast = validate_or_recover_tolerant_ast(ast) if ast
|
|
719
|
+
ast.freeze_tree if ast && @freeze_tree
|
|
693
720
|
return Parselly::ParseResult.new(ast, @errors)
|
|
694
721
|
end
|
|
695
722
|
|
|
696
723
|
ast = do_parse
|
|
697
|
-
|
|
724
|
+
finalize_ast(ast)
|
|
725
|
+
ast.freeze_tree if @freeze_tree
|
|
698
726
|
ast
|
|
699
727
|
end
|
|
700
728
|
|
|
701
729
|
def parse_with_recovery
|
|
702
730
|
do_parse
|
|
703
731
|
rescue Parselly::ParseError, RuntimeError
|
|
704
|
-
parse_partial_ast
|
|
732
|
+
parse_selector_list_recovery || parse_partial_ast
|
|
733
|
+
end
|
|
734
|
+
|
|
735
|
+
def validate_or_recover_tolerant_ast(ast)
|
|
736
|
+
finalize_ast(ast)
|
|
737
|
+
ast
|
|
738
|
+
rescue Parselly::ParseError => e
|
|
739
|
+
@errors << parse_error_from_exception(e)
|
|
740
|
+
parse_selector_list_recovery(validate: true) || ast
|
|
741
|
+
end
|
|
742
|
+
|
|
743
|
+
def parse_selector_list_recovery(validate: false)
|
|
744
|
+
return nil unless @tokens && @tokens.any? { |token| token[0] == :COMMA }
|
|
745
|
+
|
|
746
|
+
eof_token = @tokens.last if @tokens.last && @tokens.last[0] == false
|
|
747
|
+
body_tokens = eof_token ? @tokens[0...-1] : @tokens
|
|
748
|
+
segments = []
|
|
749
|
+
current = []
|
|
750
|
+
|
|
751
|
+
body_tokens.each do |token|
|
|
752
|
+
if token[0] == :COMMA
|
|
753
|
+
segments << current
|
|
754
|
+
current = []
|
|
755
|
+
else
|
|
756
|
+
current << token
|
|
757
|
+
end
|
|
758
|
+
end
|
|
759
|
+
segments << current
|
|
760
|
+
|
|
761
|
+
result = Node.new(:selector_list, nil, body_tokens.first&.[](2) || { line: 1, column: 1, offset: 0 })
|
|
762
|
+
recovered = false
|
|
763
|
+
|
|
764
|
+
segments.each do |segment|
|
|
765
|
+
next if segment.empty?
|
|
766
|
+
|
|
767
|
+
begin
|
|
768
|
+
parsed = parse_from_tokens(segment + [eof_token || [false, nil, segment.last[2]]], suppress_errors: true)
|
|
769
|
+
finalize_ast(parsed) if validate
|
|
770
|
+
result.add_child(parsed)
|
|
771
|
+
recovered = true
|
|
772
|
+
rescue Parselly::ParseError, RuntimeError
|
|
773
|
+
next
|
|
774
|
+
end
|
|
775
|
+
end
|
|
776
|
+
|
|
777
|
+
recovered ? result : nil
|
|
705
778
|
end
|
|
706
779
|
|
|
707
780
|
def parse_partial_ast
|
|
@@ -735,6 +808,8 @@ ensure
|
|
|
735
808
|
end
|
|
736
809
|
|
|
737
810
|
def parse_error_from_exception(error)
|
|
811
|
+
return error.error if error.respond_to?(:error)
|
|
812
|
+
|
|
738
813
|
line = nil
|
|
739
814
|
column = nil
|
|
740
815
|
offset = nil
|
|
@@ -748,17 +823,61 @@ def parse_error_from_exception(error)
|
|
|
748
823
|
{ message: error.message, line: line, column: column, offset: offset }
|
|
749
824
|
end
|
|
750
825
|
|
|
751
|
-
def
|
|
826
|
+
def parse_error(message, position)
|
|
827
|
+
{
|
|
828
|
+
message: message,
|
|
829
|
+
line: position[:line],
|
|
830
|
+
column: position[:column],
|
|
831
|
+
offset: position[:offset]
|
|
832
|
+
}.tap do |error|
|
|
833
|
+
error[:end_line] = position[:end_line] if position.key?(:end_line)
|
|
834
|
+
error[:end_column] = position[:end_column] if position.key?(:end_column)
|
|
835
|
+
error[:end_offset] = position[:end_offset] if position.key?(:end_offset)
|
|
836
|
+
end
|
|
837
|
+
end
|
|
838
|
+
|
|
839
|
+
def token_value(token)
|
|
752
840
|
token.respond_to?(:value) ? token.value : token
|
|
753
841
|
end
|
|
754
842
|
|
|
755
|
-
def
|
|
756
|
-
token.respond_to?(:raw) ? token.raw : token
|
|
843
|
+
def token_raw(token)
|
|
844
|
+
token.respond_to?(:raw) ? token.raw : token_value(token)
|
|
845
|
+
end
|
|
846
|
+
|
|
847
|
+
def token_position(token)
|
|
848
|
+
token.respond_to?(:position) && token.position ? token.position : @current_position
|
|
849
|
+
end
|
|
850
|
+
|
|
851
|
+
def token_quote(token)
|
|
852
|
+
token.respond_to?(:quote) ? token.quote : nil
|
|
853
|
+
end
|
|
854
|
+
|
|
855
|
+
def pseudo_name(name)
|
|
856
|
+
name.to_s.downcase
|
|
857
|
+
end
|
|
858
|
+
|
|
859
|
+
def attribute_modifier_value(token)
|
|
860
|
+
modifier = token_value(token).to_s
|
|
861
|
+
normalized_modifier = modifier.downcase
|
|
862
|
+
return normalized_modifier if ATTRIBUTE_MODIFIERS.include?(normalized_modifier)
|
|
863
|
+
|
|
864
|
+
raise_syntax_error("Parse error: invalid attribute modifier '#{modifier}'", token_position(token))
|
|
865
|
+
end
|
|
866
|
+
|
|
867
|
+
def raise_syntax_error(message, position)
|
|
868
|
+
error = parse_error(message, position)
|
|
869
|
+
if @tolerant
|
|
870
|
+
@errors << error unless @suppress_errors
|
|
871
|
+
@error_index ||= [@index - 1, 0].max
|
|
872
|
+
end
|
|
873
|
+
raise Parselly::SyntaxError, error
|
|
757
874
|
end
|
|
758
875
|
|
|
759
876
|
def preprocess_tokens!
|
|
760
877
|
return if @tokens.size <= 1
|
|
761
878
|
|
|
879
|
+
mark_nth_of_tokens!
|
|
880
|
+
|
|
762
881
|
new_tokens = Array.new(@tokens.size + (@tokens.size / 2)) # Pre-allocate with conservative estimate
|
|
763
882
|
new_tokens_idx = 0
|
|
764
883
|
|
|
@@ -770,7 +889,7 @@ def preprocess_tokens!
|
|
|
770
889
|
if i < last_idx
|
|
771
890
|
next_token = @tokens[i + 1]
|
|
772
891
|
if needs_descendant?(token, next_token)
|
|
773
|
-
pos =
|
|
892
|
+
pos = next_token[2]
|
|
774
893
|
new_tokens[new_tokens_idx] = [:DESCENDANT, ' ', pos]
|
|
775
894
|
new_tokens_idx += 1
|
|
776
895
|
end
|
|
@@ -780,38 +899,129 @@ def preprocess_tokens!
|
|
|
780
899
|
@tokens = new_tokens.first(new_tokens_idx)
|
|
781
900
|
end
|
|
782
901
|
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
902
|
+
def mark_nth_of_tokens!
|
|
903
|
+
paren_depth = 0
|
|
904
|
+
last_idx = @tokens.size - 1
|
|
905
|
+
|
|
906
|
+
@tokens.each_with_index do |token, index|
|
|
907
|
+
case token[0]
|
|
908
|
+
when :LPAREN
|
|
909
|
+
paren_depth += 1
|
|
910
|
+
when :RPAREN
|
|
911
|
+
paren_depth -= 1 if paren_depth.positive?
|
|
912
|
+
when :IDENT
|
|
913
|
+
next unless paren_depth.positive?
|
|
914
|
+
next unless token_value(token[1]) == 'of'
|
|
915
|
+
next if index.zero? || index >= last_idx
|
|
916
|
+
|
|
917
|
+
previous_token = @tokens[index - 1]
|
|
918
|
+
next_token = @tokens[index + 1]
|
|
919
|
+
if token_gap?(previous_token, token) && token_gap?(token, next_token) &&
|
|
920
|
+
CAN_START_COMPOUND.include?(next_token[0])
|
|
921
|
+
token[0] = :OF
|
|
922
|
+
end
|
|
923
|
+
end
|
|
924
|
+
end
|
|
925
|
+
end
|
|
926
|
+
|
|
927
|
+
# Insert DESCENDANT combinator only when actual ignored input
|
|
928
|
+
# (CSS whitespace or comments) separated two compound selector tokens.
|
|
788
929
|
def needs_descendant?(current, next_tok)
|
|
789
930
|
current_type = current[0]
|
|
790
931
|
next_type = next_tok[0]
|
|
791
932
|
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
933
|
+
CAN_END_COMPOUND.include?(current_type) &&
|
|
934
|
+
CAN_START_COMPOUND.include?(next_type) &&
|
|
935
|
+
token_gap?(current, next_tok)
|
|
936
|
+
end
|
|
937
|
+
|
|
938
|
+
def token_gap?(current, next_tok)
|
|
939
|
+
current_end = current[2][:end_offset] || current[2][:offset]
|
|
940
|
+
next_tok[2][:offset] > current_end
|
|
941
|
+
end
|
|
798
942
|
|
|
799
|
-
|
|
943
|
+
def finalize_ast(node)
|
|
944
|
+
validate_known_pseudo_functions!(node)
|
|
945
|
+
validate_max_depth!(node) if @max_depth
|
|
800
946
|
end
|
|
801
947
|
|
|
802
|
-
def
|
|
948
|
+
def validate_known_pseudo_functions!(node)
|
|
803
949
|
return unless node.respond_to?(:children) && node.children
|
|
804
950
|
|
|
805
|
-
if node.type == :pseudo_function
|
|
806
|
-
|
|
807
|
-
if
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
951
|
+
if node.type == :pseudo_function
|
|
952
|
+
name = pseudo_name(node.value)
|
|
953
|
+
validate_nth_pseudo!(node) if NTH_PSEUDO_NAMES.include?(name)
|
|
954
|
+
validate_selector_list_pseudo!(node) if SELECTOR_LIST_PSEUDO_NAMES.include?(name)
|
|
955
|
+
validate_relative_selector_list_pseudo!(node) if RELATIVE_SELECTOR_LIST_PSEUDO_NAMES.include?(name)
|
|
956
|
+
end
|
|
957
|
+
|
|
958
|
+
node.children.compact.each { |child| validate_known_pseudo_functions!(child) }
|
|
959
|
+
end
|
|
960
|
+
|
|
961
|
+
def validate_nth_pseudo!(node)
|
|
962
|
+
child = node.children.first
|
|
963
|
+
return if child&.type == :an_plus_b
|
|
964
|
+
return if child&.type == :nth_selector_argument
|
|
965
|
+
|
|
966
|
+
raise Parselly::SyntaxError, parse_error(
|
|
967
|
+
"Parse error: invalid argument for :#{node.value}()",
|
|
968
|
+
child&.position || node.position
|
|
969
|
+
)
|
|
970
|
+
end
|
|
971
|
+
|
|
972
|
+
def validate_selector_list_pseudo!(node)
|
|
973
|
+
child = node.children.first
|
|
974
|
+
return if child&.type == :selector_list && !relative_selector_list?(child)
|
|
975
|
+
|
|
976
|
+
raise Parselly::SyntaxError, parse_error(
|
|
977
|
+
"Parse error: invalid argument for :#{node.value}()",
|
|
978
|
+
child&.position || node.position
|
|
979
|
+
)
|
|
980
|
+
end
|
|
981
|
+
|
|
982
|
+
def validate_relative_selector_list_pseudo!(node)
|
|
983
|
+
child = node.children.first
|
|
984
|
+
return if child&.type == :selector_list
|
|
985
|
+
|
|
986
|
+
raise Parselly::SyntaxError, parse_error(
|
|
987
|
+
"Parse error: invalid argument for :#{node.value}()",
|
|
988
|
+
child&.position || node.position
|
|
989
|
+
)
|
|
990
|
+
end
|
|
991
|
+
|
|
992
|
+
def relative_selector_list?(node)
|
|
993
|
+
node.type == :selector_list &&
|
|
994
|
+
node.children.any? { |child| relative_selector?(child) }
|
|
995
|
+
end
|
|
996
|
+
|
|
997
|
+
def relative_selector?(node)
|
|
998
|
+
node.type == :selector && node.children.first &&
|
|
999
|
+
node.children.first.type.to_s.end_with?('_combinator')
|
|
1000
|
+
end
|
|
1001
|
+
|
|
1002
|
+
def validate_max_depth!(node)
|
|
1003
|
+
stack = [[node, 1]]
|
|
1004
|
+
|
|
1005
|
+
until stack.empty?
|
|
1006
|
+
current, depth = stack.pop
|
|
1007
|
+
if depth > @max_depth
|
|
1008
|
+
raise Parselly::ParseError, parse_error(
|
|
1009
|
+
"Input exceeds max_depth #{@max_depth}",
|
|
1010
|
+
current.position
|
|
1011
|
+
)
|
|
812
1012
|
end
|
|
1013
|
+
current.children.each { |child| stack << [child, depth + 1] }
|
|
813
1014
|
end
|
|
814
|
-
|
|
1015
|
+
end
|
|
1016
|
+
|
|
1017
|
+
def normalize_pseudo_argument(name, argument)
|
|
1018
|
+
return argument unless NTH_PSEUDO_NAMES.include?(pseudo_name(name))
|
|
1019
|
+
return argument unless argument&.type == :selector_list
|
|
1020
|
+
|
|
1021
|
+
an_plus_b_value = extract_an_plus_b_value(argument)
|
|
1022
|
+
return argument unless an_plus_b_value
|
|
1023
|
+
|
|
1024
|
+
Node.new(:an_plus_b, an_plus_b_value, argument.position, raw_value: an_plus_b_value)
|
|
815
1025
|
end
|
|
816
1026
|
|
|
817
1027
|
def extract_an_plus_b_value(selector_list_node)
|
|
@@ -834,205 +1044,248 @@ def next_token
|
|
|
834
1044
|
@index += 1
|
|
835
1045
|
@current_position = token_position
|
|
836
1046
|
|
|
837
|
-
[token_type, token_value]
|
|
1047
|
+
[token_type, parser_token_value(token_value, token_position)]
|
|
1048
|
+
end
|
|
1049
|
+
|
|
1050
|
+
def parser_token_value(value, position)
|
|
1051
|
+
if value.respond_to?(:position)
|
|
1052
|
+
value.position ||= position if value.respond_to?(:position=)
|
|
1053
|
+
return value
|
|
1054
|
+
end
|
|
1055
|
+
|
|
1056
|
+
Parselly::Lexer::TokenValue.new(value: value, raw: value, position: position)
|
|
838
1057
|
end
|
|
839
1058
|
|
|
840
1059
|
def on_error(token_id, val, vstack)
|
|
841
1060
|
token_name = token_to_str(token_id) || '?'
|
|
842
1061
|
pos = @current_position || { line: '?', column: '?' }
|
|
843
|
-
error
|
|
844
|
-
message: "Parse error: unexpected #{token_name} '#{val}' at #{pos[:line]}:#{pos[:column]}",
|
|
845
|
-
line: pos[:line],
|
|
846
|
-
column: pos[:column],
|
|
847
|
-
offset: pos[:offset]
|
|
848
|
-
}
|
|
849
|
-
if @tolerant
|
|
850
|
-
@errors << error unless @suppress_errors
|
|
851
|
-
@error_index ||= [@index - 1, 0].max
|
|
852
|
-
raise Parselly::ParseError, error
|
|
853
|
-
end
|
|
854
|
-
raise error[:message]
|
|
1062
|
+
raise_syntax_error("Parse error: unexpected #{token_name} '#{token_value(val)}' at #{pos[:line]}:#{pos[:column]}", pos)
|
|
855
1063
|
end
|
|
856
1064
|
...end parser.y/module_eval...
|
|
857
1065
|
##### State transition tables begin ###
|
|
858
1066
|
|
|
859
1067
|
racc_action_table = [
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
7,
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
1068
|
+
7, 19, 41, 20, 106, 15, 16, 8, 17, 42,
|
|
1069
|
+
7, 44, 18, -62, 107, 15, 16, 8, 17, 109,
|
|
1070
|
+
36, 34, 18, 45, 90, 7, 9, 37, 43, 110,
|
|
1071
|
+
15, 16, 8, 17, 91, 34, 9, 18, 75, 78,
|
|
1072
|
+
35, 82, 52, 15, 16, 8, 17, 116, 38, 53,
|
|
1073
|
+
18, 9, 26, 27, 28, 29, 30, 117, 71, 70,
|
|
1074
|
+
7, 72, 54, 83, 9, 15, 16, 8, 17, 55,
|
|
1075
|
+
39, 46, 18, 75, 78, 20, 82, 64, 15, 16,
|
|
1076
|
+
8, 17, 65, 66, 67, 18, 9, 26, 27, 28,
|
|
1077
|
+
29, 30, 68, 96, 73, 7, 95, 74, 83, 9,
|
|
1078
|
+
15, 16, 8, 17, 87, 89, 92, 18, -61, 26,
|
|
1079
|
+
27, 28, 29, 30, 93, 94, 97, 7, 102, 103,
|
|
1080
|
+
104, 9, 15, 16, 8, 17, 56, 108, 97, 18,
|
|
1081
|
+
113, 26, 27, 28, 29, 30, 58, 59, 60, 61,
|
|
1082
|
+
62, 63, 114, 9, 15, 16, 115, 17, 118, 15,
|
|
1083
|
+
16, 18, 17, 119, 120, 121, 18, 26, 27, 28,
|
|
1084
|
+
29, 30, 26, 27, 28, 29, 30 ]
|
|
873
1085
|
|
|
874
1086
|
racc_action_check = [
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
1087
|
+
0, 1, 17, 2, 94, 0, 0, 0, 0, 17,
|
|
1088
|
+
20, 18, 0, 75, 94, 20, 20, 20, 20, 96,
|
|
1089
|
+
9, 7, 20, 18, 75, 23, 0, 9, 17, 96,
|
|
1090
|
+
23, 23, 23, 23, 75, 75, 20, 23, 67, 67,
|
|
1091
|
+
8, 67, 34, 67, 67, 67, 67, 108, 15, 34,
|
|
1092
|
+
67, 23, 67, 67, 67, 67, 67, 108, 57, 57,
|
|
1093
|
+
86, 57, 35, 67, 67, 86, 86, 86, 86, 35,
|
|
1094
|
+
16, 19, 86, 87, 87, 21, 87, 41, 87, 87,
|
|
1095
|
+
87, 87, 42, 43, 44, 87, 86, 87, 87, 87,
|
|
1096
|
+
87, 87, 45, 83, 64, 93, 83, 65, 87, 87,
|
|
1097
|
+
93, 93, 93, 93, 68, 69, 76, 93, 79, 93,
|
|
1098
|
+
93, 93, 93, 93, 81, 82, 84, 97, 88, 90,
|
|
1099
|
+
91, 93, 97, 97, 97, 97, 40, 95, 98, 97,
|
|
1100
|
+
101, 97, 97, 97, 97, 97, 40, 40, 40, 40,
|
|
1101
|
+
40, 40, 106, 97, 4, 4, 107, 4, 109, 32,
|
|
1102
|
+
32, 4, 32, 110, 116, 117, 32, 3, 3, 3,
|
|
1103
|
+
3, 3, 24, 24, 24, 24, 24 ]
|
|
888
1104
|
|
|
889
1105
|
racc_action_pointer = [
|
|
890
|
-
|
|
891
|
-
nil, nil, nil, nil,
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
nil, nil, nil,
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
1106
|
+
-2, 1, -12, 141, 137, nil, nil, -7, 12, 18,
|
|
1107
|
+
nil, nil, nil, nil, nil, 46, 68, 0, 9, 71,
|
|
1108
|
+
8, 60, nil, 23, 146, nil, nil, nil, nil, nil,
|
|
1109
|
+
nil, nil, 142, nil, 40, 60, nil, nil, nil, nil,
|
|
1110
|
+
115, 49, 54, 81, 72, 90, nil, nil, nil, nil,
|
|
1111
|
+
nil, nil, nil, nil, nil, nil, nil, 56, nil, nil,
|
|
1112
|
+
nil, nil, nil, nil, 92, 95, nil, 36, 92, 103,
|
|
1113
|
+
nil, nil, nil, nil, nil, 7, 93, nil, nil, 102,
|
|
1114
|
+
nil, 108, 113, 91, 101, nil, 58, 71, 107, nil,
|
|
1115
|
+
114, 115, nil, 93, -13, 125, 2, 115, 113, nil,
|
|
1116
|
+
nil, 117, nil, nil, nil, nil, 137, 141, 30, 143,
|
|
1117
|
+
148, nil, nil, nil, nil, nil, 149, 150, nil, nil,
|
|
1118
|
+
nil, nil ]
|
|
900
1119
|
|
|
901
1120
|
racc_action_default = [
|
|
902
|
-
-
|
|
903
|
-
-
|
|
904
|
-
-2, -4, -
|
|
905
|
-
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
-
|
|
909
|
-
-
|
|
910
|
-
-
|
|
911
|
-
-
|
|
1121
|
+
-81, -81, -2, -6, -17, -15, -16, -20, -21, -81,
|
|
1122
|
+
-28, -29, -30, -31, -32, -81, -81, -81, -81, -81,
|
|
1123
|
+
-81, -2, -4, -81, -6, -8, -9, -10, -11, -12,
|
|
1124
|
+
-13, -14, -17, -19, -81, -81, -24, -27, -33, -34,
|
|
1125
|
+
-81, -37, -81, -81, -52, -81, 122, -1, -3, -5,
|
|
1126
|
+
-7, -18, -22, -25, -23, -26, -35, -81, -41, -42,
|
|
1127
|
+
-43, -44, -45, -46, -81, -81, -40, -81, -54, -50,
|
|
1128
|
+
-47, -48, -49, -38, -39, -20, -81, -56, -57, -58,
|
|
1129
|
+
-59, -81, -74, -81, -76, -79, -81, -81, -81, -51,
|
|
1130
|
+
-81, -81, -53, -81, -65, -81, -73, -81, -76, -78,
|
|
1131
|
+
-80, -81, -36, -66, -67, -60, -81, -81, -70, -81,
|
|
1132
|
+
-81, -75, -77, -55, -63, -64, -81, -81, -71, -72,
|
|
1133
|
+
-68, -69 ]
|
|
912
1134
|
|
|
913
1135
|
racc_goto_table = [
|
|
914
|
-
2,
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
nil,
|
|
1136
|
+
2, 32, 33, 23, 25, 99, 76, 1, 22, 49,
|
|
1137
|
+
31, 40, 57, 69, 88, 105, 111, nil, nil, 112,
|
|
1138
|
+
47, nil, nil, nil, 23, 50, 101, 48, nil, 32,
|
|
1139
|
+
51, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
|
918
1140
|
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
|
919
|
-
nil, nil, nil, nil,
|
|
1141
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
|
1142
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
|
1143
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
|
1144
|
+
nil, nil, nil, nil, nil, nil, 100 ]
|
|
920
1145
|
|
|
921
1146
|
racc_goto_check = [
|
|
922
|
-
2,
|
|
923
|
-
10, 19,
|
|
924
|
-
|
|
925
|
-
nil,
|
|
1147
|
+
2, 12, 13, 6, 8, 30, 23, 1, 4, 5,
|
|
1148
|
+
10, 19, 20, 21, 22, 26, 28, nil, nil, 30,
|
|
1149
|
+
2, nil, nil, nil, 6, 8, 23, 4, nil, 12,
|
|
1150
|
+
13, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
|
1151
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
|
926
1152
|
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
|
927
|
-
nil, nil, nil, nil,
|
|
1153
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
|
1154
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
|
1155
|
+
nil, nil, nil, nil, nil, nil, 2 ]
|
|
928
1156
|
|
|
929
1157
|
racc_goto_pointer = [
|
|
930
|
-
nil, 7, 0, nil,
|
|
931
|
-
6, nil, -
|
|
932
|
-
-
|
|
1158
|
+
nil, 7, 0, nil, 6, -14, 0, nil, 1, nil,
|
|
1159
|
+
6, nil, -3, -2, nil, nil, nil, nil, nil, -6,
|
|
1160
|
+
-28, -44, -55, -61, nil, nil, -78, nil, -81, nil,
|
|
1161
|
+
-79 ]
|
|
933
1162
|
|
|
934
1163
|
racc_goto_default = [
|
|
935
|
-
nil, nil,
|
|
936
|
-
nil, 5, 6, nil,
|
|
937
|
-
nil,
|
|
1164
|
+
nil, nil, 85, 21, nil, 3, 86, 24, nil, 4,
|
|
1165
|
+
nil, 5, 6, nil, 10, 11, 12, 13, 14, nil,
|
|
1166
|
+
nil, nil, nil, nil, 77, 79, 80, 81, 84, 98,
|
|
1167
|
+
nil ]
|
|
938
1168
|
|
|
939
1169
|
racc_reduce_table = [
|
|
940
1170
|
0, 0, :racc_error,
|
|
941
|
-
2,
|
|
942
|
-
0,
|
|
943
|
-
2,
|
|
944
|
-
2,
|
|
945
|
-
2,
|
|
946
|
-
0,
|
|
947
|
-
2,
|
|
948
|
-
2,
|
|
949
|
-
1,
|
|
950
|
-
1,
|
|
951
|
-
1,
|
|
952
|
-
1,
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
1,
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
1,
|
|
960
|
-
1,
|
|
961
|
-
1,
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
1171
|
+
2, 33, :_reduce_1,
|
|
1172
|
+
0, 34, :_reduce_2,
|
|
1173
|
+
2, 34, :_reduce_3,
|
|
1174
|
+
2, 31, :_reduce_4,
|
|
1175
|
+
2, 37, :_reduce_5,
|
|
1176
|
+
0, 38, :_reduce_6,
|
|
1177
|
+
2, 38, :_reduce_7,
|
|
1178
|
+
2, 32, :_reduce_8,
|
|
1179
|
+
1, 36, :_reduce_9,
|
|
1180
|
+
1, 36, :_reduce_10,
|
|
1181
|
+
1, 36, :_reduce_11,
|
|
1182
|
+
1, 36, :_reduce_12,
|
|
1183
|
+
1, 36, :_reduce_13,
|
|
1184
|
+
2, 35, :_reduce_14,
|
|
1185
|
+
1, 39, :_reduce_15,
|
|
1186
|
+
1, 39, :_reduce_16,
|
|
1187
|
+
0, 43, :_reduce_17,
|
|
1188
|
+
2, 43, :_reduce_18,
|
|
1189
|
+
1, 40, :_reduce_19,
|
|
1190
|
+
1, 41, :_reduce_20,
|
|
1191
|
+
1, 41, :_reduce_21,
|
|
1192
|
+
3, 41, :_reduce_22,
|
|
1193
|
+
3, 41, :_reduce_23,
|
|
1194
|
+
2, 41, :_reduce_24,
|
|
1195
|
+
3, 41, :_reduce_25,
|
|
1196
|
+
3, 41, :_reduce_26,
|
|
967
1197
|
2, 41, :_reduce_27,
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
1,
|
|
972
|
-
1,
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
1,
|
|
982
|
-
1,
|
|
983
|
-
1,
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1198
|
+
1, 42, :_reduce_28,
|
|
1199
|
+
1, 42, :_reduce_29,
|
|
1200
|
+
1, 42, :_reduce_30,
|
|
1201
|
+
1, 42, :_reduce_31,
|
|
1202
|
+
1, 42, :_reduce_32,
|
|
1203
|
+
2, 44, :_reduce_33,
|
|
1204
|
+
2, 45, :_reduce_34,
|
|
1205
|
+
3, 46, :_reduce_35,
|
|
1206
|
+
6, 46, :_reduce_36,
|
|
1207
|
+
1, 49, :_reduce_37,
|
|
1208
|
+
3, 49, :_reduce_38,
|
|
1209
|
+
3, 49, :_reduce_39,
|
|
1210
|
+
2, 49, :_reduce_40,
|
|
1211
|
+
1, 50, :_reduce_41,
|
|
1212
|
+
1, 50, :_reduce_42,
|
|
1213
|
+
1, 50, :_reduce_43,
|
|
1214
|
+
1, 50, :_reduce_44,
|
|
1215
|
+
1, 50, :_reduce_45,
|
|
1216
|
+
1, 50, :_reduce_46,
|
|
1217
|
+
1, 51, :_reduce_47,
|
|
1218
|
+
1, 51, :_reduce_48,
|
|
1219
|
+
1, 51, :_reduce_49,
|
|
1220
|
+
0, 52, :_reduce_50,
|
|
1221
|
+
1, 52, :_reduce_51,
|
|
1222
|
+
2, 47, :_reduce_52,
|
|
1223
|
+
5, 47, :_reduce_53,
|
|
1224
|
+
3, 48, :_reduce_54,
|
|
1225
|
+
6, 48, :_reduce_55,
|
|
1226
|
+
1, 53, :_reduce_56,
|
|
1227
|
+
1, 53, :_reduce_57,
|
|
1228
|
+
1, 53, :_reduce_58,
|
|
1229
|
+
1, 53, :_reduce_59,
|
|
1230
|
+
3, 54, :_reduce_60,
|
|
1231
|
+
1, 57, :_reduce_61,
|
|
1232
|
+
1, 57, :_reduce_62,
|
|
1233
|
+
4, 55, :_reduce_63,
|
|
1234
|
+
4, 55, :_reduce_64,
|
|
1235
|
+
2, 55, :_reduce_65,
|
|
1236
|
+
3, 55, :_reduce_66,
|
|
1237
|
+
3, 55, :_reduce_67,
|
|
1238
|
+
5, 55, :_reduce_68,
|
|
1239
|
+
5, 55, :_reduce_69,
|
|
1240
|
+
3, 55, :_reduce_70,
|
|
1241
|
+
4, 55, :_reduce_71,
|
|
1242
|
+
4, 55, :_reduce_72,
|
|
1243
|
+
2, 55, :_reduce_73,
|
|
1244
|
+
1, 55, :_reduce_74,
|
|
1245
|
+
2, 59, :_reduce_75,
|
|
1246
|
+
0, 60, :_reduce_76,
|
|
1247
|
+
2, 60, :_reduce_77,
|
|
1248
|
+
2, 56, :_reduce_78,
|
|
1249
|
+
1, 58, :_reduce_79,
|
|
1250
|
+
2, 58, :_reduce_80 ]
|
|
1251
|
+
|
|
1252
|
+
racc_reduce_n = 81
|
|
1253
|
+
|
|
1254
|
+
racc_shift_n = 122
|
|
1006
1255
|
|
|
1007
1256
|
racc_token_table = {
|
|
1008
1257
|
false => 0,
|
|
1009
1258
|
:error => 1,
|
|
1010
1259
|
:IDENT => 2,
|
|
1011
1260
|
:STRING => 3,
|
|
1012
|
-
:
|
|
1013
|
-
:
|
|
1014
|
-
:
|
|
1015
|
-
:
|
|
1016
|
-
:
|
|
1017
|
-
:
|
|
1018
|
-
:
|
|
1019
|
-
:
|
|
1020
|
-
:
|
|
1021
|
-
:
|
|
1022
|
-
:
|
|
1023
|
-
:
|
|
1024
|
-
:
|
|
1025
|
-
:
|
|
1026
|
-
:
|
|
1027
|
-
:
|
|
1028
|
-
:
|
|
1029
|
-
:
|
|
1030
|
-
:
|
|
1031
|
-
:
|
|
1032
|
-
:
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1261
|
+
:BAD_STRING => 4,
|
|
1262
|
+
:NUMBER => 5,
|
|
1263
|
+
:OF => 6,
|
|
1264
|
+
:HASH => 7,
|
|
1265
|
+
:DOT => 8,
|
|
1266
|
+
:STAR => 9,
|
|
1267
|
+
:LBRACKET => 10,
|
|
1268
|
+
:RBRACKET => 11,
|
|
1269
|
+
:LPAREN => 12,
|
|
1270
|
+
:RPAREN => 13,
|
|
1271
|
+
:COLON => 14,
|
|
1272
|
+
:COMMA => 15,
|
|
1273
|
+
:CHILD => 16,
|
|
1274
|
+
:ADJACENT => 17,
|
|
1275
|
+
:SIBLING => 18,
|
|
1276
|
+
:DESCENDANT => 19,
|
|
1277
|
+
:COLUMN => 20,
|
|
1278
|
+
:EQUAL => 21,
|
|
1279
|
+
:INCLUDES => 22,
|
|
1280
|
+
:DASHMATCH => 23,
|
|
1281
|
+
:PREFIXMATCH => 24,
|
|
1282
|
+
:SUFFIXMATCH => 25,
|
|
1283
|
+
:SUBSTRINGMATCH => 26,
|
|
1284
|
+
:MINUS => 27,
|
|
1285
|
+
:PIPE => 28,
|
|
1286
|
+
"-temp-group" => 29 }
|
|
1287
|
+
|
|
1288
|
+
racc_nt_base = 30
|
|
1036
1289
|
|
|
1037
1290
|
racc_use_result_var = true
|
|
1038
1291
|
|
|
@@ -1058,7 +1311,9 @@ Racc_token_to_s_table = [
|
|
|
1058
1311
|
"error",
|
|
1059
1312
|
"IDENT",
|
|
1060
1313
|
"STRING",
|
|
1314
|
+
"BAD_STRING",
|
|
1061
1315
|
"NUMBER",
|
|
1316
|
+
"OF",
|
|
1062
1317
|
"HASH",
|
|
1063
1318
|
"DOT",
|
|
1064
1319
|
"STAR",
|
|
@@ -1072,6 +1327,7 @@ Racc_token_to_s_table = [
|
|
|
1072
1327
|
"ADJACENT",
|
|
1073
1328
|
"SIBLING",
|
|
1074
1329
|
"DESCENDANT",
|
|
1330
|
+
"COLUMN",
|
|
1075
1331
|
"EQUAL",
|
|
1076
1332
|
"INCLUDES",
|
|
1077
1333
|
"DASHMATCH",
|
|
@@ -1079,6 +1335,7 @@ Racc_token_to_s_table = [
|
|
|
1079
1335
|
"SUFFIXMATCH",
|
|
1080
1336
|
"SUBSTRINGMATCH",
|
|
1081
1337
|
"MINUS",
|
|
1338
|
+
"PIPE",
|
|
1082
1339
|
"\"-temp-group\"",
|
|
1083
1340
|
"$start",
|
|
1084
1341
|
"selector_list",
|
|
@@ -1099,10 +1356,15 @@ Racc_token_to_s_table = [
|
|
|
1099
1356
|
"attribute_selector",
|
|
1100
1357
|
"pseudo_class_selector",
|
|
1101
1358
|
"pseudo_element_selector",
|
|
1359
|
+
"attribute_name",
|
|
1102
1360
|
"attr_matcher",
|
|
1361
|
+
"attribute_value",
|
|
1362
|
+
"attr_modifier",
|
|
1103
1363
|
"any_value",
|
|
1364
|
+
"nth_of_value",
|
|
1104
1365
|
"an_plus_b",
|
|
1105
1366
|
"relative_selector_list",
|
|
1367
|
+
"nth_of_an_plus_b",
|
|
1106
1368
|
"relative_selector",
|
|
1107
1369
|
"\"-group@COMMA-relative_selector\"",
|
|
1108
1370
|
"\"-many@-group@COMMA-relative_selector\"" ]
|
|
@@ -1137,7 +1399,7 @@ module_eval(<<'.,.,', 'parser.y', 31)
|
|
|
1137
1399
|
|
|
1138
1400
|
module_eval(<<'.,.,', 'parser.y', 26)
|
|
1139
1401
|
def _reduce_4(val, _values, result)
|
|
1140
|
-
result = Node.new(:selector_list, nil,
|
|
1402
|
+
result = Node.new(:selector_list, nil, val[0].position)
|
|
1141
1403
|
result.add_child(val[0])
|
|
1142
1404
|
val[1].each { |pair| result.add_child(pair[1]) }
|
|
1143
1405
|
|
|
@@ -1187,45 +1449,45 @@ module_eval(<<'.,.,', 'parser.y', 35)
|
|
|
1187
1449
|
|
|
1188
1450
|
module_eval(<<'.,.,', 'parser.y', 52)
|
|
1189
1451
|
def _reduce_9(val, _values, result)
|
|
1190
|
-
result = Node.new(:child_combinator, '>',
|
|
1452
|
+
result = Node.new(:child_combinator, '>', token_position(val[0]))
|
|
1191
1453
|
result
|
|
1192
1454
|
end
|
|
1193
1455
|
.,.,
|
|
1194
1456
|
|
|
1195
1457
|
module_eval(<<'.,.,', 'parser.y', 54)
|
|
1196
1458
|
def _reduce_10(val, _values, result)
|
|
1197
|
-
result = Node.new(:adjacent_combinator, '+',
|
|
1459
|
+
result = Node.new(:adjacent_combinator, '+', token_position(val[0]))
|
|
1198
1460
|
result
|
|
1199
1461
|
end
|
|
1200
1462
|
.,.,
|
|
1201
1463
|
|
|
1202
1464
|
module_eval(<<'.,.,', 'parser.y', 56)
|
|
1203
1465
|
def _reduce_11(val, _values, result)
|
|
1204
|
-
result = Node.new(:sibling_combinator, '~',
|
|
1466
|
+
result = Node.new(:sibling_combinator, '~', token_position(val[0]))
|
|
1205
1467
|
result
|
|
1206
1468
|
end
|
|
1207
1469
|
.,.,
|
|
1208
1470
|
|
|
1209
1471
|
module_eval(<<'.,.,', 'parser.y', 58)
|
|
1210
1472
|
def _reduce_12(val, _values, result)
|
|
1211
|
-
result = Node.new(:descendant_combinator, ' ',
|
|
1473
|
+
result = Node.new(:descendant_combinator, ' ', token_position(val[0]))
|
|
1212
1474
|
result
|
|
1213
1475
|
end
|
|
1214
1476
|
.,.,
|
|
1215
1477
|
|
|
1216
|
-
module_eval(<<'.,.,', 'parser.y',
|
|
1478
|
+
module_eval(<<'.,.,', 'parser.y', 60)
|
|
1217
1479
|
def _reduce_13(val, _values, result)
|
|
1218
|
-
|
|
1219
|
-
result.add_child(val[0])
|
|
1220
|
-
val[1].each { |sel| result.add_child(sel) } unless val[1].empty?
|
|
1221
|
-
|
|
1480
|
+
result = Node.new(:column_combinator, '||', token_position(val[0]))
|
|
1222
1481
|
result
|
|
1223
1482
|
end
|
|
1224
1483
|
.,.,
|
|
1225
1484
|
|
|
1226
|
-
module_eval(<<'.,.,', 'parser.y',
|
|
1485
|
+
module_eval(<<'.,.,', 'parser.y', 66)
|
|
1227
1486
|
def _reduce_14(val, _values, result)
|
|
1228
|
-
|
|
1487
|
+
result = Node.new(:simple_selector_sequence, nil, val[0].position)
|
|
1488
|
+
result.add_child(val[0])
|
|
1489
|
+
val[1].each { |sel| result.add_child(sel) } unless val[1].empty?
|
|
1490
|
+
|
|
1229
1491
|
result
|
|
1230
1492
|
end
|
|
1231
1493
|
.,.,
|
|
@@ -1237,348 +1499,560 @@ module_eval(<<'.,.,', 'parser.y', 74)
|
|
|
1237
1499
|
end
|
|
1238
1500
|
.,.,
|
|
1239
1501
|
|
|
1240
|
-
module_eval(<<'.,.,', 'parser.y',
|
|
1502
|
+
module_eval(<<'.,.,', 'parser.y', 76)
|
|
1241
1503
|
def _reduce_16(val, _values, result)
|
|
1242
|
-
|
|
1504
|
+
result = val[0]
|
|
1243
1505
|
result
|
|
1244
1506
|
end
|
|
1245
1507
|
.,.,
|
|
1246
1508
|
|
|
1247
|
-
module_eval(<<'.,.,', 'parser.y',
|
|
1509
|
+
module_eval(<<'.,.,', 'parser.y', 83)
|
|
1248
1510
|
def _reduce_17(val, _values, result)
|
|
1249
1511
|
result = val[1] ? val[1].unshift(val[0]) : val
|
|
1250
1512
|
result
|
|
1251
1513
|
end
|
|
1252
1514
|
.,.,
|
|
1253
1515
|
|
|
1254
|
-
module_eval(<<'.,.,', 'parser.y',
|
|
1516
|
+
module_eval(<<'.,.,', 'parser.y', 83)
|
|
1255
1517
|
def _reduce_18(val, _values, result)
|
|
1256
|
-
|
|
1518
|
+
result = val[1] ? val[1].unshift(val[0]) : val
|
|
1257
1519
|
result
|
|
1258
1520
|
end
|
|
1259
1521
|
.,.,
|
|
1260
1522
|
|
|
1261
|
-
module_eval(<<'.,.,', 'parser.y',
|
|
1523
|
+
module_eval(<<'.,.,', 'parser.y', 81)
|
|
1262
1524
|
def _reduce_19(val, _values, result)
|
|
1263
|
-
result =
|
|
1525
|
+
result = val[0]
|
|
1264
1526
|
result
|
|
1265
1527
|
end
|
|
1266
1528
|
.,.,
|
|
1267
1529
|
|
|
1268
1530
|
module_eval(<<'.,.,', 'parser.y', 86)
|
|
1269
1531
|
def _reduce_20(val, _values, result)
|
|
1270
|
-
result = Node.new(:
|
|
1532
|
+
result = Node.new(:type_selector, token_value(val[0]), token_position(val[0]), raw_value: token_raw(val[0]))
|
|
1271
1533
|
result
|
|
1272
1534
|
end
|
|
1273
1535
|
.,.,
|
|
1274
1536
|
|
|
1275
|
-
module_eval(<<'.,.,', 'parser.y',
|
|
1537
|
+
module_eval(<<'.,.,', 'parser.y', 88)
|
|
1276
1538
|
def _reduce_21(val, _values, result)
|
|
1277
|
-
result = val[0]
|
|
1539
|
+
result = Node.new(:universal_selector, '*', token_position(val[0]))
|
|
1278
1540
|
result
|
|
1279
1541
|
end
|
|
1280
1542
|
.,.,
|
|
1281
1543
|
|
|
1282
|
-
module_eval(<<'.,.,', 'parser.y',
|
|
1544
|
+
module_eval(<<'.,.,', 'parser.y', 91)
|
|
1283
1545
|
def _reduce_22(val, _values, result)
|
|
1284
|
-
|
|
1546
|
+
result = Node.new(
|
|
1547
|
+
:type_selector,
|
|
1548
|
+
token_value(val[2]),
|
|
1549
|
+
token_position(val[0]),
|
|
1550
|
+
raw_value: "#{token_raw(val[0])}|#{token_raw(val[2])}",
|
|
1551
|
+
namespace: token_value(val[0])
|
|
1552
|
+
)
|
|
1553
|
+
|
|
1285
1554
|
result
|
|
1286
1555
|
end
|
|
1287
1556
|
.,.,
|
|
1288
1557
|
|
|
1289
|
-
module_eval(<<'.,.,', 'parser.y',
|
|
1558
|
+
module_eval(<<'.,.,', 'parser.y', 101)
|
|
1290
1559
|
def _reduce_23(val, _values, result)
|
|
1291
|
-
|
|
1560
|
+
result = Node.new(
|
|
1561
|
+
:type_selector,
|
|
1562
|
+
token_value(val[2]),
|
|
1563
|
+
token_position(val[0]),
|
|
1564
|
+
raw_value: "*|#{token_raw(val[2])}",
|
|
1565
|
+
namespace: '*'
|
|
1566
|
+
)
|
|
1567
|
+
|
|
1292
1568
|
result
|
|
1293
1569
|
end
|
|
1294
1570
|
.,.,
|
|
1295
1571
|
|
|
1296
|
-
module_eval(<<'.,.,', 'parser.y',
|
|
1572
|
+
module_eval(<<'.,.,', 'parser.y', 111)
|
|
1297
1573
|
def _reduce_24(val, _values, result)
|
|
1298
|
-
|
|
1574
|
+
result = Node.new(
|
|
1575
|
+
:type_selector,
|
|
1576
|
+
token_value(val[1]),
|
|
1577
|
+
token_position(val[0]),
|
|
1578
|
+
raw_value: "|#{token_raw(val[1])}",
|
|
1579
|
+
namespace: ''
|
|
1580
|
+
)
|
|
1581
|
+
|
|
1299
1582
|
result
|
|
1300
1583
|
end
|
|
1301
1584
|
.,.,
|
|
1302
1585
|
|
|
1303
|
-
module_eval(<<'.,.,', 'parser.y',
|
|
1586
|
+
module_eval(<<'.,.,', 'parser.y', 121)
|
|
1304
1587
|
def _reduce_25(val, _values, result)
|
|
1305
|
-
|
|
1588
|
+
result = Node.new(
|
|
1589
|
+
:universal_selector,
|
|
1590
|
+
'*',
|
|
1591
|
+
token_position(val[0]),
|
|
1592
|
+
raw_value: "#{token_raw(val[0])}|*",
|
|
1593
|
+
namespace: token_value(val[0])
|
|
1594
|
+
)
|
|
1595
|
+
|
|
1306
1596
|
result
|
|
1307
1597
|
end
|
|
1308
1598
|
.,.,
|
|
1309
1599
|
|
|
1310
|
-
module_eval(<<'.,.,', 'parser.y',
|
|
1600
|
+
module_eval(<<'.,.,', 'parser.y', 131)
|
|
1311
1601
|
def _reduce_26(val, _values, result)
|
|
1312
|
-
|
|
1602
|
+
result = Node.new(
|
|
1603
|
+
:universal_selector,
|
|
1604
|
+
'*',
|
|
1605
|
+
token_position(val[0]),
|
|
1606
|
+
raw_value: '*|*',
|
|
1607
|
+
namespace: '*'
|
|
1608
|
+
)
|
|
1609
|
+
|
|
1313
1610
|
result
|
|
1314
1611
|
end
|
|
1315
1612
|
.,.,
|
|
1316
1613
|
|
|
1317
|
-
module_eval(<<'.,.,', 'parser.y',
|
|
1614
|
+
module_eval(<<'.,.,', 'parser.y', 141)
|
|
1318
1615
|
def _reduce_27(val, _values, result)
|
|
1319
|
-
|
|
1616
|
+
result = Node.new(
|
|
1617
|
+
:universal_selector,
|
|
1618
|
+
'*',
|
|
1619
|
+
token_position(val[0]),
|
|
1620
|
+
raw_value: '|*',
|
|
1621
|
+
namespace: ''
|
|
1622
|
+
)
|
|
1623
|
+
|
|
1320
1624
|
result
|
|
1321
1625
|
end
|
|
1322
1626
|
.,.,
|
|
1323
1627
|
|
|
1324
|
-
module_eval(<<'.,.,', 'parser.y',
|
|
1628
|
+
module_eval(<<'.,.,', 'parser.y', 153)
|
|
1325
1629
|
def _reduce_28(val, _values, result)
|
|
1326
|
-
result =
|
|
1630
|
+
result = val[0]
|
|
1327
1631
|
result
|
|
1328
1632
|
end
|
|
1329
1633
|
.,.,
|
|
1330
1634
|
|
|
1331
|
-
module_eval(<<'.,.,', 'parser.y',
|
|
1635
|
+
module_eval(<<'.,.,', 'parser.y', 155)
|
|
1332
1636
|
def _reduce_29(val, _values, result)
|
|
1333
|
-
|
|
1334
|
-
result.add_child(Node.new(:attribute, identifier_value(val[1]), @current_position, raw_value: identifier_raw(val[1])))
|
|
1335
|
-
result.add_child(val[2])
|
|
1336
|
-
result.add_child(Node.new(:value, val[3], @current_position))
|
|
1337
|
-
|
|
1637
|
+
result = val[0]
|
|
1338
1638
|
result
|
|
1339
1639
|
end
|
|
1340
1640
|
.,.,
|
|
1341
1641
|
|
|
1342
|
-
module_eval(<<'.,.,', 'parser.y',
|
|
1642
|
+
module_eval(<<'.,.,', 'parser.y', 157)
|
|
1343
1643
|
def _reduce_30(val, _values, result)
|
|
1344
|
-
|
|
1345
|
-
result.add_child(Node.new(:attribute, identifier_value(val[1]), @current_position, raw_value: identifier_raw(val[1])))
|
|
1346
|
-
result.add_child(val[2])
|
|
1347
|
-
result.add_child(Node.new(:value, identifier_value(val[3]), @current_position, raw_value: identifier_raw(val[3])))
|
|
1348
|
-
|
|
1644
|
+
result = val[0]
|
|
1349
1645
|
result
|
|
1350
1646
|
end
|
|
1351
1647
|
.,.,
|
|
1352
1648
|
|
|
1353
|
-
module_eval(<<'.,.,', 'parser.y',
|
|
1649
|
+
module_eval(<<'.,.,', 'parser.y', 159)
|
|
1354
1650
|
def _reduce_31(val, _values, result)
|
|
1355
|
-
result =
|
|
1651
|
+
result = val[0]
|
|
1356
1652
|
result
|
|
1357
1653
|
end
|
|
1358
1654
|
.,.,
|
|
1359
1655
|
|
|
1360
|
-
module_eval(<<'.,.,', 'parser.y',
|
|
1656
|
+
module_eval(<<'.,.,', 'parser.y', 161)
|
|
1361
1657
|
def _reduce_32(val, _values, result)
|
|
1362
|
-
result =
|
|
1658
|
+
result = val[0]
|
|
1363
1659
|
result
|
|
1364
1660
|
end
|
|
1365
1661
|
.,.,
|
|
1366
1662
|
|
|
1367
|
-
module_eval(<<'.,.,', 'parser.y',
|
|
1663
|
+
module_eval(<<'.,.,', 'parser.y', 166)
|
|
1368
1664
|
def _reduce_33(val, _values, result)
|
|
1369
|
-
result = Node.new(:
|
|
1665
|
+
result = Node.new(:id_selector, token_value(val[1]), token_position(val[0]), raw_value: token_raw(val[1]))
|
|
1370
1666
|
result
|
|
1371
1667
|
end
|
|
1372
1668
|
.,.,
|
|
1373
1669
|
|
|
1374
|
-
module_eval(<<'.,.,', 'parser.y',
|
|
1670
|
+
module_eval(<<'.,.,', 'parser.y', 171)
|
|
1375
1671
|
def _reduce_34(val, _values, result)
|
|
1376
|
-
result = Node.new(:
|
|
1672
|
+
result = Node.new(:class_selector, token_value(val[1]), token_position(val[0]), raw_value: token_raw(val[1]))
|
|
1377
1673
|
result
|
|
1378
1674
|
end
|
|
1379
1675
|
.,.,
|
|
1380
1676
|
|
|
1381
|
-
module_eval(<<'.,.,', 'parser.y',
|
|
1677
|
+
module_eval(<<'.,.,', 'parser.y', 177)
|
|
1382
1678
|
def _reduce_35(val, _values, result)
|
|
1383
|
-
|
|
1679
|
+
result = Node.new(
|
|
1680
|
+
:attribute_selector,
|
|
1681
|
+
val[1].value,
|
|
1682
|
+
token_position(val[0]),
|
|
1683
|
+
raw_value: val[1].raw_value,
|
|
1684
|
+
namespace: val[1].namespace
|
|
1685
|
+
)
|
|
1686
|
+
|
|
1384
1687
|
result
|
|
1385
1688
|
end
|
|
1386
1689
|
.,.,
|
|
1387
1690
|
|
|
1388
|
-
module_eval(<<'.,.,', 'parser.y',
|
|
1691
|
+
module_eval(<<'.,.,', 'parser.y', 187)
|
|
1389
1692
|
def _reduce_36(val, _values, result)
|
|
1390
|
-
|
|
1693
|
+
result = Node.new(:attribute_selector, nil, token_position(val[0]), modifier: val[4])
|
|
1694
|
+
result.add_child(val[1])
|
|
1695
|
+
result.add_child(val[2])
|
|
1696
|
+
result.add_child(val[3])
|
|
1697
|
+
|
|
1391
1698
|
result
|
|
1392
1699
|
end
|
|
1393
1700
|
.,.,
|
|
1394
1701
|
|
|
1395
|
-
module_eval(<<'.,.,', 'parser.y',
|
|
1702
|
+
module_eval(<<'.,.,', 'parser.y', 197)
|
|
1396
1703
|
def _reduce_37(val, _values, result)
|
|
1397
|
-
|
|
1704
|
+
result = Node.new(:attribute, token_value(val[0]), token_position(val[0]), raw_value: token_raw(val[0]))
|
|
1705
|
+
|
|
1398
1706
|
result
|
|
1399
1707
|
end
|
|
1400
1708
|
.,.,
|
|
1401
1709
|
|
|
1402
|
-
module_eval(<<'.,.,', 'parser.y',
|
|
1710
|
+
module_eval(<<'.,.,', 'parser.y', 201)
|
|
1403
1711
|
def _reduce_38(val, _values, result)
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1712
|
+
result = Node.new(
|
|
1713
|
+
:attribute,
|
|
1714
|
+
token_value(val[2]),
|
|
1715
|
+
token_position(val[0]),
|
|
1716
|
+
raw_value: "#{token_raw(val[0])}|#{token_raw(val[2])}",
|
|
1717
|
+
namespace: token_value(val[0])
|
|
1718
|
+
)
|
|
1407
1719
|
|
|
1408
1720
|
result
|
|
1409
1721
|
end
|
|
1410
1722
|
.,.,
|
|
1411
1723
|
|
|
1412
|
-
module_eval(<<'.,.,', 'parser.y',
|
|
1724
|
+
module_eval(<<'.,.,', 'parser.y', 211)
|
|
1413
1725
|
def _reduce_39(val, _values, result)
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1726
|
+
result = Node.new(
|
|
1727
|
+
:attribute,
|
|
1728
|
+
token_value(val[2]),
|
|
1729
|
+
token_position(val[0]),
|
|
1730
|
+
raw_value: "*|#{token_raw(val[2])}",
|
|
1731
|
+
namespace: '*'
|
|
1732
|
+
)
|
|
1417
1733
|
|
|
1418
1734
|
result
|
|
1419
1735
|
end
|
|
1420
1736
|
.,.,
|
|
1421
1737
|
|
|
1422
|
-
module_eval(<<'.,.,', 'parser.y',
|
|
1738
|
+
module_eval(<<'.,.,', 'parser.y', 221)
|
|
1423
1739
|
def _reduce_40(val, _values, result)
|
|
1424
|
-
|
|
1740
|
+
result = Node.new(
|
|
1741
|
+
:attribute,
|
|
1742
|
+
token_value(val[1]),
|
|
1743
|
+
token_position(val[0]),
|
|
1744
|
+
raw_value: "|#{token_raw(val[1])}",
|
|
1745
|
+
namespace: ''
|
|
1746
|
+
)
|
|
1747
|
+
|
|
1425
1748
|
result
|
|
1426
1749
|
end
|
|
1427
1750
|
.,.,
|
|
1428
1751
|
|
|
1429
|
-
module_eval(<<'.,.,', 'parser.y',
|
|
1752
|
+
module_eval(<<'.,.,', 'parser.y', 233)
|
|
1430
1753
|
def _reduce_41(val, _values, result)
|
|
1431
|
-
result = Node.new(:
|
|
1754
|
+
result = Node.new(:equal_operator, '=', token_position(val[0]))
|
|
1432
1755
|
result
|
|
1433
1756
|
end
|
|
1434
1757
|
.,.,
|
|
1435
1758
|
|
|
1436
|
-
module_eval(<<'.,.,', 'parser.y',
|
|
1759
|
+
module_eval(<<'.,.,', 'parser.y', 235)
|
|
1437
1760
|
def _reduce_42(val, _values, result)
|
|
1438
|
-
result = val[0]
|
|
1761
|
+
result = Node.new(:includes_operator, '~=', token_position(val[0]))
|
|
1439
1762
|
result
|
|
1440
1763
|
end
|
|
1441
1764
|
.,.,
|
|
1442
1765
|
|
|
1443
|
-
module_eval(<<'.,.,', 'parser.y',
|
|
1766
|
+
module_eval(<<'.,.,', 'parser.y', 237)
|
|
1444
1767
|
def _reduce_43(val, _values, result)
|
|
1445
|
-
result = val[0]
|
|
1768
|
+
result = Node.new(:dashmatch_operator, '|=', token_position(val[0]))
|
|
1446
1769
|
result
|
|
1447
1770
|
end
|
|
1448
1771
|
.,.,
|
|
1449
1772
|
|
|
1450
|
-
module_eval(<<'.,.,', 'parser.y',
|
|
1773
|
+
module_eval(<<'.,.,', 'parser.y', 239)
|
|
1451
1774
|
def _reduce_44(val, _values, result)
|
|
1775
|
+
result = Node.new(:prefixmatch_operator, '^=', token_position(val[0]))
|
|
1776
|
+
result
|
|
1777
|
+
end
|
|
1778
|
+
.,.,
|
|
1779
|
+
|
|
1780
|
+
module_eval(<<'.,.,', 'parser.y', 241)
|
|
1781
|
+
def _reduce_45(val, _values, result)
|
|
1782
|
+
result = Node.new(:suffixmatch_operator, '$=', token_position(val[0]))
|
|
1783
|
+
result
|
|
1784
|
+
end
|
|
1785
|
+
.,.,
|
|
1786
|
+
|
|
1787
|
+
module_eval(<<'.,.,', 'parser.y', 243)
|
|
1788
|
+
def _reduce_46(val, _values, result)
|
|
1789
|
+
result = Node.new(:substringmatch_operator, '*=', token_position(val[0]))
|
|
1790
|
+
result
|
|
1791
|
+
end
|
|
1792
|
+
.,.,
|
|
1793
|
+
|
|
1794
|
+
module_eval(<<'.,.,', 'parser.y', 248)
|
|
1795
|
+
def _reduce_47(val, _values, result)
|
|
1796
|
+
result = Node.new(:value, token_value(val[0]), token_position(val[0]), raw_value: token_raw(val[0]), quote: token_quote(val[0]))
|
|
1797
|
+
result
|
|
1798
|
+
end
|
|
1799
|
+
.,.,
|
|
1800
|
+
|
|
1801
|
+
module_eval(<<'.,.,', 'parser.y', 250)
|
|
1802
|
+
def _reduce_48(val, _values, result)
|
|
1803
|
+
result = Node.new(:value, token_value(val[0]), token_position(val[0]), raw_value: token_raw(val[0]))
|
|
1804
|
+
result
|
|
1805
|
+
end
|
|
1806
|
+
.,.,
|
|
1807
|
+
|
|
1808
|
+
module_eval(<<'.,.,', 'parser.y', 252)
|
|
1809
|
+
def _reduce_49(val, _values, result)
|
|
1810
|
+
result = Node.new(:value, token_value(val[0]), token_position(val[0]), raw_value: token_raw(val[0]))
|
|
1811
|
+
result
|
|
1812
|
+
end
|
|
1813
|
+
.,.,
|
|
1814
|
+
|
|
1815
|
+
module_eval(<<'.,.,', 'parser.y', 257)
|
|
1816
|
+
def _reduce_50(val, _values, result)
|
|
1817
|
+
result = nil
|
|
1818
|
+
result
|
|
1819
|
+
end
|
|
1820
|
+
.,.,
|
|
1821
|
+
|
|
1822
|
+
module_eval(<<'.,.,', 'parser.y', 259)
|
|
1823
|
+
def _reduce_51(val, _values, result)
|
|
1824
|
+
result = attribute_modifier_value(val[0])
|
|
1825
|
+
result
|
|
1826
|
+
end
|
|
1827
|
+
.,.,
|
|
1828
|
+
|
|
1829
|
+
module_eval(<<'.,.,', 'parser.y', 265)
|
|
1830
|
+
def _reduce_52(val, _values, result)
|
|
1831
|
+
name = token_value(val[1])
|
|
1832
|
+
node_type = LEGACY_PSEUDO_ELEMENT_NAMES.include?(pseudo_name(name)) ? :pseudo_element : :pseudo_class
|
|
1833
|
+
result = Node.new(node_type, name, token_position(val[0]), raw_value: token_raw(val[1]), prefix: ':')
|
|
1834
|
+
|
|
1835
|
+
result
|
|
1836
|
+
end
|
|
1837
|
+
.,.,
|
|
1838
|
+
|
|
1839
|
+
module_eval(<<'.,.,', 'parser.y', 271)
|
|
1840
|
+
def _reduce_53(val, _values, result)
|
|
1841
|
+
fn = Node.new(:pseudo_function, token_value(val[1]), token_position(val[0]), raw_value: token_raw(val[1]), prefix: ':')
|
|
1842
|
+
fn.add_child(normalize_pseudo_argument(fn.value, val[3]))
|
|
1843
|
+
result = fn
|
|
1844
|
+
|
|
1845
|
+
result
|
|
1846
|
+
end
|
|
1847
|
+
.,.,
|
|
1848
|
+
|
|
1849
|
+
module_eval(<<'.,.,', 'parser.y', 279)
|
|
1850
|
+
def _reduce_54(val, _values, result)
|
|
1851
|
+
result = Node.new(:pseudo_element, token_value(val[2]), token_position(val[0]), raw_value: token_raw(val[2]), prefix: '::')
|
|
1852
|
+
result
|
|
1853
|
+
end
|
|
1854
|
+
.,.,
|
|
1855
|
+
|
|
1856
|
+
module_eval(<<'.,.,', 'parser.y', 282)
|
|
1857
|
+
def _reduce_55(val, _values, result)
|
|
1858
|
+
fn = Node.new(:pseudo_element_function, token_value(val[2]), token_position(val[0]), raw_value: token_raw(val[2]), prefix: '::')
|
|
1859
|
+
fn.add_child(val[4])
|
|
1860
|
+
result = fn
|
|
1861
|
+
|
|
1862
|
+
result
|
|
1863
|
+
end
|
|
1864
|
+
.,.,
|
|
1865
|
+
|
|
1866
|
+
module_eval(<<'.,.,', 'parser.y', 290)
|
|
1867
|
+
def _reduce_56(val, _values, result)
|
|
1868
|
+
result = val[0]
|
|
1869
|
+
result
|
|
1870
|
+
end
|
|
1871
|
+
.,.,
|
|
1872
|
+
|
|
1873
|
+
module_eval(<<'.,.,', 'parser.y', 292)
|
|
1874
|
+
def _reduce_57(val, _values, result)
|
|
1875
|
+
result = Node.new(:argument, token_value(val[0]), token_position(val[0]), raw_value: token_raw(val[0]), quote: token_quote(val[0]))
|
|
1876
|
+
result
|
|
1877
|
+
end
|
|
1878
|
+
.,.,
|
|
1879
|
+
|
|
1880
|
+
module_eval(<<'.,.,', 'parser.y', 294)
|
|
1881
|
+
def _reduce_58(val, _values, result)
|
|
1882
|
+
result = val[0]
|
|
1883
|
+
result
|
|
1884
|
+
end
|
|
1885
|
+
.,.,
|
|
1886
|
+
|
|
1887
|
+
module_eval(<<'.,.,', 'parser.y', 296)
|
|
1888
|
+
def _reduce_59(val, _values, result)
|
|
1889
|
+
result = val[0]
|
|
1890
|
+
result
|
|
1891
|
+
end
|
|
1892
|
+
.,.,
|
|
1893
|
+
|
|
1894
|
+
module_eval(<<'.,.,', 'parser.y', 302)
|
|
1895
|
+
def _reduce_60(val, _values, result)
|
|
1896
|
+
result = Node.new(:nth_selector_argument, nil, val[0].position)
|
|
1897
|
+
result.add_child(val[0])
|
|
1898
|
+
result.add_child(val[2])
|
|
1899
|
+
|
|
1900
|
+
result
|
|
1901
|
+
end
|
|
1902
|
+
.,.,
|
|
1903
|
+
|
|
1904
|
+
module_eval(<<'.,.,', 'parser.y', 310)
|
|
1905
|
+
def _reduce_61(val, _values, result)
|
|
1906
|
+
result = val[0]
|
|
1907
|
+
result
|
|
1908
|
+
end
|
|
1909
|
+
.,.,
|
|
1910
|
+
|
|
1911
|
+
module_eval(<<'.,.,', 'parser.y', 313)
|
|
1912
|
+
def _reduce_62(val, _values, result)
|
|
1913
|
+
value = token_value(val[0])
|
|
1914
|
+
unless value =~ AN_PLUS_B_REGEX
|
|
1915
|
+
raise Parselly::SyntaxError, parse_error("Parse error: invalid An+B value '#{value}'", token_position(val[0]))
|
|
1916
|
+
end
|
|
1917
|
+
|
|
1918
|
+
result = Node.new(:an_plus_b, value, token_position(val[0]), raw_value: token_raw(val[0]))
|
|
1919
|
+
|
|
1920
|
+
result
|
|
1921
|
+
end
|
|
1922
|
+
.,.,
|
|
1923
|
+
|
|
1924
|
+
module_eval(<<'.,.,', 'parser.y', 326)
|
|
1925
|
+
def _reduce_63(val, _values, result)
|
|
1452
1926
|
# Handle 'An+B' like '2n+1'
|
|
1453
|
-
result = Node.new(:an_plus_b, "#{val[0]}#{val[1]}+#{val[3]}",
|
|
1927
|
+
result = Node.new(:an_plus_b, "#{token_value(val[0])}#{token_value(val[1])}+#{token_value(val[3])}", token_position(val[0]))
|
|
1454
1928
|
|
|
1455
1929
|
result
|
|
1456
1930
|
end
|
|
1457
1931
|
.,.,
|
|
1458
1932
|
|
|
1459
|
-
module_eval(<<'.,.,', 'parser.y',
|
|
1460
|
-
def
|
|
1933
|
+
module_eval(<<'.,.,', 'parser.y', 331)
|
|
1934
|
+
def _reduce_64(val, _values, result)
|
|
1461
1935
|
# Handle 'An-B' like '2n-1'
|
|
1462
|
-
result = Node.new(:an_plus_b, "#{val[0]}#{val[1]}-#{val[3]}",
|
|
1936
|
+
result = Node.new(:an_plus_b, "#{token_value(val[0])}#{token_value(val[1])}-#{token_value(val[3])}", token_position(val[0]))
|
|
1463
1937
|
|
|
1464
1938
|
result
|
|
1465
1939
|
end
|
|
1466
1940
|
.,.,
|
|
1467
1941
|
|
|
1468
|
-
module_eval(<<'.,.,', 'parser.y',
|
|
1469
|
-
def
|
|
1942
|
+
module_eval(<<'.,.,', 'parser.y', 336)
|
|
1943
|
+
def _reduce_65(val, _values, result)
|
|
1470
1944
|
# Handle 'An' like '2n' or composite like '2n-1' (when '-1' is part of IDENT)
|
|
1471
|
-
result = Node.new(:an_plus_b, "#{val[0]}#{val[1]}",
|
|
1945
|
+
result = Node.new(:an_plus_b, "#{token_value(val[0])}#{token_value(val[1])}", token_position(val[0]))
|
|
1472
1946
|
|
|
1473
1947
|
result
|
|
1474
1948
|
end
|
|
1475
1949
|
.,.,
|
|
1476
1950
|
|
|
1477
|
-
module_eval(<<'.,.,', 'parser.y',
|
|
1478
|
-
def
|
|
1951
|
+
module_eval(<<'.,.,', 'parser.y', 341)
|
|
1952
|
+
def _reduce_66(val, _values, result)
|
|
1479
1953
|
# Handle 'n+B' like 'n+5' or keywords followed by offset (rare but valid)
|
|
1480
|
-
result = Node.new(:an_plus_b, "#{val[0]}+#{val[2]}",
|
|
1954
|
+
result = Node.new(:an_plus_b, "#{token_value(val[0])}+#{token_value(val[2])}", token_position(val[0]))
|
|
1481
1955
|
|
|
1482
1956
|
result
|
|
1483
1957
|
end
|
|
1484
1958
|
.,.,
|
|
1485
1959
|
|
|
1486
|
-
module_eval(<<'.,.,', 'parser.y',
|
|
1487
|
-
def
|
|
1960
|
+
module_eval(<<'.,.,', 'parser.y', 346)
|
|
1961
|
+
def _reduce_67(val, _values, result)
|
|
1488
1962
|
# Handle 'n-B' like 'n-3'
|
|
1489
|
-
result = Node.new(:an_plus_b, "#{val[0]}-#{val[2]}",
|
|
1963
|
+
result = Node.new(:an_plus_b, "#{token_value(val[0])}-#{token_value(val[2])}", token_position(val[0]))
|
|
1490
1964
|
|
|
1491
1965
|
result
|
|
1492
1966
|
end
|
|
1493
1967
|
.,.,
|
|
1494
1968
|
|
|
1495
|
-
module_eval(<<'.,.,', 'parser.y',
|
|
1496
|
-
def
|
|
1969
|
+
module_eval(<<'.,.,', 'parser.y', 352)
|
|
1970
|
+
def _reduce_68(val, _values, result)
|
|
1497
1971
|
# Handle '-An+B' like '-2n+1'
|
|
1498
|
-
result = Node.new(:an_plus_b, "-#{val[1]}#{val[2]}+#{val[4]}",
|
|
1972
|
+
result = Node.new(:an_plus_b, "-#{token_value(val[1])}#{token_value(val[2])}+#{token_value(val[4])}", token_position(val[0]))
|
|
1499
1973
|
|
|
1500
1974
|
result
|
|
1501
1975
|
end
|
|
1502
1976
|
.,.,
|
|
1503
1977
|
|
|
1504
|
-
module_eval(<<'.,.,', 'parser.y',
|
|
1505
|
-
def
|
|
1978
|
+
module_eval(<<'.,.,', 'parser.y', 357)
|
|
1979
|
+
def _reduce_69(val, _values, result)
|
|
1506
1980
|
# Handle '-An-B' like '-2n-1'
|
|
1507
|
-
result = Node.new(:an_plus_b, "-#{val[1]}#{val[2]}-#{val[4]}",
|
|
1981
|
+
result = Node.new(:an_plus_b, "-#{token_value(val[1])}#{token_value(val[2])}-#{token_value(val[4])}", token_position(val[0]))
|
|
1508
1982
|
|
|
1509
1983
|
result
|
|
1510
1984
|
end
|
|
1511
1985
|
.,.,
|
|
1512
1986
|
|
|
1513
|
-
module_eval(<<'.,.,', 'parser.y',
|
|
1514
|
-
def
|
|
1987
|
+
module_eval(<<'.,.,', 'parser.y', 362)
|
|
1988
|
+
def _reduce_70(val, _values, result)
|
|
1515
1989
|
# Handle '-An' like '-2n' or composite like '-2n+1' (when '+1' is part of IDENT)
|
|
1516
|
-
result = Node.new(:an_plus_b, "-#{val[1]}#{val[2]}",
|
|
1990
|
+
result = Node.new(:an_plus_b, "-#{token_value(val[1])}#{token_value(val[2])}", token_position(val[0]))
|
|
1517
1991
|
|
|
1518
1992
|
result
|
|
1519
1993
|
end
|
|
1520
1994
|
.,.,
|
|
1521
1995
|
|
|
1522
|
-
module_eval(<<'.,.,', 'parser.y',
|
|
1523
|
-
def
|
|
1996
|
+
module_eval(<<'.,.,', 'parser.y', 367)
|
|
1997
|
+
def _reduce_71(val, _values, result)
|
|
1524
1998
|
# Handle '-n+B' like '-n+3'
|
|
1525
|
-
result = Node.new(:an_plus_b, "-#{val[1]}+#{val[3]}",
|
|
1999
|
+
result = Node.new(:an_plus_b, "-#{token_value(val[1])}+#{token_value(val[3])}", token_position(val[0]))
|
|
1526
2000
|
|
|
1527
2001
|
result
|
|
1528
2002
|
end
|
|
1529
2003
|
.,.,
|
|
1530
2004
|
|
|
1531
|
-
module_eval(<<'.,.,', 'parser.y',
|
|
1532
|
-
def
|
|
2005
|
+
module_eval(<<'.,.,', 'parser.y', 372)
|
|
2006
|
+
def _reduce_72(val, _values, result)
|
|
1533
2007
|
# Handle '-n-B' like '-n-2'
|
|
1534
|
-
result = Node.new(:an_plus_b, "-#{val[1]}-#{val[3]}",
|
|
2008
|
+
result = Node.new(:an_plus_b, "-#{token_value(val[1])}-#{token_value(val[3])}", token_position(val[0]))
|
|
1535
2009
|
|
|
1536
2010
|
result
|
|
1537
2011
|
end
|
|
1538
2012
|
.,.,
|
|
1539
2013
|
|
|
1540
|
-
module_eval(<<'.,.,', 'parser.y',
|
|
1541
|
-
def
|
|
2014
|
+
module_eval(<<'.,.,', 'parser.y', 377)
|
|
2015
|
+
def _reduce_73(val, _values, result)
|
|
1542
2016
|
# Handle '-n' or composite like '-n+3' (when '+3' is part of IDENT)
|
|
1543
|
-
result = Node.new(:an_plus_b, "-#{val[1]}",
|
|
2017
|
+
result = Node.new(:an_plus_b, "-#{token_value(val[1])}", token_position(val[0]))
|
|
1544
2018
|
|
|
1545
2019
|
result
|
|
1546
2020
|
end
|
|
1547
2021
|
.,.,
|
|
1548
2022
|
|
|
1549
|
-
module_eval(<<'.,.,', 'parser.y',
|
|
1550
|
-
def
|
|
2023
|
+
module_eval(<<'.,.,', 'parser.y', 383)
|
|
2024
|
+
def _reduce_74(val, _values, result)
|
|
1551
2025
|
# Handle just a number like '3'
|
|
1552
|
-
result = Node.new(:an_plus_b, val[0].to_s,
|
|
2026
|
+
result = Node.new(:an_plus_b, token_value(val[0]).to_s, token_position(val[0]))
|
|
1553
2027
|
|
|
1554
2028
|
result
|
|
1555
2029
|
end
|
|
1556
2030
|
.,.,
|
|
1557
2031
|
|
|
1558
|
-
module_eval(<<'.,.,', 'parser.y',
|
|
1559
|
-
def
|
|
2032
|
+
module_eval(<<'.,.,', 'parser.y', 396)
|
|
2033
|
+
def _reduce_75(val, _values, result)
|
|
1560
2034
|
result = val
|
|
1561
2035
|
result
|
|
1562
2036
|
end
|
|
1563
2037
|
.,.,
|
|
1564
2038
|
|
|
1565
|
-
module_eval(<<'.,.,', 'parser.y',
|
|
1566
|
-
def
|
|
2039
|
+
module_eval(<<'.,.,', 'parser.y', 396)
|
|
2040
|
+
def _reduce_76(val, _values, result)
|
|
1567
2041
|
result = val[1] ? val[1].unshift(val[0]) : val
|
|
1568
2042
|
result
|
|
1569
2043
|
end
|
|
1570
2044
|
.,.,
|
|
1571
2045
|
|
|
1572
|
-
module_eval(<<'.,.,', 'parser.y',
|
|
1573
|
-
def
|
|
2046
|
+
module_eval(<<'.,.,', 'parser.y', 396)
|
|
2047
|
+
def _reduce_77(val, _values, result)
|
|
1574
2048
|
result = val[1] ? val[1].unshift(val[0]) : val
|
|
1575
2049
|
result
|
|
1576
2050
|
end
|
|
1577
2051
|
.,.,
|
|
1578
2052
|
|
|
1579
|
-
module_eval(<<'.,.,', 'parser.y',
|
|
1580
|
-
def
|
|
1581
|
-
result = Node.new(:selector_list, nil,
|
|
2053
|
+
module_eval(<<'.,.,', 'parser.y', 391)
|
|
2054
|
+
def _reduce_78(val, _values, result)
|
|
2055
|
+
result = Node.new(:selector_list, nil, val[0].position)
|
|
1582
2056
|
result.add_child(val[0])
|
|
1583
2057
|
val[1].each { |pair| result.add_child(pair[1]) }
|
|
1584
2058
|
|
|
@@ -1586,15 +2060,15 @@ module_eval(<<'.,.,', 'parser.y', 246)
|
|
|
1586
2060
|
end
|
|
1587
2061
|
.,.,
|
|
1588
2062
|
|
|
1589
|
-
module_eval(<<'.,.,', 'parser.y',
|
|
1590
|
-
def
|
|
2063
|
+
module_eval(<<'.,.,', 'parser.y', 399)
|
|
2064
|
+
def _reduce_79(val, _values, result)
|
|
1591
2065
|
result = val[0]
|
|
1592
2066
|
result
|
|
1593
2067
|
end
|
|
1594
2068
|
.,.,
|
|
1595
2069
|
|
|
1596
|
-
module_eval(<<'.,.,', 'parser.y',
|
|
1597
|
-
def
|
|
2070
|
+
module_eval(<<'.,.,', 'parser.y', 402)
|
|
2071
|
+
def _reduce_80(val, _values, result)
|
|
1598
2072
|
result = Node.new(:selector, nil, val[0].position)
|
|
1599
2073
|
result.add_child(val[0])
|
|
1600
2074
|
result.add_child(val[1])
|